Glider
Paraglider plugin.
Constructor Summary
Public Constructor | ||
public |
constructor(options: PLUGIN_DEFAULTS): this Paraglider is an API driven slider. |
Member Summary
Private Members | ||
private |
State store for interaction flags |
|
private |
animation: loop Animation flag. |
|
private |
Outer element |
|
private |
Plugin options merged from defaults and custom configuration |
|
private |
A list of all slides. |
|
private |
This element is used to track mouse or touch interaction |
|
private get |
Getter for the state |
Method Summary
Public Methods | ||
public |
destroy() Destroys the plugin by removing event listeners and class names |
|
public |
Moves to the nth slide via trigger. |
|
public |
Init call for the plugin. |
|
public |
Moves to the next slide via trigger. |
|
public |
Moves to the previous slide via trigger. |
Private Methods | ||
private |
Adds class names to slides |
|
private |
Initially set class names |
|
private |
Adds event listeners needed for this plugin to work. |
|
private |
addSides() Add |
|
private |
getClientX(e: Event): number Find clientX from the event. |
|
private |
getReturnValues(direction: boolean): object Prepares return values |
|
private |
handleDown(e: Event) First interaction with the mouse or per touch will be used to set flags and define initial values. |
|
private |
Handle the end of the slide animation. |
|
private |
handleMove(e: Event) Handler for mouse or touch movement. |
|
private |
Handles the progress. |
|
private |
handleUp() Last interaction with the mouse or per touch will be used to set flags and define initial values. |
|
private |
Batch removal of class names. |
|
private |
Removes all event listeners. |
|
private |
Handles internal storage |
|
private |
Handles the snap animation |
Public Constructors
public constructor(options: PLUGIN_DEFAULTS): this source
Paraglider is an API driven slider. It exposes a timeline and offers some options.
This gives developers a lot of freedom when implementing a slider. The main purpose for this plugin is to create slideshows with a parallax effect. Due to the simplicity you can feed the timeline to other plugins and create amazing effects like animating SVGs or drawing on a canvas.
Params:
Name | Type | Attribute | Description |
options | PLUGIN_DEFAULTS | Custom options for the Plugin call |
Return:
this |
Private Members
private animation: loop source
Animation flag. Calls the animation and stores the function to allow cancelAnimationFrame
Public Methods
public goTo(n: number): * source
Moves to the nth slide via trigger. Respects left/right movement
Params:
Name | Type | Attribute | Description |
n | number | index of requested slide |
Return:
* |
public init(el: Element) source
Init call for the plugin.
This method assigns the element to the plugin scope, adds the required event listeners and class names.
Params:
Name | Type | Attribute | Description |
el | Element | An element containing the required markup with and selectors |
public nextSlide(e: Event): * source
Moves to the next slide via trigger.
Params:
Name | Type | Attribute | Description |
e | Event |
|
optionally pass the event to prevent it |
Return:
* |
public prevSlide(e: Event): * source
Moves to the previous slide via trigger.
Params:
Name | Type | Attribute | Description |
e | Event |
|
optionally pass the event to prevent it |
Return:
* |
Private Methods
private addInitClassNames() source
Initially set class names
init
will be removed after the first interaction. It allows a 'silent' start
when working with CSS animations or transitions.
private addListeners() source
Adds event listeners needed for this plugin to work. Movement and release should be tracked on window or document.
Listen:
touchmove |
Listens to touchmove if |
touchend |
Listens to touchend if |
touchstart |
Listens to touchstart if |
mousemove |
Listens to mousemove if |
mouseup |
Listens to mouseup if |
mousedown |
Listens to mousedown if |
private addSides() source
Add previous
and next
classes around the current
slide.
This function respects pager clicks, which modify the next or previous element.
private getClientX(e: Event): number source
Find clientX from the event. This helper will return the correct value for touch or mouse.
Params:
Name | Type | Attribute | Description |
e | Event | Mouse or touch event |
private getReturnValues(direction: boolean): object source
Prepares return values
Params:
Name | Type | Attribute | Description |
direction | boolean |
private handleDown(e: Event) source
First interaction with the mouse or per touch will be used to set flags and define initial values.
Params:
Name | Type | Attribute | Description |
e | Event | Mouse or touch event |
private handleEnd(end: number) source
Handle the end of the slide animation.
If there is a callback called onEnd
call it.
Params:
Name | Type | Attribute | Description |
end | number | Final value |
private handleMove(e: Event) source
Handler for mouse or touch movement.
Waits for a threshold and then records the movement on the x
axis
Params:
Name | Type | Attribute | Description |
e | Event | Mouse or touch move event |
private handleProgress() source
Handles the progress. Calculates the progress from the internal state and element dimension. A callback is fired if set
private handleUp() source
Last interaction with the mouse or per touch will be used to set flags and define initial values. Only fires if down is active. Prevents unintended behavior when the first touch or mousedown was outside the element.
private removeClassNames() source
Batch removal of class names. This is dirty but simply removes anything the plugin could have set.
TODO:
- Find a better way to do this.
private removeListeners() source
Removes all event listeners. (Helpful when destroying the plugin instance)