• Stars
    star
    221
  • Rank 179,773 (Top 4 %)
  • Language
    HTML
  • License
    MIT License
  • Created almost 7 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Animating Elements Along SVG Paths with Javascript

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

More Repositories

1

segment

A JavaScript library to draw and animate SVG path strokes
CSS
1,741
star
2

pieces

Javascript library to draw and animate images, texts or SVG paths as multiple rectangular pieces
JavaScript
226
star
3

loading-buttons

Loading buttons demo for x-team article
JavaScript
147
star
4

morphing-hamburger-menu

A CSS only Morphing Hamburger Menu.
CSS
134
star
5

download-button

Download Button full of Micro Interactions
CSS
123
star
6

jelly

Drawing and Animating Jelly Shapes with Canvas
JavaScript
112
star
7

momentum-slider

Create sliders with momentum!
CSS
99
star
8

elastic-slider

An experimental slider using SVG clip-path feature and animations powered by Snap.svg
CSS
83
star
9

brushstroke

Draw creative brushstrokes directly in the browser with a nice API. Be able to draw solid colors, images, or even HTML!
JavaScript
80
star
10

cody

A library to embed demos for front-end developers. No dependencies and fully customizable!
JavaScript
75
star
11

splash-transition

Creating an eye catching animation, just using SVG paths and CSS transitions.
CSS
69
star
12

letters

An experimental plugin for animating SVG letters using Segment.
JavaScript
55
star
13

images-gallery

Images Gallery using PixiJS and WebGL
JavaScript
55
star
14

scroll-based-animation

Scroll Based Animation with JavaScript
JavaScript
48
star
15

spy

Custom Scrollspy with Gumshoe, Smooth Scroll and Anime.js
JavaScript
33
star
16

elastic-range-input

Fancy component to simulate a range input
CSS
33
star
17

creative-upload

Creative Upload Interaction with Javascript and Canvas
CSS
25
star
18

dissection-puzzles

Learn how to create and animate dissection puzzles using just CSS and SVG.
CSS
19
star
19

pieces-slider

A slider made with the Pieces library where slides are animated in a fragmented look.
JavaScript
14
star
20

animated-refresh-icon

Refresh icon animated with SVG, segment, and CSS animations.
JavaScript
10
star