-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgwdcarouselgallery_min.js
19 lines (19 loc) · 8.87 KB
/
gwdcarouselgallery_min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+function(){var f;var l=function(a){return"gwd-page"==a.tagName.toLowerCase()||"gwd-page"==a.getAttribute("is")},m=function(a){if(l(a))return a;for(;a&&9!=a.nodeType;)if((a=a.parentElement)&&l(a))return a;return null},n=function(a,b,c){a=parseInt(a.getAttribute(b),10);isNaN(a)&&(a=c);return a},p=function(a,b,c,d){d=d||b;a.hasAttribute(b)?(a=a.getAttribute(b),c.setAttribute(d,a)):c.removeAttribute(d)};var q=["-ms-","-moz-","-webkit-",""],r=function(a,b,c,d){for(var e,g,h=0;h<q.length;++h)e=q[h]+b,g=(d?q[h]:"")+c,a.style.setProperty(e,g)};var t=function(a){setTimeout(a,0)};var u=function(a,b,c){var d;c?(d=document.createEvent("CustomEvent"),d.initCustomEvent(a,!0,!0,c)):(d=document.createEvent("Event"),d.initEvent(a,!0,!0));b.dispatchEvent(d);return d},v=function(a,b){t(function(){u("autoplayended",a,b)})},w=function(a,b){var c=function(d){a.removeEventListener("attached",c);b(d)};a.addEventListener("attached",c)};var x=function(a){a=a.trim();return window.Enabler?Enabler.getUrl(a):a};var y=function(a,b){this.i=a;this.j=null;this.da=b;this.C=!1};
y.prototype.play=function(a,b,c){if(this.i.frameCount&&null==this.j){b=b||"forwards";var d;c?(d=Math.floor(a/c),a=c):(d=this.i.frameCount,a/=d);var e=[],g=this.i.currentIndex-1;c=g;for(var h=0;h<d;h++){if(0<h||!this.da)c=z(c+A(b,1),this.i.frameCount);e.push(c)}b=function(){if(e.length){var a=e.shift();this.C=!0;this.i.goToFrame(a+1);this.C=!1;B(this.i,"frameautoplayed",a+1)}else this.stop(!0),this.i.goToFrame(g+1)}.bind(this);this.j=setInterval(b,a);setTimeout(b)}};
y.prototype.stop=function(a){!this.C&&this.j&&(clearInterval(this.j),v(this.i,{completed:!!a}),this.j=null)};
var C=function(a){var b=document.createElement("img","gwd-image");b.setAttribute("source",a);return b},D=function(a){var b=[];if(a){a=a.split(",");for(var c=0;c<a.length;++c)/\S/.test(a[c])&&b.push(C(x(a[c])))}return b},E=function(a,b){for(var c=0,d=a.length;c<d;c++){var e=a[c];"img"==e.tagName.toLowerCase()&&"gwd-image"==e.getAttribute("is")&&(null!=b?e.setAttribute("scaling",b):e.removeAttribute("scaling"))}},B=function(a,b,c){u(b,a,{id:c||a.currentIndex})},F=function(a,b){for(var c=b.length,d=
b.splice(0,c),e,g=0;g<c;g++)e=d[g],"frameshown"==e?B(a,e):u(e,a)},A=function(a,b){return"left"==a||"backwards"==a?-b:b},z=function(a,b){return(a%b+b)%b};var G=function(a){var b=n(a,"frame-width",-1);-1==b&&(b=parseInt(.8*a.clientWidth,10));var c=a.hasAttribute("show-reflection"),d=n(a,"frame-height",-1);-1==d&&(d=c?parseInt(4*a.clientHeight/7,10):parseInt(6*a.clientHeight/7,10));var e=n(a,"neighbor-translation-x",-1);-1==e&&(e=parseInt(b/8,10));var g=n(a,"neighbor-translation-y",-1);-1==g&&(g=parseInt(d/-10,10));var h=n(a,"neighbor-translation-z",-1);-1==h&&(h=-d);return{autoplay:a.hasAttribute("autoplay"),s:b,S:d,W:n(a,"neighbor-rotation-y",38),
X:e,L:g,Y:h,transitionDuration:n(a,"transition-duration",600),ha:c,ea:n(a,"start-frame",2)}},H=function(a,b,c,d,e){b="translate3d("+b+"px, "+c+"px, "+d+"px)";e&&(b="rotate3d(0, 1, 0, "+e+"deg) "+b);r(a,"transform",b)},I=function(a,b){r(a,"transition","transform "+b+"ms",!0)};var J=function(a,b){function c(){}c.prototype=b.prototype;a.fa=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.ga=function(a,c,g){for(var h=Array(arguments.length-2),k=2;k<arguments.length;k++)h[k-2]=arguments[k];return b.prototype[c].apply(a,h)}};var K=function(){};J(K,HTMLElement);f=K.prototype;f.createdCallback=function(){this.f=[];this.b=null;this.a=0;this.o=1;this.m=new y(this,!0);Object.defineProperty(this,"currentIndex",{enumerable:!0,get:this.T.bind(this)});Object.defineProperty(this,"frameSnapInterval",{enumerable:!0,get:this.V.bind(this)});Object.defineProperty(this,"frameCount",{enumerable:!0,get:this.U.bind(this)})};f.attributeChangedCallback=function(){};f.getFrame=function(a){if(0!=this.a)return this.f[a-1]};f.gwdLoad=function(){};
f.gwdIsLoaded=function(){return!0};f.goToFrame=function(a,b){this.stopRotation();0!=this.a&&(a>this.a?a=this.a:1>a&&(a=1),this.J(a,b))};f.J=function(a){this.b=a-1};var L=function(a,b,c,d){if(null!=a.b){var e=z(a.b+A(b,a.o||1),a.o*Math.ceil(a.a/a.o));((null!=d?d:1)||!("forwards"==b&&e<a.b||"backwards"==b&&e>a.b))&&a.goToFrame(e+1,c||"slide")}};f=K.prototype;f.goBackwards=function(a,b){return L(this,"backwards",a,b)};f.goForwards=function(a,b){return L(this,"forwards",a,b)};
f.rotateOnce=function(a,b){this.m.play(a||0,b)};f.stopRotation=function(){this.m.stop()};f.T=function(){return 0<this.a?this.b+1:void 0};f.V=function(){return this.o};f.U=function(){return this.a};var N=function(){};J(N,K);f=N.prototype;
f.createdCallback=function(){N.fa.createdCallback.call(this);this.D=!1;this.h=null;this.K=-1;this.G=0;var a=document.createElement("gwd-gesture");a.className="gesture";this.B=a;this.R=this.ba.bind(this);this.P=this.ca.bind(this);this.O=this.aa.bind(this);this.N=this.$.bind(this);this.w=u.bind(null,"firstinteraction",this);this.M=this.Z.bind(this);this.H=!1;this.F=[];this.l=F.bind(null,this,this.F);this.v=[];this.I=0;if(this.A=this.hasAttribute("images"))for(;this.firstChild;)this.removeChild(this.firstChild);this.c=
null;this.u=0;this.m=new y(this,!1);this.g=null};
f.attachedCallback=function(){var a=this.B;this.u=this.u||this.clientWidth/2;a.addEventListener("trackstart",this.R,!1);a.addEventListener("track",this.P,!1);a.addEventListener("trackend",this.O,!1);a.addEventListener("tap",this.N,!1);this.addEventListener("transitionend",this.l,!1);this.addEventListener("webkitTransitionEnd",this.l,!1);if("function"==typeof this.gwdLoad&&"function"==typeof this.gwdIsLoaded&&!this.gwdIsLoaded()){var b=(a=m(this))&&"function"==typeof a.gwdIsLoaded;(!a||b&&a.gwdIsLoaded())&&
this.gwdLoad()}};f.detachedCallback=function(){var a=this.B;a.removeEventListener("trackstart",this.R,!1);a.removeEventListener("track",this.P,!1);a.removeEventListener("trackend",this.O,!1);a.removeEventListener("tap",this.N,!1);this.removeEventListener("transitionend",this.l);this.removeEventListener("webkitTransitionEnd",this.l)};f.J=function(a,b){var c=this.c.transitionDuration;O(this,"none"!=b?c:0);P(this,a-1)};f.rotateOnce=function(a,b){this.m.play(a||this.c.transitionDuration*this.a,b)};
f.gwdIsLoaded=function(){return this.D};f.gwdLoad=function(){if(!this.D&&!this.h){var a;if(this.A)a=D(this.getAttribute("images"));else{a=this.childNodes;for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c];e.nodeType==Node.ELEMENT_NODE&&b.push(e)}a=b}this.f=a;Q(this)}};
var Q=function(a){for(;a.firstChild;)a.removeChild(a.firstChild);a.g=null;a.h&&a.h.removeEventListener("pageload",a.M,!1);for(var b=a.f,c=document.createElement("div","gwd-page"),d,e=0;e<b.length;++e)d=b[e],r(d,"user-select","none"),d.classList.add("frame"),c.appendChild(d);w(c,c.gwdLoad.bind(c));a.h=c;c.className=a.hasAttribute("show-reflection")?"container reflection":"container";c.addEventListener("pageload",a.M,!1);E(a.f,a.getAttribute("scaling"));a.appendChild(c);a.appendChild(a.B)};f=N.prototype;
f.Z=function(a){if(this.h===a.target){this.D=!0;this.a=this.f.length;this.v=[];this.I=this.a;this.c=G(this);a=0;for(var b,c=0;c<this.f.length;c++)b=this.f[c],b.style.left=a+"px",b.style.width=this.c.s+"px",b.style.height=this.c.S+"px",a+=this.c.s;if(this.a){a=this.c.ea-1;if(0>a||a>=this.a)a=0;O(this,0);P(this,a);this.c.autoplay&&t(this.rotateOnce.bind(this))}R(this);u("allframesloaded",this);u("ready",this)}};
f.attributeChangedCallback=function(a){switch(a){case "images":this.A=!0;this.a=0;this.b=null;this.f=D(this.getAttribute(a));Q(this);break;case "has-navigation":case "navigation-highlight":case "navigation-thumbnails":R(this);break;case "scaling":E(this.f,this.getAttribute("scaling"));break;case "style":case "class":break;default:this.c=G(this)}};f.ba=function(){null!=this.b&&(this.stopRotation(),this.G=this.b,O(this,0))};
f.ca=function(a){if(this.a){this.w&&(this.w(),this.w=null);a=-a.dx/this.c.s;var b=Math.round(a);S(this,this.G+b,a-b)}};f.aa=function(){if(null!=this.b){O(this,this.c.transitionDuration);var a=this.b;P(this,a);this.G!=a&&(0==a?u("reachleftend",this):a==this.a-1&&u("reachrightend",this))}};f.$=function(){this.a&&B(this,"frametap")};
var O=function(a,b){a.H=0<b;a.h&&I(a.h,b);for(var c=0;c<a.a;++c)I(a.f[c],b)},P=function(a,b){a.f[b]&&(a.b=b,S(a,b,0,a.a),a.F.push("frameshown"),a.v[b]||(a.v[b]=!0,--a.I||a.F.push("allframesviewed")));a.H||a.l()},S=function(a,b,c,d){for(var e=a.c,g,h=d||1,k=-h;k<=h;++k)if((d=a.f[k+b])&&0<=c*k){0>k?g=1-Math.abs(c):0<k?g=Math.abs(c)-1:(a.b=b,g=c);var M=Math.abs(g);H(d,e.X*g,e.L*M,e.Y*M,e.W*g)}a.K!=a.b&&null!=a.b&&(a.K=a.b,B(a,"frameactivated"));H(a.h,a.u-(b+c+.5)*e.s,-e.L,0)},R=function(a){var b=a.hasAttribute("has-navigation"),
c=!!a.g;b&&!c?(b=a.id||a.getAttribute("data-gwd-grp-id"),a.g=document.createElement("gwd-gallerynavigation"),a.g.setAttribute("for",b),a.classList.add("has-navigation"),a.appendChild(a.g)):!b&&c&&(a.classList.remove("has-navigation"),a.removeChild(a.g),a.g=null);a.g&&(p(a,"navigation-highlight",a.g,"highlight"),p(a,"navigation-thumbnails",a.g,"use-thumbnails"))};document.registerElement("gwd-carouselgallery",{prototype:N.prototype});}()