title | layout | slug | priority | algolia |
---|---|---|---|---|
API |
docs.html |
api |
5 |
true |
[[lead]]Bunch of helpful properties and methods are available through Glide instance[[/lead]]
- Usage: Holds currently active zero-based slide index.
var glide = new Glide('.glide', { startAt: 1 }).mount()
var i = glide.index // => 1
- Usage: Holds instance initialization settings.
var glide = new Glide('.glide', { startAt: 1 }).mount()
var startAt = glide.settings.startAt // => 1
- Usage: Holds type of the Glide instance.
var glide = new Glide('.glide').mount()
var type = glide.type // => 'slider'
- Usage: Holds state of the ability to interact.
var glide = new Glide('.glide').mount()
console.log(glide.disabled) // => false
glide.disable()
console.log(glide.disabled) // => true
- Usage: A Glide instance is in "uninitialized" mode until a
mount()
method call. It starts an entire building process.
var glide = new Glide('.glide')
glide.mount()
- Example:
[[example dir=api/mount]]
-
Arguments:
{Object} settings
-
Usage: Update settings for the Glide instance.
var glide = new Glide('.glide', { startAt: 0 }).mount()
glide.update({ startAt: 1 })
- Example:
[[example dir=api/update]]
- Usage: Destroy instance and undo all modifications which have been made to the DOM. It also unbinds added event listeners.
var glide = new Glide('.glide', { startAt: 0 }).mount()
glide.destroy()
- Example:
[[example dir=api/destroy]]
-
Arguments:
{String|Array} event
{Function} [definition]
-
Usage: Register callback which will be called at the specified events.
var glide = new Glide('.glide')
glide.on('mount.after', function () {
// Logic fired after mounting
})
glide.mount()
- Example:
[[example dir=api/on]]
-
Arguments:
{String} pattern
-
Usage: Make movement based on the defined pattern. A pattern must be in the special format:
>
- Move one forward<
- Move one backward={i}
- Go to {i} zero-based slide (eq. '=1', will go to second slide)>>
- Rewinds to end (last slide)<<
- Rewinds to start (first slide)
var glide = new Glide('.glide').mount()
glide.go('>')
- Example:
[[example dir=api/go]]
- Usage: Stop auto-playing. Hold changing slides after a defined interval.
var glide = new Glide('.glide', { autoplay: 4000 }).mount()
glide.pause()
- Example:
[[example dir=api/pause]]
-
Arguments:
{Number} force
Force to run auto-playing with passed interval regardless ofautoplay
settings
-
Usage: Start previously stopped auto-playing.
var glide = new Glide('.glide', { autoplay: 4000 }).mount()
glide.pause() // Pausing so we can resume it later
glide.play()
If instance was initialized with disabled autoplay, you can forcefully start it by passing interval number into play()
method.
var glide = new Glide('.glide', { autoplay: false }).mount()
glide.play(4000)
- Example:
[[example dir=api/play]]
- Usage: Disable instance interaction. Blocks ability to manually change slides via controls or API.
var glide = new Glide('.glide').mount()
glide.disable()
- Example:
[[example dir=api/disable]]
- Usage: Enable previously disabled instance. Start responding to interaction.
var glide = new Glide('.glide').mount()
glide.enable()
- Example:
[[example dir=api/enable]]
-
Arguments:
{String} type
-
Usage: Verify the type of a Glide instance.
var slider = new Glide('.glide', { type: 'carousel' }).mount()
slider.isType('slider') // => false
slider.isType('carousel') // => true