Home Manual Reference Source Repository

Typedef

Static Public Summary
public
public

Callback when the Glider has been destroyed

public

onEnd(data: callbackData, slides: Array<Element>, options: callbackOptions): *

Callback when the Glider stopped moving

public

Callback when the Glider has been created

public

onSlide(progress: number, data: callbackData, slides: Array<Element>, options: callbackOptions): *

Callback while the Glider is moving

Static Private Summary
private

animationCallback(progress: number): *

Static Public

public callbackData: * source

Properties:

NameTypeAttributeDescription
previous number | Array<number>
  • nullable: true

Could be an Array, a number or null.

  • null: no items available
  • number: one item available
  • array: multiple items available
current number | Array<number>
  • nullable: true

Could be an Array, a number or null.

  • null: no items available
  • number: one item available
  • array: multiple items available
next number | Array<number>
  • nullable: true

Could be an Array, a number or null.

  • null: no items available
  • number: one item available
  • array: multiple items available
rest Array<number>

Array of all remaining slide indexes. If none are left the array is just empty

public onDestroy(options: PLUGIN_DEFAULTS | PRESET_DEFAULTS): * source

Callback when the Glider has been destroyed

Example:

new Glider({
 onDestroy(options) {
   // Slider has been destroyed
 }
})

public onEnd(data: callbackData, slides: Array<Element>, options: callbackOptions): * source

Callback when the Glider stopped moving

Example:

new Glider({
 onEnd({next, previous, current, rest}, slides, options) {
   rest.forEach(slide => {
     slides[slide].style.transform = ''
   })
   slides[current].style.transform = ''
   slides[previous].style.transform = 'translate3d(-100%,0,0)'
   slides[next].style.transform = 'translate3d(100%,0,0)'
 }
})

public onInit(data: callbackData, slides: Array<Element>, options: PLUGIN_DEFAULTS | PRESET_DEFAULTS): * source

Callback when the Glider has been created

Example:

new Glider({
 onInit({next, previous, current, rest}, slides, options) {
   slides[current].style.background = 'red'
 }
})

public onSlide(progress: number, data: callbackData, slides: Array<Element>, options: callbackOptions): * source

Callback while the Glider is moving

Example:

new Glider({
 onSlide(progress, {next, previous, current, rest}, slides, options) {
   if (previous !== null) {
     slides[previous].style.transform = `translate3d(${-100 + (progress * 100)}%,0,0)`
     slides[current].style.transform = `translate3d(${(progress * 100)}%,0,0)`
   } else if (next !== null) {
     slides[next].style.transform = `translate3d(${100 - (progress * 100)}%,0,0)`
     slides[current].style.transform = `translate3d(${(progress * -100)}%,0,0)`
   }
 }
})

Static Private

private animationCallback(progress: number): * source

Example:

animate(1000, 0, 1,
  p => {
    console.log(p)
  }
)