From 87c719c429dd64e97b63bb36395f07f6464af4fb Mon Sep 17 00:00:00 2001 From: LCweb-ita Date: Wed, 12 May 2021 12:25:20 +0200 Subject: [PATCH] v2.0.2 - fixed: swipe navigation on nav dots - added: lcms_first_populated event --- README.md | 7 ++++ lc-micro-slider.js | 78 +++++++++++++++++++++++++----------------- lc-micro-slider.min.js | 50 +++++++++++++-------------- package.json | 2 +- 4 files changed, 79 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 397e28d..caf65ba 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,13 @@ $el.addEventListener('lcms_ready', (e) => { }); +// dispatched whenever very first slide is populated, before preloading +$el.addEventListener('lcms_first_populated', (e) => { + + // e.detail.slide_data - (object) slide data +}); + + // dispatched whenever a new slide is shown (after lazyload) $el.addEventListener('lcms_slide_shown', (e) => { diff --git a/lc-micro-slider.js b/lc-micro-slider.js index 55efacd..6fdcdfb 100644 --- a/lc-micro-slider.js +++ b/lc-micro-slider.js @@ -1,6 +1,6 @@ /** * lc_micro_slider.js - Light and modern vanilla javascript (ES6) contents slider - * Version: 2.0.1 + * Version: 2.0.2 * Author: Luca Montanari aka LCweb * Website: https://lcweb.it * Licensed under the MIT license @@ -87,9 +87,8 @@ style_generated = true; } - maybe_querySelectorAll(attachTo).forEach(function($wrap_obj) { - + // do not initialize twice if(typeof($wrap_obj.lcms_vars) != 'undefined') { return; @@ -145,7 +144,7 @@ // extra nav cmd if(options.extra_cmd_code) { - $slider_wrap.insertAdjacentHTML('afterbegin', extra_cmd_code ); + $slider_wrap.insertAdjacentHTML('afterbegin', options.extra_cmd_code); } @@ -167,6 +166,16 @@ $this.populate_slide($wrap_obj, 'init', 0); + // dispatched whenever very first slide is populated, before preloading | args: slide object + const first_pop_event = new CustomEvent('lcms_first_populated', { + bubbles : true, + detail : { + slide_data : $wrap_obj.lcms_vars.slides[0] + } + }); + $wrap_obj.dispatchEvent(first_pop_event); + + // sliding fx setup if(options.slide_fx && options.slide_fx != 'none') { @@ -246,7 +255,7 @@ // swipe integration for touch? if(options.touchswipe) { const swipe_threshold = 30; - new swiper($slider_wrap, function(directions, $swiped_el) { + new swiper($slider_wrap.querySelector('.lcms_container'), function(directions, $swiped_el) { if(directions.left && directions.left >= swipe_threshold) { lcms_slide($wrap_obj, 'next'); @@ -373,7 +382,6 @@ const $this = this, slide = $wrap_obj.lcms_vars.slides[ slide_index ], - preload_class = (slide.img) ? 'lcms_preload' : '', loader_code = (slide.img) ? options.loader_code : ''; let fx_class; @@ -397,9 +405,8 @@ contents = (slide.content.toString().trim()) ? '
'+ slide.content +'
' : '', slide_code = - '
'+ - '
'+ bg + contents +'
'+ - loader_code + + '
'+ + '
'+ bg + contents +'
'+ '
'; // populate @@ -409,24 +416,29 @@ // preload current element if(slide.img) { if(cached_img.indexOf(slide.img) === -1 ) { + $slide.classList.add('lcms_preload'); + + // show preloader + if(loader_code) { + $slide.insertAdjacentHTML('beforeend', loader_code); + } + + // lazyload image let img = new Image(); img.src = slide.img; img.onload = (e) => { cached_img.push(slide.img); - $slide.classList.remove('lcms_preload'); - $slide.childNodes.forEach(function(el) { - if(el.classList.contains('lcms_inner')) { - return; + + // remove preloader + if(loader_code) { + for(const el of $slide.children) { + if(!el.classList || !el.classList.contains('lcms_inner')) { + el.remove(); + } } - - el.classList.add('lcms_cached'); - - setTimeout(() => { - el.remove(); - }, 300); - }); + } // dispatched whenever a new slide is shown (after lazyload) | args: slide index - slide data object - slide DOM object const ss_event = new CustomEvent('lcms_slide_shown', { @@ -443,16 +455,7 @@ } // image already cached - else { - $slide.classList.remove('lcms_preload'); - - $slide.childNodes.forEach(function(el) { - if(el.classList.contains('lcms_inner')) { - return; - } - el.remove(); - }); - + else { // dispatched whenever a new slide is shown | args: slide index - slide object const ss_event = new CustomEvent('lcms_slide_shown', { bubbles : true, @@ -1142,7 +1145,19 @@ const maybe_querySelectorAll = (selector) => { if(typeof(selector) != 'string') { - return (selector instanceof Element) ? [selector] : Object.values(selector); + if(selector instanceof Element) { // JS or jQuery + return [selector]; + } + else { + let to_return = []; + + for(const obj of selector) { + if(obj instanceof Element) { + to_return.push(obj); + } + } + return to_return; + } } // clean problematic selectors @@ -1233,5 +1248,4 @@ return this; }; - })(); \ No newline at end of file diff --git a/lc-micro-slider.min.js b/lc-micro-slider.min.js index 6d68c95..77ad5d1 100644 --- a/lc-micro-slider.min.js +++ b/lc-micro-slider.min.js @@ -1,32 +1,32 @@ /** * lc_micro_slider.js - Light and modern vanilla javascript (ES6) contents slider - * Version: 2.0.1 + * Version: 2.0.2 * Author: Luca Montanari aka LCweb * Website: https://lcweb.it * Licensed under the MIT license */ -var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.createTemplateTagFirstArg=function(k){return k.raw=k};$jscomp.createTemplateTagFirstArgWithRaw=function(k,l){k.raw=l;return k};$jscomp.arrayIteratorImpl=function(k){var l=0;return function(){return l',addit_classes:[]},z={slides:[],shown_slide:0,uniqid:"",is_sliding:!1,is_playing:!1,paused_on_hover:!1};window.lc_micro_slider=function(h, -e){e=void 0===e?{}:e;if(!h)return console.error("You must provide a valid selector or DOM object as first argument");if("object"!=typeof e)return console.error("Options must be an object");e=Object.assign({},y,e);this.init=function(){var a=this;k||(this.generate_style(),k=!0);r(h).forEach(function(b){if("undefined"==typeof b.lcms_vars){b.lcms_vars=JSON.parse(JSON.stringify(z));var d=b.children[0].children;if(!d.length)return!1;d=$jscomp.makeIterator(d);for(var g=d.next();!g.done;g=d.next())g=g.value, -g.querySelectorAll("noscript").forEach(function(c){c.remove()}),b.lcms_vars.slides.push({type:a.get_slide_type(g),content:g.innerHTML,img:g.hasAttribute("data-img")?g.getAttribute("data-img"):!1,classes:g.hasAttribute("class")?g.getAttribute("class"):""});d=Math.random().toString(36).substr(2,9);b.lcms_vars.uniqid=d;b.innerHTML='
';var f=document.querySelector('.lcms_wrap[data-id="'+d+'"]'); -e.nav_arrows&&1
'));e.slideshow_cmd&&1'));e.extra_cmd_code&&f.insertAdjacentHTML("afterbegin",extra_cmd_code);e.nav_dots&&1'),a.populate_dots(b));g=new Event("lcms_ready",{bubbles:!0});b.dispatchEvent(g);b.lcms_vars.shown_slide=0;a.populate_slide(b,"init",0);e.slide_fx&&"none"!=e.slide_fx&&(document.head.insertAdjacentHTML("beforeend",'"),f.classList.add("lcms_"+e.slide_fx+"_fx"));b.querySelector(".lcms_play")&&b.querySelector(".lcms_play").addEventListener("click",function(c){c=t(c.target,".lcms_wrap").parentNode;b.querySelector(".lcms_play").classList.contains("lcms_pause")? -a.stop(c):a.play(c)});b.querySelector(".lcms_prev")&&b.querySelector(".lcms_prev:not(.lcms_disabled)").addEventListener("click",function(c){c=t(c.target,".lcms_wrap").parentNode;a.slide(c,"prev");b.lcms_vars.paused_on_hover=!1;a.stop(c)});b.querySelector(".lcms_next")&&b.querySelector(".lcms_next:not(.lcms_disabled)").addEventListener("click",function(c){c=t(c.target,".lcms_wrap").parentNode;a.slide(c,"next");a.stop(c)});e.pause_on_hover&&(b.addEventListener("mouseenter",function(c){b.lcms_vars.is_playing&& -(b.lcms_vars.paused_on_hover=!0,a.stop(b,!0))}),b.addEventListener("mouseleave",function(c){b.lcms_vars.paused_on_hover&&(b.lcms_vars.paused_on_hover=!0,a.play(b))}));e.touchswipe&&new A(f,function(c,p){c.left&&30<=c.left?lcms_slide(b,"next"):c.right&&30<=c.right&&lcms_slide(b,"prev")});b.addEventListener("mouseleave",function(c){f.classList.contains("lcms_already_hovered")||f.classList.add("lcms_already_hovered")});b.addEventListener("lcms_slide",function(c){a.stop(b);a.slide(b,c.detail.direction)}); -b.addEventListener("lcms_play",function(){a.play(b)});b.addEventListener("lcms_stop",function(){a.stop(b)});e.autoplay&&a.play(b)}})};this.populate_dots=function(a){for(var b=this,d="",g=0;g'}a.querySelector(".lcms_nav_dots").innerHTML=d;a.querySelectorAll(".lcms_nav_dots span").forEach(function(p){p.addEventListener("click",function(m){if(p.classList.contains("lcms_sel_dot"))return!0; -m=t(p,".lcms_wrap").parentNode;var u=parseInt(p.getAttribute("data-index"),10);b.slide(m,u);a.lcms_vars.paused_on_hover=!1;b.stop(m)})})};this.get_slide_type=function(a){return a.hasAttribute("data-type")?a.getAttribute("data-type"):e.fixed_slide_type?e.fixed_slide_type:a.hasAttribute("data-img")?a.children.length?"mixed":"image":!a.children.length||1':"";var u=f.content.toString().trim()?'
'+f.content+"
":"";c='
'+b+u+"
"+p+"
";a.querySelector(".lcms_container").insertAdjacentHTML("beforeend",c);var n=a.querySelector('.lcms_slide[data-index="'+d+'"]');f.img&&(-1===l.indexOf(f.img)?(c=new Image,c.src=f.img,c.onload=function(q){l.push(f.img);n.classList.remove("lcms_preload");n.childNodes.forEach(function(v){v.classList.contains("lcms_inner")|| -(v.classList.add("lcms_cached"),setTimeout(function(){v.remove()},300))});q=new CustomEvent("lcms_slide_shown",{bubbles:!0,detail:{slide_index:d,slide_data:f,silde_elem:n}});a.dispatchEvent(q)}):(n.classList.remove("lcms_preload"),n.childNodes.forEach(function(q){q.classList.contains("lcms_inner")||q.remove()}),c=new CustomEvent("lcms_slide_shown",{bubbles:!0,detail:{slide_index:d,slide_data:f,silde_elem:n}}),a.dispatchEvent(c)));if(1b||b>a.lcms_vars.slides.length-1))return!1;if("prev"==b)var f=0===g?a.lcms_vars.slides.length-1:g-1;else"next"==b?f=g==a.lcms_vars.slides.length-1?0:g+1:(f=b,b=f>g?"next":"prev");a.lcms_vars.lcms_is_sliding=!0;a.classList.add("lcms_is_sliding", -"lcms_moving_"+b);a.querySelector(".lcms_active_slide").classList.add("lcms_prepare_for_"+b);this.populate_slide(a,"fade"==e.slide_fx?"fade":b,f);a.lcms_vars.shown_slide=f;g=new CustomEvent("lcms_changing_slide",{bubbles:!0,detail:{new_index:f,slide_data:a.lcms_vars.slides[f],curr_index:g}});a.dispatchEvent(g);e.carousel||(a.querySelectorAll(".lcms_prev, .lcms_next, .lcms_play > span").forEach(function(c){c.classList.remove("lcms_disabled_btn")}),f?f==a.lcms_vars.slides.length-1&&a.querySelectorAll(".lcms_next, .lcms_play > span").forEach(function(c){c.classList.all("lcms_disabled_btn")}): -a.querySelectorAll(".lcms_prev").forEach(function(c){c.classList.all("lcms_disabled_btn")}));setTimeout(function(){a.querySelector(".lcms_active_slide").remove();a.lcms_vars.lcms_is_sliding=!1;a.classList.remove("lcms_is_sliding","lcms_moving_"+b);a.querySelector(".lcms_slide").classList.remove("lcms_fadein","lcms_before","lcms_after");a.querySelector(".lcms_slide").classList.add("lcms_active_slide");var c=new CustomEvent("lcms_new_active_slide",{bubbles:!0,detail:{new_index:f,slide_data:a.lcms_vars.slides[f]}}); -a.dispatchEvent(c)},d)};this.play=function(a){var b=this;a.querySelector(".lcms_play")&&a.querySelector(".lcms_play").classList.add("lcms_pause");if(a.lcms_vars.is_playing)return!0;a.classList.add("lcms_is_playing");a.lcms_vars.is_playing=setInterval(function(){b.slide(a,"next")},e.slideshow_time+e.animation_time);var d=new Event("lcms_play_slideshow",{bubbles:!0});a.dispatchEvent(d)};this.stop=function(a,b){b=void 0===b?!1:b;a.querySelector(".lcms_play")&&!b&&a.querySelector(".lcms_play").classList.remove("lcms_pause"); -if(!a.lcms_vars.is_playing)return!0;a.classList.remove("lcms_is_playing");clearInterval(a.lcms_vars.is_playing);a.lcms_vars.is_playing=null;var d=new Event("lcms_stop_slideshow",{bubbles:!0});a.dispatchEvent(d)};this.generate_style=function(){document.head.insertAdjacentHTML("beforeend",'')}; -this.init();return this};window.lcms_play=function(h){r(h).forEach(function(e){var a=new Event("lcms_play");e.dispatchEvent(a)})};window.lcms_stop=function(h){r(h).forEach(function(e){var a=new Event("lcms_stop");e.dispatchEvent(a)})};window.lcms_slide=function(h,e){r(h).forEach(function(a){var b=new CustomEvent("lcms_slide",{detail:{direction:e}});a.dispatchEvent(b)})};var r=function(h){if("string"!=typeof h)return h instanceof Element?[h]:Object.values(h);(h.match(/(#[0-9][^\s:,]*)/g)||[]).forEach(function(e){h= -h.replace(e,'[id="'+e.replace("#","")+'"]')});return document.querySelectorAll(h)},t=function(h,e){for(var a=h;null!=a.parentNode&&!a.matches(e);)a=a.parentNode;return a},A=function(h,e){this.$elements=[];this.uniqid=Math.random().toString(36).substr(2,9);this.init=function(){var a=this;this.$elements=r(h);this.$elements.forEach(function(b){"undefined"==typeof b.lcswiper_cb&&(b.lcswiper_cb={});b.lcswiper_cb[a.uniqid]=e;b.addEventListener("touchstart",function(d){b.lcswiper_xDown=d.touches[0].clientX; -b.lcswiper_yDown=d.touches[0].clientY});b.addEventListener("touchend",function(d){a.handleTouchDiff(b,d)})})};this.handleTouchDiff=function(a,b){if("undefined"!=typeof a.lcswiper_xDown&&a.lcswiper_xDown&&"undefined"!=typeof a.lcswiper_yDown&&a.lcswiper_yDown&&"undefined"!=typeof a.lcswiper_cb[this.uniqid]){var d=b.changedTouches[0].clientY,g=parseInt(a.lcswiper_xDown-b.changedTouches[0].clientX,10);d=parseInt(a.lcswiper_yDown-d,10);0===Math.abs(g)&&0===Math.abs(d)||a.lcswiper_cb[this.uniqid].call(this, -{up:0g?Math.abs(g):0,down:0>d?Math.abs(d):0,left:0',addit_classes:[]},y={slides:[],shown_slide:0,uniqid:"",is_sliding:!1,is_playing:!1,paused_on_hover:!1};window.lc_micro_slider=function(k, +d){d=void 0===d?{}:d;if(!k)return console.error("You must provide a valid selector or DOM object as first argument");if("object"!=typeof d)return console.error("Options must be an object");d=Object.assign({},x,d);this.init=function(){var a=this;l||(this.generate_style(),l=!0);r(k).forEach(function(b){if("undefined"==typeof b.lcms_vars){b.lcms_vars=JSON.parse(JSON.stringify(y));var c=b.children[0].children;if(!c.length)return!1;c=$jscomp.makeIterator(c);for(var f=c.next();!f.done;f=c.next())f=f.value, +f.querySelectorAll("noscript").forEach(function(e){e.remove()}),b.lcms_vars.slides.push({type:a.get_slide_type(f),content:f.innerHTML,img:f.hasAttribute("data-img")?f.getAttribute("data-img"):!1,classes:f.hasAttribute("class")?f.getAttribute("class"):""});c=Math.random().toString(36).substr(2,9);b.lcms_vars.uniqid=c;b.innerHTML='
';var g=document.querySelector('.lcms_wrap[data-id="'+c+'"]'); +d.nav_arrows&&1'));d.slideshow_cmd&&1'));d.extra_cmd_code&&g.insertAdjacentHTML("afterbegin",d.extra_cmd_code);d.nav_dots&&1'),a.populate_dots(b));f=new Event("lcms_ready",{bubbles:!0});b.dispatchEvent(f);b.lcms_vars.shown_slide=0;a.populate_slide(b,"init",0);f=new CustomEvent("lcms_first_populated",{bubbles:!0,detail:{slide_data:b.lcms_vars.slides[0]}});b.dispatchEvent(f);d.slide_fx&&"none"!=d.slide_fx&&(document.head.insertAdjacentHTML("beforeend",'"),g.classList.add("lcms_"+d.slide_fx+"_fx"));b.querySelector(".lcms_play")&&b.querySelector(".lcms_play").addEventListener("click", +function(e){e=u(e.target,".lcms_wrap").parentNode;b.querySelector(".lcms_play").classList.contains("lcms_pause")?a.stop(e):a.play(e)});b.querySelector(".lcms_prev")&&b.querySelector(".lcms_prev:not(.lcms_disabled)").addEventListener("click",function(e){e=u(e.target,".lcms_wrap").parentNode;a.slide(e,"prev");b.lcms_vars.paused_on_hover=!1;a.stop(e)});b.querySelector(".lcms_next")&&b.querySelector(".lcms_next:not(.lcms_disabled)").addEventListener("click",function(e){e=u(e.target,".lcms_wrap").parentNode; +a.slide(e,"next");a.stop(e)});d.pause_on_hover&&(b.addEventListener("mouseenter",function(e){b.lcms_vars.is_playing&&(b.lcms_vars.paused_on_hover=!0,a.stop(b,!0))}),b.addEventListener("mouseleave",function(e){b.lcms_vars.paused_on_hover&&(b.lcms_vars.paused_on_hover=!0,a.play(b))}));d.touchswipe&&new z(g.querySelector(".lcms_container"),function(e,h){e.left&&30<=e.left?lcms_slide(b,"next"):e.right&&30<=e.right&&lcms_slide(b,"prev")});b.addEventListener("mouseleave",function(e){g.classList.contains("lcms_already_hovered")|| +g.classList.add("lcms_already_hovered")});b.addEventListener("lcms_slide",function(e){a.stop(b);a.slide(b,e.detail.direction)});b.addEventListener("lcms_play",function(){a.play(b)});b.addEventListener("lcms_stop",function(){a.stop(b)});d.autoplay&&a.play(b)}})};this.populate_dots=function(a){for(var b=this,c="",f=0;f'}a.querySelector(".lcms_nav_dots").innerHTML= +c;a.querySelectorAll(".lcms_nav_dots span").forEach(function(h){h.addEventListener("click",function(t){if(h.classList.contains("lcms_sel_dot"))return!0;t=u(h,".lcms_wrap").parentNode;var n=parseInt(h.getAttribute("data-index"),10);b.slide(t,n);a.lcms_vars.paused_on_hover=!1;b.stop(t)})})};this.get_slide_type=function(a){return a.hasAttribute("data-type")?a.getAttribute("data-type"):d.fixed_slide_type?d.fixed_slide_type:a.hasAttribute("data-img")?a.children.length?"mixed":"image":!a.children.length|| +1':"";var t=g.content.toString().trim()?'
'+g.content+"
":"";h='
'+b+t+"
";a.querySelector(".lcms_container").insertAdjacentHTML("beforeend",h);var n=a.querySelector('.lcms_slide[data-index="'+c+'"]');g.img&&(-1===m.indexOf(g.img)?(n.classList.add("lcms_preload"),e&&n.insertAdjacentHTML("beforeend", +e),h=new Image,h.src=g.img,h.onload=function(p){m.push(g.img);n.classList.remove("lcms_preload");if(e){p=$jscomp.makeIterator(n.children);for(var q=p.next();!q.done;q=p.next())q=q.value,q.classList&&q.classList.contains("lcms_inner")||q.remove()}p=new CustomEvent("lcms_slide_shown",{bubbles:!0,detail:{slide_index:c,slide_data:g,silde_elem:n}});a.dispatchEvent(p)}):(h=new CustomEvent("lcms_slide_shown",{bubbles:!0,detail:{slide_index:c,slide_data:g,silde_elem:n}}),a.dispatchEvent(h)));if(1b||b>a.lcms_vars.slides.length-1))return!1;if("prev"==b)var g=0===f?a.lcms_vars.slides.length-1:f-1;else"next"==b?g=f==a.lcms_vars.slides.length-1?0:f+1:(g=b,b=g>f?"next":"prev");a.lcms_vars.lcms_is_sliding= +!0;a.classList.add("lcms_is_sliding","lcms_moving_"+b);a.querySelector(".lcms_active_slide").classList.add("lcms_prepare_for_"+b);this.populate_slide(a,"fade"==d.slide_fx?"fade":b,g);a.lcms_vars.shown_slide=g;f=new CustomEvent("lcms_changing_slide",{bubbles:!0,detail:{new_index:g,slide_data:a.lcms_vars.slides[g],curr_index:f}});a.dispatchEvent(f);d.carousel||(a.querySelectorAll(".lcms_prev, .lcms_next, .lcms_play > span").forEach(function(e){e.classList.remove("lcms_disabled_btn")}),g?g==a.lcms_vars.slides.length- +1&&a.querySelectorAll(".lcms_next, .lcms_play > span").forEach(function(e){e.classList.all("lcms_disabled_btn")}):a.querySelectorAll(".lcms_prev").forEach(function(e){e.classList.all("lcms_disabled_btn")}));setTimeout(function(){a.querySelector(".lcms_active_slide").remove();a.lcms_vars.lcms_is_sliding=!1;a.classList.remove("lcms_is_sliding","lcms_moving_"+b);a.querySelector(".lcms_slide").classList.remove("lcms_fadein","lcms_before","lcms_after");a.querySelector(".lcms_slide").classList.add("lcms_active_slide"); +var e=new CustomEvent("lcms_new_active_slide",{bubbles:!0,detail:{new_index:g,slide_data:a.lcms_vars.slides[g]}});a.dispatchEvent(e)},c)};this.play=function(a){var b=this;a.querySelector(".lcms_play")&&a.querySelector(".lcms_play").classList.add("lcms_pause");if(a.lcms_vars.is_playing)return!0;a.classList.add("lcms_is_playing");a.lcms_vars.is_playing=setInterval(function(){b.slide(a,"next")},d.slideshow_time+d.animation_time);var c=new Event("lcms_play_slideshow",{bubbles:!0});a.dispatchEvent(c)}; +this.stop=function(a,b){b=void 0===b?!1:b;a.querySelector(".lcms_play")&&!b&&a.querySelector(".lcms_play").classList.remove("lcms_pause");if(!a.lcms_vars.is_playing)return!0;a.classList.remove("lcms_is_playing");clearInterval(a.lcms_vars.is_playing);a.lcms_vars.is_playing=null;var c=new Event("lcms_stop_slideshow",{bubbles:!0});a.dispatchEvent(c)};this.generate_style=function(){document.head.insertAdjacentHTML("beforeend",'')}; +this.init();return this};window.lcms_play=function(k){r(k).forEach(function(d){var a=new Event("lcms_play");d.dispatchEvent(a)})};window.lcms_stop=function(k){r(k).forEach(function(d){var a=new Event("lcms_stop");d.dispatchEvent(a)})};window.lcms_slide=function(k,d){r(k).forEach(function(a){var b=new CustomEvent("lcms_slide",{detail:{direction:d}});a.dispatchEvent(b)})};var r=function(k){if("string"!=typeof k){if(k instanceof Element)return[k];for(var d=[],a=$jscomp.makeIterator(k),b=a.next();!b.done;b= +a.next())b=b.value,b instanceof Element&&d.push(b);return d}(k.match(/(#[0-9][^\s:,]*)/g)||[]).forEach(function(c){k=k.replace(c,'[id="'+c.replace("#","")+'"]')});return document.querySelectorAll(k)},u=function(k,d){for(var a=k;null!=a.parentNode&&!a.matches(d);)a=a.parentNode;return a},z=function(k,d){this.$elements=[];this.uniqid=Math.random().toString(36).substr(2,9);this.init=function(){var a=this;this.$elements=r(k);this.$elements.forEach(function(b){"undefined"==typeof b.lcswiper_cb&&(b.lcswiper_cb= +{});b.lcswiper_cb[a.uniqid]=d;b.addEventListener("touchstart",function(c){b.lcswiper_xDown=c.touches[0].clientX;b.lcswiper_yDown=c.touches[0].clientY});b.addEventListener("touchend",function(c){a.handleTouchDiff(b,c)})})};this.handleTouchDiff=function(a,b){if("undefined"!=typeof a.lcswiper_xDown&&a.lcswiper_xDown&&"undefined"!=typeof a.lcswiper_yDown&&a.lcswiper_yDown&&"undefined"!=typeof a.lcswiper_cb[this.uniqid]){var c=b.changedTouches[0].clientY,f=parseInt(a.lcswiper_xDown-b.changedTouches[0].clientX, +10);c=parseInt(a.lcswiper_yDown-c,10);0===Math.abs(f)&&0===Math.abs(c)||a.lcswiper_cb[this.uniqid].call(this,{up:0f?Math.abs(f):0,down:0>c?Math.abs(c):0,left:0