1.2.0 âĸ Published 2 years ago
slidemanager v1.2.0
đ¨đŧâđ§ Slidemanager
Simple slide manager đĢ Focused on animations.
Installation
npm add slidemanagerUsage
import Slidemanager from 'slidemanager'
const slider = new Slidemanager({
el: document.querySelector('#gallery'),
callback({ current, previous, direction, done }) {
// Your animations here
// ...
// Call done() when your animation is complete
done()
}
})Parameters
Options
- đŧ
el: DOM element to attach the swipe event to. If not given, please provide alengthparameter. - âšī¸
callback: function called when user swipes or slide changes automatically. - đÂ
loop: whether to stop at the last / first slide or not. (Defaultfalse) - âļī¸Â
auto: set it totrueto automatically switch to the next slide. (Defaultfalse) - â¯
interval: specifies the interval in seconds between each slide change.automust betrue. (Default5) - âī¸Â
vertical: if set totrue, the swipe movement to change the current slide will need to be vertical. (Defaultfalse) - đĸ
length: number of slides. If not given, The number of slides will be the number ofel's children - *ī¸âŖÂ
swipe: iffalse, the swipe touch movement detection is disabled. (Defaulttrue) - đ
mouseSwipe: Whether the swipe movement must be checked on the mouse or not. (Defaultfalse) - đÂ
random: Switch to random slides instead of next and previous ones. Enables automatically theloopoption. (Defaultfalse) - #ī¸âŖÂ
startAt: The index from which to start the slider on initialization. (Default0) - â
threshold: Amount of pixels required to change slide when swiping (Default60) - âē
init: Whether to init the manager immediately or not. Iffalse, call the.init()method to initialize the manager. (Defaulttrue)
Methods
- đ
prev(): goes to the previous slide - đ
next(): goes to the next slide - đ
goTo(index, data): goes to the specified index, you can pass data which can be recovered in the callback - đĻ
start()/stop(): starts / stops the automatic sliding - đ
init(): adds event listeners. Call this when theinitoption is set tofalse - â°ī¸
destroy(): removes event listeners and stops the slider
Callback
The callback function receives a parameter containing the following properties :
current: New indexprevious: Previous indexdirection: 1 for next, -1 for previousdone: the function to call when you're done with your animationsdata: some data that may be given from a call togoTo()
Instance properties
The returned Slidemanager instance exposes the following properties :
index: The current indexmax: The last element's indexchanging: Whether the slider is currently moving or not
License
MIT, see LICENSE.md for details.
1.2.0
2 years ago
1.1.0
4 years ago
1.0.1
5 years ago
1.0.0
6 years ago
0.4.8
7 years ago
0.4.7
7 years ago
0.4.6
7 years ago
0.4.5
7 years ago
0.4.4
7 years ago
0.4.3
7 years ago
0.4.2
8 years ago
0.4.1
8 years ago
0.4.0
8 years ago
0.3.9
8 years ago
0.3.8
8 years ago
0.3.7
8 years ago
0.3.6
8 years ago
0.3.5
8 years ago
0.3.3
9 years ago
0.3.2
9 years ago
0.3.1
9 years ago
0.3.0
9 years ago
0.2.1
9 years ago
0.2.0
9 years ago
0.1.0
9 years ago
0.0.9
9 years ago
0.0.8
9 years ago
0.0.7
9 years ago
0.0.6
9 years ago
0.0.5
9 years ago
0.0.4
9 years ago
0.0.3
9 years ago
0.0.2
9 years ago
0.0.1
9 years ago