-
Notifications
You must be signed in to change notification settings - Fork 8
/
pivot.min.js
1 lines (1 loc) · 5.68 KB
/
pivot.min.js
1
(function(w,x){function z(a,d,b,y){function k(){b.hoverClass&&b.hoverInClass?(a.className+=" "+b.hoverClass+" "+b.hoverInClass,setTimeout(function(){a.className=g(a.className,b.hoverInClass)},1E3)):b.hoverClass?a.className+=" "+b.hoverClass:b.hoverInClass&&(a.className+=" "+b.hoverInClass,setTimeout(function(){a.className=g(a.className,b.hoverInClass)},1E3))}function D(l){var c=d.offsetWidth,h=d.offsetHeight,k=a.getBoundingClientRect(),g=y?l.touches[0].clientX-k.left:l.offsetX;l=y?l.touches[0].clientY-k.top:l.offsetY;var k=b.invert?-(c/2-g)/u:(c/2-g)/u,m=b.invert?(h/2-l)/u:-(h/2-l)/u,c=180/Math.PI*Math.atan2(l-h/2,g-c/2)-90;a.style[v]=b.scale?"rotateY("+k+"deg) rotateX("+m+"deg) scale3d(1.05, 1.05, 1.05)":"rotateY("+k+"deg) rotateX("+m+"deg)";b.shadow&&(e.style[A]="0 24px 48px rgba(14, 21, 47, 0.4), 0 12px 24px rgba(14, 21, 47, 0.4)");b.shine&&(f.style.opacity=1,f.style.backgroundImage="linear-gradient("+(0>c?c+360:c)+"deg, rgba(230, 230, 230, "+l/h*.5+") 0%, transparent 80%)")}function E(){b.shadow&&(e.style[A]="0 8px 30px rgba(14, 21, 47, 0.6)");b.persist||(a.style[v]="rotateX(0deg) rotateY(0deg)",b.shine&&(f.style.opacity=0));b.hoverClass&&b.hoverOutClass?(a.className+=" "+b.hoverOutClass,a.className=g(a.className,b.hoverClass),setTimeout(function(){a.className=g(a.className,b.hoverOutClass)},1E3)):b.hoverClass?a.className=g(a.className,b.hoverClass):b.hoverOutClass&&(a.className+=" "+b.hoverOutClass,setTimeout(function(){a.className=g(a.className,b.hoverOutClass)},1E3))}var u=0,m=c(["perspective","webkitPerspective","mozPerspective"]),h=c(["transformStyle","webkitTransformStyle","mozTransformStyle"]),v=c(["transform","webkitTransform","mozTransform"]),z=c(["backfaceVisibility","webkitBackfaceVisibility","mozBackfaceVisibility"]),n=c(["willChange"]),A=c(["boxShadow","webkitBoxShadow","mozBoxShadow"]),F=c(["userSelect","webkitUserSelect","mozUserSelect"]),p=c(["transitionProperty","webkitTransitionProperty","mozTransitionProperty"]),q=c(["transitionDuration","webkitTransitionDuration","mozTransitionDuration"]);c(["transitionDelay","webkitTransitionDelay","mozTransitionDelay"]);var r=c(["transitionTimingFunction","webkitTransitionTimingFunction","mozTransitionTimingFunction"]);b.perspective&&"number"===typeof b.perspective?(d.style[m]=b.perspective+"px",a.style[m]=b.perspective+"px"):(d.style[m]="1000px",a.style[m]="1000px");d.style[h]="preserve-3d";a.style[h]="preserve-3d";d.style[F]="none";a.style[F]="none";a.style[v]="rotateY(0deg) rotateX(0deg)";u=b.sensitivity&&"number"===typeof b.sensitivity?b.sensitivity:20;y&&(a.style[z]="hidden");b.position&&"object"===typeof b.position?(a.style.position=b.position.method,a.style.zIndex=b.position.zindex):a.style.position="relative";b.transition&&"object"===typeof b.transition?(a.style[n]=b.transition.prop,a.style[p]=b.transition.prop,a.style[q]=B(b.transition.duration),a.style[r]=C(b.transition.timing)):(a.style[n]="transform",a.style[p]="transform",a.style[q]="0.2s",a.style[r]="cubic-bezier(0.3, 1, 0.2, 1)");if(b.shadow){var e=x.createElement("div");e.className="shadow";e.style.position="absolute";e.style.top="5%";e.style.left="5%";e.style.bottom="5%";e.style.right="5%";e.style.zIndex=1;e.style[v]="translateZ(-2px)";e.style[A]="0 8px 30px rgba(14, 21, 47, 0.6)";b.transition&&"object"===typeof b.transition?(e.style[n]="box-shadow, transform",e.style[p]="box-shadow",e.style[q]=B(b.transition.duration),e.style[r]=C(b.transition.timing)):(e.style[n]="box-shadow, transform",e.style[p]="box-shadow",e.style[q]="0.2s",e.style[r]="cubic-bezier(0.3, 1, 0.2, 1)");a.appendChild(e)}if(b.shine){var f=x.createElement("div");f.className="shine";f.style.position="absolute";f.style.top=0;f.style.left=0;f.style.bottom=0;f.style.right=0;f.style.zIndex=9;f.style.opacity=0;b.transition&&"object"===typeof b.transition?(f.style[n]="opacity, transform",f.style[p]="opacity",f.style[q]=B(b.transition.duration),f.style[r]=C(b.transition.timing)):(f.style[n]="box-shadow, transform",f.style[p]="box-shadow",f.style[q]="0.2s",f.style[r]="cubic-bezier(0.3, 1, 0.2, 1)");a.appendChild(f)}if(b.child3D&&"number"===typeof b.child3D)for(m=_target.children.length,h=0;m>h;h++)b.shadow&&a.children[h].className===e.className||b.shine&&a.children[h].className===f.className||(a.children[h].style[v]="translateZ("+b.child3D+"px)");y?(d.addEventListener("touchstart",function(){t||(t=!0);return k()}),d.addEventListener("touchmove",function(a){t&&a.preventDefault();return D(a)}),d.addEventListener("touchend",function(){t&&(w.preventScroll=!1);return E()})):(d.addEventListener("mouseenter",function(){return k()}),d.addEventListener("mousemove",function(a){return D(a)}),d.addEventListener("mouseleave",function(){return E()}))}function c(a){for(var d=a.length,b=0;d>b;b++)if("undefined"!==typeof x.body.style[a[b]])return a[b];return null}function B(a){return"number"!==typeof a?(console.warn("Please provide a numeric value"),"0.2s"):1<a&&50>=a?"0."+a+"s":50<a?a+"ms":a+"s"}function C(a){var d=a.length;if(a.constructor!==Array)return console.warn("Bad input: expected array"),"none";if(4===d){if("number"===typeof a[0]&&"number"===typeof a[1]&&"number"===typeof a[2]&&"number"===typeof a[3])return"cubic-bezier("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")";console.warn("Bad input: expected numbers");return"none"}console.warn("Bad input: expected four values");return"none"}function g(a,d){return a.replace(new RegExp(d+"\\s*","gi"),"").replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}w.pivot={init:function(a){var d=!!("ontouchstart"in w)||!!("onmsgesturechange"in w)||!!navigator.MaxTouchPoints,b,c,k=0;if("undefined"!==typeof a&&"object"===typeof a&&("touch"in a&&(d=a.touch),"selector"in a&&(b=x.querySelectorAll(a.selector)),0<b.length))for(c=b.length;c>k;k++){var g=b[k];var t=g.parentNode;z(g,t,a,d)}}};var t=!1})(window,document);