1.2.0 â€ĸ Published 3 months ago

slidemanager v1.2.0

Weekly downloads
15
License
MIT
Repository
github
Last release
3 months ago

👨đŸŧ‍🔧 Slidemanager

npm bundlephobia NpmLicense

Simple slide manager đŸ’Ģ Focused on animations.

Installation

npm add slidemanager

Usage

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 a length parameter.
  • ℹī¸ callback : function called when user swipes or slide changes automatically.
  • 🔄  loop : whether to stop at the last / first slide or not. (Default false)
  • â–ļī¸Â  auto : set it to true to automatically switch to the next slide. (Default false)
  • ⏯ interval : specifies the interval in seconds between each slide change. auto must be true. (Default 5)
  • ↕ī¸Â  vertical : if set to true, the swipe movement to change the current slide will need to be vertical. (Default false)
  • đŸ”ĸ length : number of slides. If not given, The number of slides will be the number of el's children
  • *ī¸âƒŖ  swipe : if false, the swipe touch movement detection is disabled. (Default true)
  • 🈁 mouseSwipe : Whether the swipe movement must be checked on the mouse or not. (Default false)
  • 🔀  random : Switch to random slides instead of next and previous ones. Enables automatically the loop option. (Default false)
  • #ī¸âƒŖ  startAt : The index from which to start the slider on initialization. (Default 0)
  • ⏭ threshold : Amount of pixels required to change slide when swiping (Default 60)
  • âē init : Whether to init the manager immediately or not. If false, call the .init() method to initialize the manager. (Default true)

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 the init option is set to false
  • ⚰ī¸ destroy() : removes event listeners and stops the slider

Callback

The callback function receives a parameter containing the following properties :

  • current : New index
  • previous : Previous index
  • direction : 1 for next, -1 for previous
  • done : the function to call when you're done with your animations
  • data : some data that may be given from a call to goTo()

Instance properties

The returned Slidemanager instance exposes the following properties :

  • index : The current index
  • max : The last element's index
  • changing : Whether the slider is currently moving or not

License

MIT, see LICENSE.md for details.

1.2.0

3 months ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago

0.4.8

5 years ago

0.4.7

5 years ago

0.4.6

6 years ago

0.4.5

6 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.9

6 years ago

0.3.8

6 years ago

0.3.7

6 years ago

0.3.6

6 years ago

0.3.5

6 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago