Coder Social home page Coder Social logo

pencilpix / vue-carousel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ssense/vue-carousel

2.0 2.0 0.0 9.22 MB

A flexible, responsive, touch-friendly carousel for Vue.js

Home Page: https://ssense.github.io/vue-carousel/

License: MIT License

JavaScript 50.90% Vue 49.10%

vue-carousel's Introduction

Vue Carousel

Build Status Coverage Status Latest Stable Version

WARNING: vue-carousel is at pre-alpha stage of development and may undergo significant changes.

Feel free to submit issues and feature requests here.

Full documentation and examples

Table of Contents

Installation

npm install vue-carousel

or if you prefer yarn

yarn add vue-carousel

Usage

Global

You may install Vue Carousel globally:

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

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';

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

Configuration

Property Type Default Description
easing String ease Slide transition easing. Any valid CSS transition easing accepted.
minSwipeDistance Number 8 Minimum distance for the swipe to trigger a slide advance.
navigationClickTargetSize Number 8 Amount of padding to apply around the label in pixels.
mouseDrag Boolean true Flag to toggle mouse dragging.
navigationEnabled Boolean false Flag to render the navigation component (next/prev buttons).
navigationNextLabel String โ–ถ Text content of the navigation next button.
navigationPrevLabel String โ—€ Text content of the navigation prev button.
paginationActiveColor String #000000 The fill color of the active pagination dot. Any valid CSS color is accepted.
paginationColor String #efefef The fill color of pagination dots. Any valid CSS color is accepted.
paginationEnabled Boolean true Flag to render pagination component.
paginationPadding Number 10 The padding inside each pagination dot. Pixel values are accepted.
paginationSize Number 10 The size of each pagination dot. Pixel values are accepted.
perPage Number 2 Maximum number of slides displayed on each page.
perPageCustom Array Configure the number of visible slides with a particular browser width. This will be an array of arrays, ex. [[320, 2], [1199, 4]]. Formatted as [x, y] where x=browser width, and y=number of slides displayed. Ex. [1199, 4] means if (window <= 1199) then show 4 slides per page.
resistanceCoef Number 20 Resistance coefficient to dragging on the edge of the carousel. This dictates the effect of the pull as you move towards the boundaries.
scrollPerPage Boolean true Scroll per page, not per item.
speed Number Slide transition speed. Number of milliseconds accepted.
loop Boolean false Flag to make the carousel loop around when it reaches the end.
navigateTo Number 0 Listen for an external navigation request using this prop.
spacePadding Number 0 Stage padding option adds left and right padding style (in pixels) onto VueCarousel-inner.

Events

Event Type Emitter Description
slideClick Object Slide "slideClick" event throws the dataset object of the selected element

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:

npm install 
npm run dev

or, if you prefer yarn

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.