forked from oblador/angular-parallax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-parallax.min.js
2 lines (2 loc) · 1.67 KB
/
angular-parallax.min.js
1
2
angular.module("duParallax",["duScroll","duParallax.directive","duParallax.helper"]),angular.module("duParallax.helper",[]).factory("parallaxHelper",function(){function r(r,o,a,t){return function(n){var e=r*((t||0)+n.elemY);return angular.isNumber(o)&&e>o?o:angular.isNumber(a)&&a>e?a:e}}return{createAnimator:r,background:r(-.3,150,-30,50)}}),angular.module("duParallax.directive",["duScroll"]).directive("duParallax",["$rootScope","$window","$document",function(r,o,a){for(var t,n=angular.element("<div></div>")[0],e="transform WebkitTransform MozTransform OTransform".split(" "),l=0;l<e.length;l++)if(void 0!==n.style[e[l]]){t=e[l];break}if(t){var i=function(r){return r.x||r.y?"translate3d("+Math.round(r.x)+"px, "+Math.round(r.y)+"px, 0)":""},u=function(r){return r.rotation?" rotate("+(angular.isNumber(r.rotation)?Math.round(r.rotation)+"deg":r.rotation)+")":""},c=function(r,o){if(o.style[t]=i(r)+u(r),o.style.opacity=r.opacity,r.custom)for(var a in r.custom)o.style[a]=r.custom[a]};return{scope:{y:"=",x:"=",rotation:"=",opacity:"=",custom:"="},link:function(r,t){var n,e=t[0],l=!1,i=function(){var t=a.scrollTop(),u=e.getBoundingClientRect();l||(l=!0,angular.element(o).on("load",function(){var r,o=0,a=10,t=u.top;do r=t,i(),t=e.getBoundingClientRect().top,o++;while(a>o&&r!==t)}));var d={scrollY:t,elemX:u.left,elemY:u.top},f={x:0,y:0,rotation:0,opacity:1,custom:void 0};for(var s in f)angular.isFunction(r[s])?f[s]=r[s](d):r[s]&&(f[s]=r[s]);var m=angular.isUndefined(n);if(!m)for(s in f)if(f[s]!==n[s]){m=!0;break}m&&(c(f,e),n=f)};a.on("scroll touchmove",i).triggerHandler("scroll"),r.$on("$destroy",function(){a.off("scroll touchmove",i)})}}}}]);
//# sourceMappingURL=angular-parallax.min.js.map