Home Manual Reference Source Repository

Function

Static Public Summary
public

Belt animation slider.

public

Cover left animation slider

public

Cover left/right animation slider

public

Cover right animation slider

public

dataWrapper(glider: Element, opts: DATA_DEFAULTS): function

Wraps Paraglider to apply pagers and navigation buttons and autoplay.

public

Belt animation slider.

public

Wrapper including navigation arrows.

public

Simple wrapper including pagers and navigation arrows.

Static Private Summary
private

animate(speed: integer, from: number, to: number, callback: animationCallback): function

Animates from one value to the other over a given time.

private

arrayOrValue(arr: array): any

Takes an array and returns a single value if it is the only item.

private

eitherOr(either: any, or: any): any

Returns either the first or second value depending on truthness.

private

findAll(selector: string, context: Element): array

Helper to get elements.

private

findFirst(selector: string, context: Element): Element

Helper to get elements.

private

modLoop(current: number, addition: number, length: number): number

A loop using modulo

private

parseObject(dataset: dataset): object

Parse dataset with nested object strings to a true object

private

Prevents default event

private

toggleClass(el: Element, className: string, bool: boolean)

Toggle class ponyFill to support IE11 and other awkward browsers.

version [version]

Static Public

public belt(glider: Element, opts: PRESET_DEFAULTS): function source

Belt animation slider.

This is a default slider that moves the current and next or previous slide at the same time. The movement is linear.

Params:

NameTypeAttributeDescription
glider Element
opts PRESET_DEFAULTS

Return:

function

returns the destroy method

public coverLeft(glider: Element, opts: PRESET_DEFAULTS): function source

import coverLeft from 'paraglider/src/presets/cover-left.js'

Cover left animation slider

This is a slider that moves the next or previous over the current slide. The movement is linear. Sides always cover from left.

Params:

NameTypeAttributeDescription
glider Element
opts PRESET_DEFAULTS

Return:

function

returns the destroy method

public coverLeftRight(glider: Element, opts: PRESET_DEFAULTS): function source

import coverLeftRight from 'paraglider/src/presets/cover-left-right.js'

Cover left/right animation slider

This is a slider that moves the next or previous over the current slide. The movement is linear. Sides cover from left and right

Params:

NameTypeAttributeDescription
glider Element
opts PRESET_DEFAULTS

Return:

function

returns the destroy method

public coverRight(glider: Element, opts: PRESET_DEFAULTS): function source

import coverRight from 'paraglider/src/presets/cover-right.js'

Cover right animation slider

This is a slider that moves the next or previous over the current slide. The movement is linear. Sides always cover from right.

Params:

NameTypeAttributeDescription
glider Element
opts PRESET_DEFAULTS

Return:

function

returns the destroy method

public dataWrapper(glider: Element, opts: DATA_DEFAULTS): function source

import dataWrapper from 'paraglider/src/presets/data-wrapper.js'

Wraps Paraglider to apply pagers and navigation buttons and autoplay. This wrapper simplifies the usage of Paraglider by offering some basic functionality. Data attributes are used to configure the plugin.

Params:

NameTypeAttributeDescription
glider Element
opts DATA_DEFAULTS

Return:

function

returns the destroy method

public multiBelt(glider: Element, opts: PRESET_DEFAULTS): function source

import multiBelt from 'paraglider/src/presets/multi-belt.js'

Belt animation slider.

This is a default slider that moves the current and next or previous slide at the same time. The movement is linear.

Params:

NameTypeAttributeDescription
glider Element
opts PRESET_DEFAULTS

Return:

function

returns the destroy method

public multiWrapper(glider: Element, opts: PRESET_DEFAULTS): function source

import multiWrapper from 'paraglider/src/presets/multi-wrapper.js'

Wrapper including navigation arrows. Allows using visibleSlides & slideBy options

Use this helper to create custom sliders with arrows, to navigate to different slides. The options are extended by additional class names.

Params:

NameTypeAttributeDescription
glider Element
opts PRESET_DEFAULTS

Return:

function

returns the destroy method

public wrapper(glider: Element, opts: PRESET_DEFAULTS): function source

import wrapper from 'paraglider/src/presets/wrapper.js'

Simple wrapper including pagers and navigation arrows.

Use this helper to create custom sliders with pager dots and arrows, to navigate to different slides. The options are extended by additional class names.

Params:

NameTypeAttributeDescription
glider Element
opts PRESET_DEFAULTS

Return:

function

returns the destroy method

Static Private

private animate(speed: integer, from: number, to: number, callback: animationCallback): function source

import {animate} from 'paraglider/src/helpers.js'

Animates from one value to the other over a given time. This function uses requestAnimationFrame and Date to return a reliable result.

Params:

NameTypeAttributeDescription
speed integer

Duration of animation

from number

Starting point

to number

End point

callback animationCallback

Callback to be run on every step.

Return:

function

A looping function.

private arrayOrValue(arr: array): any source

import {arrayOrValue} from 'paraglider/src/helpers.js'

Takes an array and returns a single value if it is the only item. Otherwise it returns the original array.

Params:

NameTypeAttributeDescription
arr array

Array to check

Return:

any (nullable: true)

Example:

arrayOrValue([null, 1, 2]) // => [null, 1, 2]
arrayOrValue([1]) // => 1
arrayOrValue(['a']) // => 'a'
arrayOrValue([1,'1']) // => [1,'1']
arrayOrValue([null]) // => null

private eitherOr(either: any, or: any): any source

import {eitherOr} from 'paraglider/src/helpers.js'

Returns either the first or second value depending on truthness. Any number is considered true.

Params:

NameTypeAttributeDescription
either any
or any

Return:

any

One of the two input values

Example:

eiterOr(0, 4) // => 0
eiterOr('0', 4) // => '0'
eiterOr('foo', 4) // => 'foo'
eiterOr('', 4) // => 4
eiterOr(false, 4) // => 4
eiterOr(undefined, 4) // => 4
eiterOr(null, 4) // => 4
eiterOr({}, 4) // => {}
eiterOr([], 4) // => []
eiterOr(() => {}, 4) // => () => {}

private findAll(selector: string, context: Element): array source

import {findAll} from 'paraglider/src/helpers.js'

Helper to get elements. Similar to jQuery's $(selector, context)

Params:

NameTypeAttributeDescription
selector string

selector to find

context Element
  • optional
  • default: document

Context to search in

Return:

array

A list of matching elements

Example:

findAll('.foo') // => [...]

private findFirst(selector: string, context: Element): Element source

import {findFirst} from 'paraglider/src/helpers.js'

Helper to get elements. Similar to jQuery's $(selector, context)[0]

Params:

NameTypeAttributeDescription
selector string

selector to find

context Element
  • optional
  • default: document

Context to search in

Return:

Element

The first matching element

Example:

findFirst('.foo') // => <div .../>

private modLoop(current: number, addition: number, length: number): number source

import {modLoop} from 'paraglider/src/helpers.js'

A loop using modulo

Params:

NameTypeAttributeDescription
current number

Current value

addition number

Addition to the current value

length number

Maximum value.

Return:

number

Resulting number

Example:

modLoop(1, 2, 3) // => 0
modLoop(2, 3, 4) // => 1
modLoop(2, -3, 4) // => 3
modLoop(20, -3, 20) // => 17
modLoop(20, -30, 20) // => 10

private parseObject(dataset: dataset): object source

import {parseObject} from 'paraglider/src/helpers.js'

Parse dataset with nested object strings to a true object

Params:

NameTypeAttributeDescription
dataset dataset

Return:

object

valid JSON

Example:

const data = parseObject(document.querySelector('.foo').dataset)

private preventDefault(e: Event) source

import {preventDefault} from 'paraglider/src/helpers.js'

Prevents default event

Params:

NameTypeAttributeDescription
e Event

Example:

el.addEventListener('mousemove', preventDefault)
el.addEventListener('dragstart', e => {
  preventDefault(e)
  // ...
})

private toggleClass(el: Element, className: string, bool: boolean) version [version] source

import {toggleClass} from 'paraglider/src/helpers.js'

Toggle class ponyFill to support IE11 and other awkward browsers. IE11 can't use a second argument in element.classList.toggle

Params:

NameTypeAttributeDescription
el Element
className string
bool boolean

Example:

const element = document.querySelector('a')
const isActive = true
toggle(element, active, isActive) // add active
toggle(element, active, 1) // add active
toggle(element, active, !0) // add active
toggle(element, active, !!1) // add active
toggle(element, active, 'yes') // add active
toggle(element, active, 'no') // add active
toggle(element, active, null) // toggle active
toggle(element, active) // toggle active
toggle(element, active, false) // remove active
toggle(element, active, 0) // remove active
toggle(element, active, !!0) // remove active
toggle(element, active, '') // remove active

See: