API
NewsTicker
Parameters
elementHTMLElement DOM element for component instantiation and scopeoptionsObject (optional, default{})options.prevSelectorString Selector for prev element (optional, default'[data-ecl-news-ticker-prev]')options.nextSelectorString Selector for next element (optional, default'[data-ecl-news-ticker-next]')options.contentClassString Selector for the content container (optional, default'.ecl-news-ticker__content')options.slidesClassString Selector for the slides container (optional, default'.ecl-news-ticker__slides')options.slideClassString Selector for the slide items (optional, default'.ecl-news-ticker__slide')options.currentSlideClassString Selector for the counter current slide number (optional, default'.ecl-news-ticker__counter--current')options.toggleSelectorString Selector for toggling elementoptions.playSelector(optional, default'[data-ecl-news-ticker-play]')options.pauseSelector(optional, default'[data-ecl-news-ticker-pause]')options.containerClass(optional, default'.ecl-news-ticker__container')options.controlsClass(optional, default'.ecl-news-ticker__controls')options.attachClickListener(optional, defaulttrue)options.attachResizeListener(optional, defaulttrue)
init
Initialise component.
destroy
Destroy component.
shiftSlide
Action to shift next or previous slide.
Parameters
dirintstopAutoPlayBoolean
moveSlides
Transition for the slides.
Parameters
transitionBoolean
checkIndex
Action to update slides index and position.
handleAutoPlay
Toggles play/pause slides.
handleMouseOver
Trigger events on mouseover.
handleMouseOut
Trigger events on mouseout.
handleResize
Trigger events on resize.
handleFocus
Trigger events on focus.
Parameters
eEvent
autoInit
Parameters
rootHTMLElement DOM element for component instantiation and scope$1Object (optional, default{})$1.NEWS_TICKER(optional, default{})
Returns NewsTicker An instance of News ticker.
Setup
There are 2 ways to initialise the component.
Automatic
Add data-ecl-auto-init="NewsTicker" attribute to component's markup:
<div
class="ecl-news-ticker"
data-ecl-news-ticker
data-ecl-auto-init="NewsTicker"
>
...
</div>
Use the ECL library's autoInit() (ECL.autoInit()) when your page is ready or other custom event you want to hook onto.
Manual
Get target element, create an instance and invoke init().
Given you have 1 element with an attribute data-ecl-news-ticker on the page:
var elt = document.querySelector('[data-ecl-news-ticker]');
var newsTicker = new ECL.NewsTicker(elt);
newsTicker.init();
Retrieve an existing instance
If an existing instance needs to be updated, it can be retrieved this way:
var elt = document.querySelector('[data-ecl-news-ticker]');
var instance = ECL.components.get(elt);
To update an existing instance, you can run destroy() and init() on this instance, like this:
instance.destroy();
instance.init();