API
Slider
Toggle

Util

You can get self object from DOM node on Xtend UI components with Xt.get.

Xt.get({ name: 'xt-slider', el: document.querySelector('.my-container') }).then(self => {})

You can set default options for all components of the same type, with Xt.options.

Xt.options['xt-slider'] = {
  debug: true,
}

By default components are loaded and initialized only when inside viewport or instantly if self.container is not visible (display: none).

You can force global observer options or singular component observer options passing this option.

SyntaxDefault / ArgumentsDescription
Optionobserver:Boolean|nullnullForce enable or disable intersection observer

Listen

Listen to events, for listeners use this guideline.

SyntaxDOM ElementDescription
Eventon.xt.sliderelements targetsActivation event (event e.detail is original event)
Eventoff.xt.sliderelements targetsDeactivation event (event e.detail is original event)
Eventondone.xt.sliderelements targetsActivation event after delay and duration
Eventoffdone.xt.sliderelements targetsDeactivation event after delay and duration
Eventmedialoaded.xt.sliderelements targetsImages loaded event, only when setting options.mediaLoaded: true
Eventautostart.xt.slidercontainerAuto start event
Eventautostop.xt.slidercontainerAuto stop event
Eventautoheight.xt.slidertargetsAutoheight event
Eventsetup.xt.slidercontainerSetup event
Eventinit.xt.slidercontainerInit or reinit event
Eventstatus.xt.slidercontainerStatus event (enabled or disabled)
Eventrestart.xt.slidercontainerRestart event
Eventdestroy.xt.slidercontainerDestroy event

Trigger

Trigger events on DOM node.

document.querySelector('#my-element-or-target').dispatchEvent(new CustomEvent('on.trigger.xt.slider'))
SyntaxDOM ElementDescription
Eventon.trigger.xt.sliderelements targetsActivation event
Eventoff.trigger.xt.sliderelements targetsDeactivation event
Eventautostart.trigger.xt.slidercontainerAuto start event
Eventautostop.trigger.xt.slidercontainerAuto stop event

You can pass e.detail to the trigger event.

With on and off event e.detail.force = true will force the activation/deactivation skipping checks.

document.querySelector('#my-element-or-target').dispatchEvent(new CustomEvent('on.trigger.xt.slider', { detail: { force: true } }))

Properties

Access properties by getting self object.

SyntaxDescription
Propertyself.componentName:StringComponent name (used in Xt.get)
Propertyself.options:ObjectFinal options
Propertyself.initial:BooleanIf initial or reset activation
Propertyself.index:NumberCurrent index of activation
Propertyself.disabled:BooleanIf component disabled
Propertyself.container:NodeContainer node
Propertyself.elements:ArrayElements nodes
Propertyself.targets:ArrayTargets nodes
Propertyself.pags:ArrayPagination nodes
Propertyself.wrap:BooleanIf wrap activation
Propertyself.direction:NumberDirection 1 or -1
Propertyself.autoblock:BooleanBlock all auto logic
Propertyself.dragger:NodeDragger node
Propertyself.drag.size:NumberDragger size
Propertyself.drag.sizeContent:NumberContent size

Methods

Call methods by getting self object.

SyntaxDescription
Methodself.getElements(el:Node, same:Boolean = false)Get all elements from element or target, also with same drag activation, returns Array
Methodself.getTargets(el:Node, same:Boolean = false)Get all targets from element or target, also with same drag activation, returns Array
Methodself.getElementsGroups()Get elements (one per group), returns Array
Methodself.hasCurrent({ el:Node, same:Boolean = false })Check if element or target is activated, returns Boolean
Methodself.getIndex({ el:Node })Get activation index of from element or target, returns Number
Methodself.reinit({ save:Boolean = true })Reinit component and save currents as initial (default: true)
Methodself.restart()Restart component to initial
Methodself.disable()Disable component
Methodself.enable()Enable component
Methodself.destroy({ weak:Boolean = false })Destroy component

You can get activated elements or targets with hasCurrent.

self.elements.filter(x => self.hasCurrent({ el: x }))
self.targets.filter(x => self.hasCurrent({ el: x }))

Index methods, they all consider options.loop.

SyntaxDescription
Methodself.getNextIndex({ index:Number|false = false, amount:Number = 1, loop:Boolean|null = null })Get next activation index, returns Number|null
Methodself.getNext({ amount:Number = 1, loop:Boolean|null = null })Get next element, returns Node|null
Methodself.goToNext({ amount:Number = 1, force:Boolean = false, loop:Boolean|null = null })Activate next element, returns Node|null
Methodself.getPrevIndex({ index:Number|false = false, amount:Number = 1, loop:Boolean|null = null })Get prev activation index, returns Number|null
Methodself.getPrev({ amount:Number = 1, loop:Boolean|null = null })Get previous element, returns Node|null
Methodself.goToPrev({ amount:Number = 1, force:Boolean = false, loop:Boolean|null = null })Activate previous element, returns Node|null
Methodself.getNumIndex({ index:Number, loop:Boolean|null = null }Get index from number, return Number|null
Methodself.getNum({ index:Number = 1, loop:Boolean|null = null })Get element from index, returns Node|null
Methodself.goToNum({ index:Number, force:Boolean = false, loop:Boolean|null = null })Activate index, returns Node|null

API Demo