/* * floatingCarousel 4.0.1 * Copyright (c) 2017 Adam Lafene * * Licensed under the terms of the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html */ (function(q,A){"function"===typeof define&&define.amd?define([],A(q)):"object"===typeof exports?module.exports=A(q):q.floatingCarousel=A(q)})("undefined"!==typeof global?global:this.window||this.global,function(q){var A=!!document.querySelector&&!!q.addEventListener,H=window.jQuery,v,W={autoScroll:!1,autoScrollDirection:"left",autoScrollSpeed:1E4,initClass:"floatingCarouselContainer",intervalRate:16,looped:!0,scrollerAlignment:"horizontal",scrollerOffset:0,scrollSpeed:"medium",beforeCreateFunction:null, afterCreateFunction:null,enableTouchEvents:!0,touchOverflowHidden:!0,reverseOnTouch:!0},r=function(c,l,f){if("[object Object]"===Object.prototype.toString.call(c))for(var a in c)Object.prototype.hasOwnProperty.call(c,a)&&l.call(f,c[a],a,c);else{a=0;for(var X=c.length;au:du},K=function(){0!=b.looped&&(p&&(clearInterval(p),p=0),e=e?e:"vertical"!=b.scrollerAlignment.toLowerCase()?parseInt(d[0].style.left):parseInt(d[0].style.top), b.autoScrollSpeed=1E3>b.autoScrollSpeed?1E3:b.autoScrollSpeed,b.autoScrollSpeed/zh?(e=0,k=0==k?1:0):e+=n;break;default:e-n<-(h-m)?(e=m,k=0==k?1:0):e-=n}"vertical"!=b.scrollerAlignment.toLowerCase()?(d[k].style.left=e+"px",d[0==k?1:0].style.left=e-h+"px"):(d[k].style.top=e+"px",d[0==k?1:0].style.top=e-h+"px")},z))},O=function(){p&& (clearInterval(p),p=0);u="vertical"!=b.scrollerAlignment.toLowerCase()?Math.round(N(g).left+g.offsetWidth/2):Math.round(N(g).top+g.offsetHeight/2);e=e?e:"vertical"!=b.scrollerAlignment.toLowerCase()?parseInt(d[0].style.left):parseInt(d[0].style.top);v=setInterval(function(){try{var a="vertical"!=b.scrollerAlignment.toLowerCase()?B.x:B.y}catch(Z){return}var c=m/2;var f=ah?(e=0,k=0==k?1:0):e+=n:G("right",a)&&(e-n<-(h-m)?0==b.looped?e=-(h-m):(e=m,k=0==k?1:0):e-=n);"vertical"!=b.scrollerAlignment.toLowerCase()?(d[k].style.left=e+"px",d[0==k?1:0].style.left=e-h+"px"):(d[k].style.top=e+"px",d[0==k?1:0].style.top=e-h+"px")},z)},L=function(a){if(v&&(clearInterval(v),v=0,a&&0!=b.looped&&1!=b.autoScroll&&1h&&(e-=h,k=0==k?1:0):e-a<-(h-m)&&(e+= h,k=0==k?1:0);e=G("left",c)?e+a:e-a;"vertical"!=b.scrollerAlignment.toLowerCase()?(t(d,{transition:"left 300ms ease-out"}),setTimeout(function(){d[k].style.left=e+"px";d[0==k?1:0].style.left=e-h+"px"},50)):(t(d,{transition:"top 300ms ease-out"}),setTimeout(function(){d[k].style.top=e+"px";d[0==k?1:0].style.top=e-h+"px"},50));setTimeout(function(){t(d,{transition:""})},350)}},P=function(a){var b={x:0,y:0};if(a.changedTouches)a=a.changedTouches[0],b.x=a.pageX,b.y=a.pageY;else if(a.pageX||a.pageY)b.x= a.pageX,b.y=a.pageY;else{var c=document.documentElement,d=document.body;b.x=a.clientX+((c.scrollLeft||d.scrollLeft)-(c.clientLeft||0));b.y=a.clientY+((c.scrollTop||d.scrollTop)-(c.clientTop||0))}B=b},Q=function(){y=!0;b.touchOverflowHidden&&(document.body.style.overflow="hidden");O()},R=function(){b.touchOverflowHidden&&(document.body.style.overflow="");L(!0);1==b.autoScroll&&K()},S=function(a){P(a)},T=function(){y||O()},U=function(){y||(L(!0),1==b.autoScroll&&K())},V=function(a){y||P(a)};f.destroy= function(){b&&(f.pause(),1a.length)return!1;g=a;if(A){b=Y(W,c||{});null!= b.beforeCreateFunction&&"function"===typeof b.beforeCreateFunction&&b.beforeCreateFunction.call(a);a.classList.add(b.initClass);z=b.intervalRate;g.style.paddingLeft="0";g.style.paddingRight="0";m=g.offsetWidth;switch(a.children[0].nodeName.toLowerCase()){case "div":g.innerHTML="
"+g.innerHTML+"
";g.innerHTML+=g.innerHTML;d=D(a,"div");C=D(d[0],"div");break;case "ul":g.innerHTML+=g.innerHTML;d=a.querySelectorAll("ul");C=D(d[0],"li");break;case "ol":g.innerHTML+=g.innerHTML;d=a.querySelectorAll("ol"); C=D(d[0],"li");break;default:return console.log("unable to initialise scroller - please ensure contents are either in a UL, an OL or in DIVs"),!1}t(C,{"float":"left"});switch(b.scrollSpeed.toLowerCase()){case "slow":w=1;break;case "fast":w=4;break;default:w=2}r(C,function(a){var c=parseInt(window.getComputedStyle(a).getPropertyValue("margin-top")),d=parseInt(window.getComputedStyle(a).getPropertyValue("margin-bottom")),e=parseInt(window.getComputedStyle(a).getPropertyValue("margin-left")),f=parseInt(window.getComputedStyle(a).getPropertyValue("margin-right")); c=a.offsetHeight+c+d;e=a.offsetWidth+e+f;"vertical"!=b.scrollerAlignment.toLowerCase()?(h+=e,a.offsetHeight>J&&(J=c)):(h+=c,a.offsetWidth>E&&(E=e))});"vertical"!=b.scrollerAlignment.toLowerCase()?g.style.height=J+"px":(g.style.width=E+"px",g.style.height=0m?(x=Math.round(h/100*b.scrollerOffset)-Math.round(m/2),x>h-m&&(x=h-m),g.style.overflow="hidden",g.style.position="relative",r(d,function(a){a.style.position= "absolute";"vertical"!=b.scrollerAlignment.toLowerCase()?t(a,{top:0,width:h+"px"}):t(a,{left:0,height:h+"px",width:E+"px"});r(a.children,function(a){a.style["float"]="left";a.style.position="static"})}),"vertical"!=b.scrollerAlignment.toLowerCase()?(d[0].style.left=0