-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlc-micro-slider.min.js
9 lines (8 loc) · 19.1 KB
/
lc-micro-slider.min.js
1
2
3
4
5
6
7
8
9
/**
* lc_micro_slider.js - Light and modern vanilla javascript (ES6) contents slider
* Version: 2.1.2
* Author: Luca Montanari (LCweb)
* Website: https://lcweb.it
* Licensed under the MIT license
*/
!function(){"use strict";if(void 0!==window.lc_micro_slider)return!1;let n=null,t=[];const e={slide_fx:"fadeslide",slide_easing:"ease",nav_arrows:!0,nav_dots:!1,slideshow_cmd:!0,carousel:!0,touchswipe:!0,autoplay:!1,animation_time:700,slideshow_time:5e3,pause_on_hover:!0,pause_on_video_play:!1,extra_cmd_code:"",fixed_slide_type:"",loader_code:'<span class="lcms_loader"></span>',addit_classes:[]},s={slides:[],shown_slide:0,uniqid:"",is_sliding:!1,is_playing:!1,paused_on_hover:!1};window.lc_micro_slider=function(c,o={}){return c?"object"!=typeof o?console.error("Options must be an object"):(o=Object.assign({},e,o),this.init=function(){const t=this;n||(this.generate_style(),n=!0),l(c).forEach((function(n){if(void 0!==n.lcms_vars)return;n.lcms_vars=JSON.parse(JSON.stringify(s));const e=n.children[0].children;if(!e.length)return!1;for(const s of e){s.querySelectorAll("noscript").forEach((function(n){n.remove()}));let e=!1,l=!1;s.hasAttribute("data-srcset")?(e=s.getAttribute("data-srcset"),l=!0):s.hasAttribute("data-img")&&(e=s.getAttribute("data-img")),n.lcms_vars.slides.push({type:t.get_slide_type(s),content:s.innerHTML,img:e,using_srcset:l,classes:s.hasAttribute("class")?s.getAttribute("class"):""})}const l=Math.random().toString(36).substr(2,9);n.lcms_vars.uniqid=l,n.innerHTML='<div class="lcms_wrap '+o.addit_classes.join(" ")+'" data-id="'+l+'"><div class="lcms_container"></div></div>';const c=document.querySelector('.lcms_wrap[data-id="'+l+'"]');if(o.nav_arrows&&n.lcms_vars.slides.length>1){const n=o.carousel?"":"lcms_disabled_btn";c.classList.add("lcms_has_nav_arr"),c.insertAdjacentHTML("afterbegin",'<div class="lcms_nav"><span class="lcms_prev '+n+'"></span><span class="lcms_next"></span></div>')}o.slideshow_cmd&&n.lcms_vars.slides.length>1&&(c.classList.add("lcms_has_ss_cmd"),c.insertAdjacentHTML("afterbegin",'<div class="lcms_play"><span></span></div>')),o.extra_cmd_code&&c.insertAdjacentHTML("afterbegin",o.extra_cmd_code),o.nav_dots&&n.lcms_vars.slides.length>1&&(c.classList.add("lcms_has_nav_dots"),c.insertAdjacentHTML("afterbegin",'<div class="lcms_nav_dots"></div>'),t.populate_dots(n));const _=new Event("lcms_ready",{bubbles:!0});n.dispatchEvent(_),n.lcms_vars.shown_slide=0,t.populate_slide(n,"init",0);const m=new CustomEvent("lcms_first_populated",{bubbles:!0,detail:{slide_data:n.lcms_vars.slides[0]}});if(n.dispatchEvent(m),o.slide_fx&&"none"!=o.slide_fx){const n=o.slide_easing&&"ease"!=o.slide_easing?"animation-timing-function: "+o.slide_easing+" !important;":"";document.head.insertAdjacentHTML("beforeend",`<style>\n .lcms_wrap[data-id="${l}"] .lcms_before, \n .lcms_wrap[data-id="${l}"] .lcms_after, \n .lcms_wrap[data-id="${l}"] .lcms_prepare_for_prev,\n .lcms_wrap[data-id="${l}"] .lcms_prepare_for_next {\n animation-duration: ${o.animation_time}ms !important;\n ${n}\n }</style>`),c.classList.add("lcms_"+o.slide_fx+"_fx")}if(n.querySelector(".lcms_play")&&n.querySelector(".lcms_play").addEventListener("click",(e=>{const s=i(e.target,".lcms_wrap").parentNode;n.querySelector(".lcms_play").classList.contains("lcms_pause")?t.stop(s):t.play(s)})),n.querySelector(".lcms_prev")&&n.querySelector(".lcms_prev:not(.lcms_disabled)").addEventListener("click",(e=>{const s=i(e.target,".lcms_wrap").parentNode;t.slide(s,"prev"),n.lcms_vars.paused_on_hover=!1,t.stop(s)})),n.querySelector(".lcms_next")&&n.querySelector(".lcms_next:not(.lcms_disabled)").addEventListener("click",(n=>{const e=i(n.target,".lcms_wrap").parentNode;t.slide(e,"next"),t.stop(e)})),o.pause_on_hover&&(n.addEventListener("mouseenter",(e=>{n.lcms_vars.is_playing&&(n.lcms_vars.paused_on_hover=!0,t.stop(n,!0))})),n.addEventListener("mouseleave",(e=>{n.lcms_vars.paused_on_hover&&(n.lcms_vars.paused_on_hover=!0,t.play(n))}))),o.touchswipe){const t=30;new a(c.querySelector(".lcms_container"),(function(e,s){e.left&&e.left>=t?lcms_slide(n,"next"):e.right&&e.right>=t&&lcms_slide(n,"prev")}))}n.addEventListener("mouseleave",(n=>{c.classList.contains("lcms_already_hovered")||c.classList.add("lcms_already_hovered")})),n.addEventListener("lcms_slide",(e=>{t.stop(n),t.slide(n,e.detail.direction)})),n.addEventListener("lcms_play",(()=>{t.play(n)})),n.addEventListener("lcms_stop",(()=>{t.stop(n)})),o.autoplay&&t.play(n)}))},this.populate_dots=function(n){const t=this;let e="";for(let t=0;t<n.lcms_vars.slides.length;t++){const s=t?"":"lcms_sel_dot";let l=n.lcms_vars.slides[t].img;l||(l=""),e+='<span class="'+s+'" data-index="'+t+'" data-image="'+l+'"></span>'}n.querySelector(".lcms_nav_dots").innerHTML=e,n.querySelectorAll(".lcms_nav_dots span").forEach((function(e){e.addEventListener("click",(s=>{if(e.classList.contains("lcms_sel_dot"))return!0;const l=i(e,".lcms_wrap").parentNode,a=parseInt(e.getAttribute("data-index"),10);t.slide(l,a),n.lcms_vars.paused_on_hover=!1,t.stop(l)}))}))},this.get_slide_type=function(n){return n.hasAttribute("data-type")?n.getAttribute("data-type"):o.fixed_slide_type?o.fixed_slide_type:n.hasAttribute("data-img")||n.hasAttribute("data-srcset")?n.children.length?"mixed":"image":!n.children.length||n.children.length>1?"mixed":"IFRAME"==n.children[0].nodeName?"iframe":"VIDEO"==n.children[0].nodeName?"video":"mixed"},this.load_img=function(n){new Promise((n=>{const t=new Image;t.onload=()=>n({url:url,ratio:t.naturalWidth/t.naturalHeight}),t.src=url}))},this.lazyload_img=async function(n){if(!n.img)return!0;const e=new Image;if(n.using_srcset){const t=n=>new Promise((t=>setTimeout(t,n)));let s,l=document.createElement("IMG");l.srcset=n.img;for(let n=0;n<500&&(await t(20),s=l.currentSrc,!s);n++);if(!s)return console.error("LC micro slider - cannot find srcset image url for "+n.img),!1;e.src=s,l=null}else e.src=n.img;var s;await(s=e,new Promise((n=>{s.onload=()=>n()}))),t.push(n.img)},this.populate_slide=async function(n,e,s){const l=this,i=n.lcms_vars.slides[s],a=i.img?o.loader_code:"";let c;switch(e){case"init":c="lcms_active_slide";break;case"fade":c="lcms_fadein";break;case"prev":c="lcms_before";break;case"next":c="lcms_after"}n.querySelector(".lcms_has_nav_dots")&&(n.querySelector(".lcms_nav_dots .lcms_sel_dot").classList.remove("lcms_sel_dot"),n.querySelectorAll(".lcms_nav_dots span")[s].classList.add("lcms_sel_dot"));const _=i.img?`<div class="lcms_bg"><img srcset="${i.img}" /></div>`:"",m=i.content.toString().trim()?'<div class="lcms_content">'+i.content+"</div>":"",r='<div class="lcms_slide '+c+'" data-index="'+s+'" data-type="'+i.type+'"><div class="lcms_inner '+i.classes+'">'+_+m+"</div></div>";n.querySelector(".lcms_container").insertAdjacentHTML("beforeend",r);const d=n.querySelector('.lcms_slide[data-index="'+s+'"]');if(i.img){if(-1!==t.indexOf(i.img))d.classList.add("lcms_cached");else if(d.classList.add("lcms_preload"),a&&d.insertAdjacentHTML("beforeend",a),await l.lazyload_img(i),d.classList.remove("lcms_preload"),a)for(const n of d.children)n.classList&&n.classList.contains("lcms_inner")||n.remove();const e=new CustomEvent("lcms_slide_shown",{bubbles:!0,detail:{slide_index:s,slide_data:i,silde_elem:d}});n.dispatchEvent(e)}if(n.lcms_vars.slides.length>1){const t=s<n.lcms_vars.slides.length-1?s+1:0;l.lazyload_img(n.lcms_vars.slides[t])}if(n.lcms_vars.slides.length>2){const t=s?s-1:n.lcms_vars.slides.length-1;l.lazyload_img(n.lcms_vars.slides[t])}o.pause_on_video_play&&"video"==i.type&&d.querySelector("video")&&d.querySelector("video").addEventListener("play",(()=>{l.stop(n)}))},this.slide=function(n,t){const e=n.lcms_vars.shown_slide;if("prev"!=t&&"next"!=t&&"number"!=typeof t)return!1;if(!o.carousel&&("prev"==t&&!n.lcms_vars.shown_slide||"next"==t&&n.lcms_vars.shown_slide==n.lcms_vars.slides.length-1))return!1;if(n.lcms_vars.lcms_is_sliding||1==n.lcms_vars.slides.length)return!1;if("number"==typeof t&&(t<0||t>n.lcms_vars.slides.length-1))return!1;let s;"prev"==t?s=0===e?n.lcms_vars.slides.length-1:e-1:"next"==t?s=e==n.lcms_vars.slides.length-1?0:e+1:(s=t,t=s>e?"next":"prev"),n.lcms_vars.lcms_is_sliding=!0,n.classList.add("lcms_is_sliding","lcms_moving_"+t),n.querySelector(".lcms_active_slide").classList.add("lcms_prepare_for_"+t);const l="fade"==o.slide_fx?"fade":t;this.populate_slide(n,l,s),n.lcms_vars.shown_slide=s;const i=new CustomEvent("lcms_changing_slide",{bubbles:!0,detail:{new_index:s,slide_data:n.lcms_vars.slides[s],curr_index:e}});n.dispatchEvent(i),o.carousel||(n.querySelectorAll(".lcms_prev, .lcms_next, .lcms_play > span").forEach((function(n){n.classList.remove("lcms_disabled_btn")})),s?s==n.lcms_vars.slides.length-1&&n.querySelectorAll(".lcms_next, .lcms_play > span").forEach((function(n){n.classList.all("lcms_disabled_btn")})):n.querySelectorAll(".lcms_prev").forEach((function(n){n.classList.all("lcms_disabled_btn")}))),setTimeout((()=>{n.querySelector(".lcms_active_slide").remove(),n.lcms_vars.lcms_is_sliding=!1,n.classList.remove("lcms_is_sliding","lcms_moving_"+t),n.querySelector(".lcms_slide").classList.remove("lcms_fadein","lcms_before","lcms_after"),n.querySelector(".lcms_slide").classList.add("lcms_active_slide");const e=new CustomEvent("lcms_new_active_slide",{bubbles:!0,detail:{new_index:s,slide_data:n.lcms_vars.slides[s]}});n.dispatchEvent(e)}),o.animation_time)},this.play=function(n){const t=this;if(n.querySelector(".lcms_play")&&n.querySelector(".lcms_play").classList.add("lcms_pause"),n.lcms_vars.is_playing)return!0;n.classList.add("lcms_is_playing"),n.lcms_vars.is_playing=setInterval((()=>{t.slide(n,"next")}),o.slideshow_time+o.animation_time);const e=new Event("lcms_play_slideshow",{bubbles:!0});n.dispatchEvent(e)},this.stop=function(n,t=!1){if(n.querySelector(".lcms_play")&&!t&&n.querySelector(".lcms_play").classList.remove("lcms_pause"),!n.lcms_vars.is_playing)return!0;n.classList.remove("lcms_is_playing"),clearInterval(n.lcms_vars.is_playing),n.lcms_vars.is_playing=null;const e=new Event("lcms_stop_slideshow",{bubbles:!0});n.dispatchEvent(e)},this.generate_style=function(){document.head.insertAdjacentHTML("beforeend",'<style>\n/* MANDATORY STYLES */\n.lcms_wrap, \n.lcms_wrap *,\n.lcms_wrap *:before,\n.lcms_wrap *:after {\n box-sizing: border-box;\n}\n.lcms_wrap,\n.lcms_container {\n\twidth: 100%;\n\theight: 100%;\t\n}\n.lcms_wrap {\n\tposition: relative;\n\toverflow: visible;\t\n}\n.lcms_container {\n\tposition: absolute;\n\tz-index: 20;\n\toverflow: hidden !important;\n}\n.lcms_slide {\n\tposition: absolute;\t\n\twidth: 100%;\n\theight: 100%;\t\n\tz-index: 100;\n\ttop: 0%;\n\tleft: 0%;\n transform-style: preserve-3d;\n}\n.lcms_inner {\n\twidth: 100%;\n\theight: 100%;\n\topacity: 1;\n\toverflow: hidden;\n\ttransition: opacity .3s ease-in;\n}\n.lcms_preload .lcms_inner {\n\topacity: 0;\t\n}\n.lcms_cached {\n\ttransition: none !important;\t\n}\n.lcms_slide.lcms_fadein {\n\tz-index: 90;\t\n}\n.lcms_bg,\n.lcms_content {\n\tposition: absolute;\t\n}\n.lcms_bg {\n\ttop: 0;\n\tleft: 0;\n\tright: 0;\n\tbottom: 0;\n\tz-index: 10;\n}\n.lcms_bg img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n.lcms_content {\n\tz-index: 20;\n}\n\n\n/* nav and buttons */\n.lcms_nav,\n.lcms_play,\n.lcms_nav_dots {\n\tposition: absolute;\n\tz-index: 999;\t\n}\n.lcms_play {\n\tz-index: 998;\t\n}\n.lcms_wrap.lcms_has_nav_dots {\n max-height: calc(100% - 40px);\n\tmargin-bottom: 40px;\n}\n.lcms_nav_dots {\n\tz-index: 997;\n\tright: 0px;\t\n\tleft: 0;\n\tbottom: -35px;\n\ttext-align: center;\n}\n.lcms_disabled_btn,\n.lcms_sel_dot {\n\tcursor: default !important;\t\n}\n.lcms_moving_next .lcms_slide_fx .lcms_active_slide,\n.lcms_moving_next .lcms_slide_fx .lcms_after,\n.lcms_moving_prev .lcms_slide_fx .lcms_active_slide,\n.lcms_moving_prev .lcms_slide_fx .lcms_before {\n animation: lcms_foo .7s forwards ease;\n}\n\n\n/* slide type rules */\n.lcms_slide[data-type="iframe"] .lcms_content,\n.lcms_slide[data-type="video"] .lcms_content,\n.lcms_slide[data-type="iframe"] .lcms_content > *,\n.lcms_slide[data-type="video"] .lcms_content > * {\n height: 100%;\n width: 100%;\n border: 0;\n padding: 0;\n margin: 0;\n}\n.lcms_slide[data-type="mixed"] .lcms_content {\n height: 100%;\n width: 100%;\n}\n\n\n\n/*** ENTRANCE/EXIT EFFECTS ***/\n\n/* fade */\n.lcms_is_sliding .lcms_fade_fx .lcms_active_slide {\n\tanimation-name: lcms_fade;\n}\n@keyframes lcms_fade {\n from {opacity; 1}\n to {opacity: 0;}\n}\n\n\n\n/* slide */\n.lcms_moving_prev .lcms_slide_fx .lcms_before {\n\tanimation-name: lcms_slide_new_p;\t\n}\n@keyframes lcms_slide_new_p {\n\tfrom {left: -100%;}\n\tto {left: 0;}\n}\n\n\n.lcms_moving_prev .lcms_slide_fx .lcms_active_slide {\n\tanimation-name: lcms_slide_p;\t\n}\n@keyframes lcms_slide_p {\n\tfrom {left: 0;}\n\tto {left: 100%;}\n}\n\n\n.lcms_moving_next .lcms_slide_fx .lcms_after {\n\tanimation-name: lcms_slide_new_n;\t\n}\n@keyframes lcms_slide_new_n {\n\tfrom {left: 100%;}\n\tto {left: 0;}\n}\n\n\n.lcms_moving_next .lcms_slide_fx .lcms_active_slide {\n\tanimation-name: lcms_slide_n;\t\n}\n@keyframes lcms_slide_n {\n\tfrom {left: 0;}\n\tto {left: -100%;}\n}\n\n\n\n/* vertical slide */\n.lcms_moving_prev .lcms_v_slide_fx .lcms_before {\n\tanimation-name: lcms_v_slide_new_p;\t\n}\n@keyframes lcms_v_slide_new_p {\n\tfrom {top: -100%;}\n\tto {top: 0;}\n}\n\n\n.lcms_moving_prev .lcms_v_slide_fx .lcms_active_slide {\n\tanimation-name: lcms_v_slide_p;\t\n}\n@keyframes lcms_v_slide_p {\n\tfrom {top: 0;}\n\tto {top: 100%;}\n}\n\n\n.lcms_moving_next .lcms_v_slide_fx .lcms_after {\n\tanimation-name: lcms_v_slide_new_n;\t\n}\n@keyframes lcms_v_slide_new_n {\n\tfrom {top: 100%;}\n\tto {top: 0;}\n}\n\n\n.lcms_moving_next .lcms_v_slide_fx .lcms_active_slide {\n\tanimation-name: lcms_v_slide_n;\t\n}\n@keyframes lcms_v_slide_n {\n\tfrom {top: 0;}\n\tto {top: -100%;}\n}\n\n\n\n/* overlap */\n.lcms_moving_prev .lcms_overlap_fx .lcms_before {\n\tanimation-name: lcms_overlap_p;\t\n}\n@keyframes lcms_overlap_p {\n\tfrom {left: -100%;}\n\tto {left: 0;}\n}\n\n\n.lcms_moving_next .lcms_overlap_fx .lcms_after {\n\tanimation-name: lcms_overlap_n;\t\n}\n@keyframes lcms_overlap_n {\n\tfrom {left: 100%;}\n\tto {left: 0;}\n}\n\n\n\n/* vertical overlap */\n.lcms_moving_prev .lcms_v_overlap_fx .lcms_before {\n\tanimation-name: lcms_v_overlap_p;\t\n}\n@keyframes lcms_v_overlap_p {\n\tfrom {top: -100%;}\n\tto {top: 0;}\n}\n\n\n.lcms_moving_next .lcms_v_overlap_fx .lcms_after {\n\tanimation-name: lcms_v_overlap_n;\t\n}\n@keyframes lcms_v_overlap_n {\n\tfrom {top: 100%;}\n\tto {top: 0;}\n}\n\n\n\n/* fadeslide */\n.lcms_moving_prev .lcms_fadeslide_fx .lcms_before {\n\tanimation-name: lcms_fadeslide_new_p;\t\n}\n@keyframes lcms_fadeslide_new_p {\n\tfrom {\n\t\topacity: 0;\n\t\tleft: -100%;\n\t}\n\tto {\n\t\topacity: 1;\n\t\tleft: 0;\n\t}\n}\n\n\n.lcms_moving_prev .lcms_fadeslide_fx .lcms_active_slide {\n\tanimation-name: lcms_fadeslide_p;\t\n}\n@keyframes lcms_fadeslide_p {\n\tfrom {\n\t\topacity: 1;\n\t\tleft: 0;\n\t}\n\tto {\n\t\topacity: 0;\n\t\tleft: 100%;\n\t}\n}\n\n\n.lcms_moving_next .lcms_fadeslide_fx .lcms_after {\n\tanimation-name: lcms_fadeslide_new_n;\t\n}\n@keyframes lcms_fadeslide_new_n {\n\tfrom {\n\t\topacity: 0;\n\t\tleft: 100%;\n\t}\n\tto {\n\t\topacity: 1;\n\t\tleft: 0;\n\t}\n}\n\n\n.lcms_moving_next .lcms_fadeslide_fx .lcms_active_slide {\n\tanimation-name: lcms_fadeslide_n;\t\n}\n@keyframes lcms_fadeslide_n {\n\tfrom {\n\t\topacity: 1;\n\t\tleft: 0;\n\t}\n\tto {\n\t\topacity: 0;\n\t\tleft: -100%;\n\t}\n}\n\n\n\n/* zoom-in */\n.lcms_moving_prev .lcms_zoom-in_fx .lcms_before {\n\tanimation-name: lcms_zoom-in_new_p;\t\n}\n@keyframes lcms_zoom-in_new_p {\n\tfrom {\n\t\topacity: 0;\n\t\ttransform: scale(1.5);\n\t}\n\tto {\n\t\topacity: 1;\n\t\ttransform: scale(1);\n\t}\n}\n\n\n.lcms_moving_prev .lcms_zoom-in_fx .lcms_active_slide {\n\tanimation-name: lcms_zoom-in_p;\t\n}\n@keyframes lcms_zoom-in_p {\n\tfrom {\n\t\topacity: 1;\n\t\ttransform: scale(1);\n\t}\n\tto {\n\t\topacity: 0;\n\t\ttransform: scale(.5);\n\t}\n}\n\n\n.lcms_moving_next .lcms_zoom-in_fx .lcms_after {\n\tanimation-name: lcms_zoom-in_new_n;\t\n}\n@keyframes lcms_zoom-in_new_n {\n\tfrom {\n\t\topacity: 0;\n\t\ttransform: scale(.5);\n\t}\n\tto {\n\t\topacity: 1;\n\t\ttransform: scale(1);\n\t}\n}\n\n\n.lcms_moving_next .lcms_zoom-in_fx .lcms_active_slide {\n\tanimation-name: lcms_zoom-in_n;\t\n}\n@keyframes lcms_zoom-in_n {\n\tfrom {\n\t\topacity: 1;\n\t\ttransform: scale(1);\n\t}\n\tto {\n\t\topacity: 0;\n\t\ttransform: scale(1.5);\n\t}\n}\n\n\n\n/* zoom-out */\n.lcms_moving_prev .lcms_zoom-out_fx .lcms_before {\n\tanimation-name: lcms_zoom-out_new_p;\t\n}\n@keyframes lcms_zoom-out_new_p {\n\tfrom {\n\t\topacity: 0;\n\t\ttransform: scale(.5);\n\t}\n\tto {\n\t\topacity: 1;\n\t\ttransform: scale(1);\n\t}\n}\n\n\n.lcms_moving_prev .lcms_zoom-out_fx .lcms_active_slide {\n\tanimation-name: lcms_zoom-out_p;\t\n}\n@keyframes lcms_zoom-out_p {\n\tfrom {\n\t\topacity: 1;\n\t\ttransform: scale(1);\n\t}\n\tto {\n\t\topacity: 0;\n\t\ttransform: scale(1.5);\n\t}\n}\n\n\n.lcms_moving_next .lcms_zoom-out_fx .lcms_after {\n\tanimation-name: lcms_zoom-out_new_n;\t\n}\n@keyframes lcms_zoom-out_new_n {\n\tfrom {\n\t\topacity: 0;\n\t\ttransform: scale(1.5);\n\t}\n\tto {\n\t\topacity: 1;\n\t\ttransform: scale(1);\n\t}\n}\n\n\n.lcms_moving_next .lcms_zoom-out_fx .lcms_active_slide {\n\tanimation-name: lcms_zoom-out_n;\t\n}\n@keyframes lcms_zoom-out_n {\n\tfrom {\n\t\topacity: 1;\n\t\ttransform: scale(1);\n\t}\n\tto {\n\t\topacity: 0;\n\t\ttransform: scale(.5);\n\t}\n}\n</style>')},this.init(),this):console.error("You must provide a valid selector or DOM object as first argument")},window.lcms_play=function(n){l(n).forEach((function(n){const t=new Event("lcms_play");n.dispatchEvent(t)}))},window.lcms_stop=function(n){l(n).forEach((function(n){const t=new Event("lcms_stop");n.dispatchEvent(t)}))},window.lcms_slide=function(n,t){l(n).forEach((function(n){const e=new CustomEvent("lcms_slide",{detail:{direction:t}});n.dispatchEvent(e)}))};const l=n=>{if("string"!=typeof n){if(n instanceof Element)return[n];{let t=[];for(const e of n)e instanceof Element&&t.push(e);return t}}return(n.match(/(#[0-9][^\s:,]*)/g)||[]).forEach((function(t){n=n.replace(t,'[id="'+t.replace("#","")+'"]')})),document.querySelectorAll(n)},i=(n,t)=>{let e=n;for(;null!=e.parentNode&&!e.matches(t);)e=e.parentNode;return e},a=function(n,t){return this.$elements=[],this.uniqid=Math.random().toString(36).substr(2,9),this.init=function(){const e=this;this.$elements=l(n),this.$elements.forEach((function(n){void 0===n.lcswiper_cb&&(n.lcswiper_cb={}),n.lcswiper_cb[e.uniqid]=t,n.addEventListener("touchstart",(t=>{n.lcswiper_xDown=t.touches[0].clientX,n.lcswiper_yDown=t.touches[0].clientY})),n.addEventListener("touchend",(t=>{e.handleTouchDiff(n,t)}))}))},this.handleTouchDiff=function(n,t){if(void 0===n.lcswiper_xDown||!n.lcswiper_xDown||void 0===n.lcswiper_yDown||!n.lcswiper_yDown||void 0===n.lcswiper_cb[this.uniqid])return;const e=t.changedTouches[0].clientX,s=t.changedTouches[0].clientY,l=parseInt(n.lcswiper_xDown-e,10),i=parseInt(n.lcswiper_yDown-s,10);if(0!==Math.abs(l)||0!==Math.abs(i)){const t={up:i>0?i:0,right:l<0?Math.abs(l):0,down:i<0?Math.abs(i):0,left:l>0?l:0};n.lcswiper_cb[this.uniqid].call(this,t,n)}n.lcswiper_xDown=0,n.lcswiper_yDown=0},this.init(),this}}();