0.6.5 • Published 5 years ago

vue-carousel-preset v0.6.5

Weekly downloads
56
License
MIT
Repository
github
Last release
5 years ago

vue-Carousel-Preset

This is an updated version of the popular carousel package Vue-carousel.

Installation

npm install vue-carousel-preset

or if you prefer yarn

yarn add vue-carousel-preset

Usage

Global

installing vue-carousel-preset globally:

import Vue from 'vue';
import VueCarousel from 'vue-carousel-preset';

Vue.use(VueCarousel);

This will make <carousel> and <slide> available to all components within your Vue app.

Local

Include the carousel directly into your component using import:

import { Carousel, Slide } from 'vue-carousel-preset';

export default {
  ...
  components: {
    Carousel,
    Slide
  }
  ...
};

Configuration

PropertyTypeDefaultDescription
adjustableHeightBooleanfalseAdjust the height of the carousel for the current slide.
adjustableHeightEasingStringSlide transition easing for adjustableHeight. Any valid CSS transition easing accepted.
autoplayBooleanfalseFlag to enable autoplay.
autoplayDirectionStringforwardSets the autoplay direction for the carousel during autoplay. By default it is forward ut can also be set to backward. If an incorrect string is supplied it will default to forward.
navigationArrowsBooleanfalseShow navigation arrows.
verticallyCenterNavArrowsBooleanfalseShow navigation arrows on the right and left of the carousel slides.
slideDisabledStyleBooleanfalseAdd opacity on non disabled slides and removes overflow hidden.
showThumbsBooleanfalseShow thumbnails underneath carousel.
thumbContainerStyleObject{ marginTop: '0' }Define styles for the thumbnails container.
thumbImageStylesObject{ width: '80px' }Define styles for each thumbnail.
darkModeBooleanfalseUses gray arrow svgs for the navigation arrows.
autoplayHoverPauseBooleantrueFlag to pause autoplay on hover.
autoplayTimeoutNumber2000Time elapsed before advancing slide in autoplay.
centerModeBooleanfalseCenter images when the size is less than the container width.
easingStringeaseSlide transition easing. Any valid CSS transition easing accepted.
loopBooleanfalseFlag to make the carousel loop around when it reaches the end.
minSwipeDistanceNumber8Minimum distance for the swipe to trigger a slide advance.
mouseDragBooleantrueFlag to toggle mouse dragging.
navigateToNumber0Listen for an external navigation request using this prop.
navigationClickTargetSizeNumber8Amount of padding to apply around the label in pixels.
navigationNextLabelStringText content of the navigation next button.
navigationPrevLabelStringText content of the navigation prev button.
paginationActiveColorString#000000The fill color of the active pagination dot. Any valid CSS color is accepted.
paginationColorString#efefefThe fill color of pagination dots. Any valid CSS color is accepted.
paginationPositionStringbottomThe position of pagination dots. Possible values are bottom, bottom-overlay, top and top-overlay. The overlay values place the pagination component over the images.
paginationEnabledBooleantrueFlag to render pagination component.
paginationPaddingNumber10The padding inside each pagination dot. Pixel values are accepted.
paginationSizeNumber10The size of each pagination dot. Pixel values are accepted.
perPageNumber2Maximum number of slides displayed on each page.
resistanceCoefNumber20Resistance coefficient to dragging on the edge of the carousel. This dictates the effect of the pull as you move towards the boundaries.
scrollPerPageBooleantrueScroll per page, not per item.
spacePaddingNumber0Stage padding option adds left and right padding style (in pixels) onto VueCarousel-inner.
spacePaddingMaxOffsetFactorNumber0Specify by how much should the space padding value be multiplied of, to re-arange the final slide padding.
speedNumber500Slide transition speed. Number of milliseconds accepted.
tagNameStringslideName (tag) of slide component. Overwrite with coponent name when extending slide component.
valueNumberSupport for v-model functionality. Setting this value will change the current page to the number inputted (if between 0 and pageCount).

Events

EventTypeEmitterDescription
pageChangeNumberCarousel"pageChange" event emits the value of the current page
slideclickObjectSlide"slideclick" event throws the dataset object of the selected element
transitionEndCarousel"transitionEnd" event is thrown when the transition end is reached

HTML Structure

Once the Carousel and Slide components are installed globally or imported, they can be used in templates in the following manner:

  <carousel :per-page="1" :navigate-to="someLocalProperty" :mouse-drag="false">
    <slide>
      Slide 1 Content
    </slide>
    <slide>
      Slide 2 Content
    </slide>
  </carousel>

To listen for the 'slideclick' event you can do the following:

  <carousel>
    <slide
        data-index="0"
        data-name="MySlideName"
        @slideclick="handleSlideClick">
      Slide 1 Content
    </slide>
    ...
  </carousel>
  handleSlideClick (dataset) => {
    console.log(dataset.index, dataset.name)
  }

Development

A sandboxed dev environment is provided by vue-play. Changes made to the component files will appear in real time in the sandbox.

To begin development, run:

yarn install
yarn dev

then navigate to http://localhost:5000

To modify and add sandbox scenarios, edit play/index.js

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

0.6.5

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.9

5 years ago

0.5.8

5 years ago

0.5.7

5 years ago

0.5.6

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.9

5 years ago

0.4.8

5 years ago

0.4.7

5 years ago

0.4.6

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.9

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago