Coder Social home page Coder Social logo

path-slider's Introduction

Path Slider

Sliding elements along SVG paths!

Basic Usage Links

TUTORIAL

DEMO

CODEPEN

Advanced Usage Links

TUTORIAL

Demo Elastic | Demo Images

Codepen Elastic | Codepen Images

Documentation

PathSlider constructor ask for 3 parameters:

  • path: SVG path (or String selector) to slide elements through it
  • items: DOM elements (or String selector) to slide
  • options: Object with options to override defaults

For example:

var options = {startLength: 0};
var mySlider = new PathSlider('.path', '.item', options);

Possible options:

  • startLength (float or 'center'): Length of the path to start positioning the elements
  • activeSeparation (float): Separation among the active item and adjacent items
  • paddingSeparation (float): Padding separation at the beginning and the end of the path
  • duration, delay, easing, elasticity: Refer to anime.js library options
  • stagger (ms): Delay among animations of each item
  • begin (function): Callback function to call immediately before each item animation starts
  • end (function): Callback function to call immediately after each item animation ends
  • beginAll (function): Callback function to call immediately before all the animations starts
  • endAll (function): Callback function to call immediately after all the animations ends
  • blockUntilEnd (boolean): If true (false by default), you need to wait current animation ends to select a new item
  • clickSelection (boolean): If true (default), add listeners for click events in every item to allow selecting them

Callback functions begin and end receive an object with some useful info:

  • index: Index of item
  • node: The DOM node
  • selected: True if item has been selected
  • unselected: True if item has been unselected

Selecting items:

By default, the library add listeners for click events in every item to allow selecting them (clickSelection option). You can also select items using the following functions:

  • selectPrevItem(): Select the prev item
  • selectNextItem(): Select the next item
  • selectItem(index): Select any item using the corresponding index

For example:

mySlider.selectPrevItem(); // Or any of the following
// mySlider.selectNextItem();
// mySlider.selectItem(0);

path-slider's People

Contributors

lmgonzalves avatar

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.