-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathangular-stellar.min.js
More file actions
5 lines (5 loc) · 6.36 KB
/
angular-stellar.min.js
File metadata and controls
5 lines (5 loc) · 6.36 KB
1
2
3
4
5
/*! tomchentw-boilerplate - v 0.2.6 - Fri Jan 17 2014 19:05:42 GMT+0800 (CST)
* https://github.com/tomchentw/angular-stellar
* Copyright (c) 2014 [tomchentw](https://github.com/tomchentw/);
* Licensed [MIT](http://tomchentw.mit-license.org/)
*/(function(){var t,e,n,o,r,i,s,l,a,c,f,u;t=angular.bind,e=angular.noop,n=angular.extend,o=1e3/60,r=["$window","$log"].concat(function(e,n){var r,i,s,l,a;for(r=["request","webkitRequest","mozRequest","oRequest","msRequest"],i=0,s=r.length;s>i;++i)if(l=r[i],a=e[l+"AnimationFrame"])return t(e,a);return n.warn("Can't find requestAnimationFrame in your browser. Use polyfill."),function(t){return e.setTimeout(t,o)}}),i={scrollProperty:"scroll",positionProperty:"position",horizontalScrolling:!0,verticalScrolling:!0,horizontalOffset:0,verticalOffset:0,hideDistantElements:!0,hideElement:function(t){t.addClass("ng-hide")},showElement:function(t){t.removeClass("ng-hide")},isElementHidden:function(t){return t.hasClass("ng-hide")}},s=function(){function e(t,e){i[t]=this,i._targets.push(this),this._$element=e,this._callbacks=[],this._props={}}e.displayName="Target";var r=e.prototype,i=e;return e._lastTime=0,e._targets=[],e.getInstance=function(t,n){return e[t]||new e(t,n)},e.handleUpdate=function(t){var e,n,r,i,s,l;if(e=t-this._lastTime<o)return!0;for(this._lastTime=t,n=!1,r=0,s=(i=this._targets).length;s>r;++r)l=i[r],l.handleUpdate()&&!n&&(n=!0);return n},r.addCallbak=function(e){var n;return n=-1+this._callbacks.push(e),t(this._callbacks,this._callbacks.splice,n)},r.handleUpdate=function(){var t,e,o,r,i;if(t=this.getOffset(),t.scrollTop=this.getTop(),t.scrollLeft=this.getLeft(),!angular.equals(t,this._props))for(n(this._props,t),e=0,r=(o=this._callbacks).length;r>e;++e)(i=o[e])(this._props)},r.handleWebkitBug=function(){var t,e,n;t=this._props,e=t.scrollTop,n=t.scrollLeft,this.setTop(e+1),this.setLeft(n+1),this.setTop(e),this.setLeft(n)},r.getLeft=function(){return this._$element.prop("scrollLeft")},r.setLeft=function(t){this._$element.prop("scrollLeft",t)},r.getTop=function(){return this._$element.prop("scrollTop")},r.setTop=function(t){this._$element.prop("scrollTop",t)},e}(),l=["$window"].concat(function(t){return function(e,n){var o,r;return o=e[0],r=o.currentStyle?o.currentStyle:t.getComputedStyle?t.getComputedStyle(o):o.style,n?r[n]:r}}),a=["$css"].concat(function(t){var e,n,o,r;e=/^(moz|webkit|khtml|o|ms)(?=[A-Z])/;for(n in t(angular.element("<script></script>")))if(o=n.match(e)){r=o[0];break}return function(t){return r+(r?angular.uppercase(t.charAt(0))+""+t.slice(1):t)}}),c=["$window","$document","$position","$requestAnimationFrame","$css","$vendorPrefix","stellarConfig"].concat(function(e,o,r,i,l,a,c){var f,u,p,h;return f=s.getInstance("window",angular.element(e)),u=s.getInstance("document",o),f.getOffset=u.getOffset=function(){var t;return t=o[0].documentElement,{height:t.clientHeight,width:t.clientWidth,top:0,left:0}},f.getLeft=u.getLeft=function(){return e.pageXOffset},f.getTop=u.getTop=function(){return e.pageYOffset},f.setLeft=u.setLeft=function(t){e.scrollTo(t,e.pageYOffset)},f.setTop=u.setLeft=function(t){e.scrollTo(e.pageXOffset,t)},p=c.scrollProperty,n(s.prototype,{getOffset:function(){return r.offset(this._$element)}},angular.isObject(p)?p:function(){var t,e;switch(t=function(t,e){return parseInt(l(t,e),10)},e=a("transform"),p){case"position":return{getLeft:function(){return-1*t(this._$element,"left")},getTop:function(){return-1*t(this._$element,"top")}};case"margin":return{getLeft:function(){return-1*t(this._$element,"marginLeft")},getTop:function(){return-1*t(this._$element,"marginTop")}};case"transform":return{getLeft:function(){var t;return t=l(this._$element,e),"none"===t?0:-1*parseInt(t.match(/(-?[0-9]+)/g)[4],10)},getTop:function(){var t;return t=l(this._$element,e),"none"===t?0:-1*parseInt(t.match(/(-?[0-9]+)/g)[5],10)}};case"scroll":default:return{}}}.call(this)),h=t(this,i,function(t){var e;e=s.handleUpdate(t),("scroll"!==p||e)&&h()}),"scroll"===p&&f._$element.on("scroll resize",h),function(t,e){return h()&&s.getInstance(t,e)}}),f=["$position","$css","stellarTarget"].concat(function(t,e,n){var o,r;return o=function(t){var n;return n=e(t,"backgroundPosition").split(" "),[parseInt(n[0],10),parseInt(n[1],10)]},r=function(t,n){var o,r;return o=n.stellarBackgroundRatio||1,r="fixed"===e(t,"backgroundAttachment")?0:1,r-o},{restrict:"A",link:function(e,s,l){var a,c,f,u,p,h;a=r(s,l),c=l.stellarVerticalOffset||i.verticalOffset,f=l.stellarHorizontalOffset||i.horizontalOffset,u=t.offset(s),p=o(s),h={top:0,left:0},u.bgTop=p[1],u.bgLeft=p[0],e.$on("$destroy",n("window").addCallbak(function(t){var e,n;e=a*(t.scrollTop+c-t.top-u.top+h.top-u.bgTop),n=a*(t.scrollLeft+f-t.left-u.left+h.left-u.bgLeft),s.css("background-position",n+"px "+e+"px")}))}}}),u=["$css","$vendorPrefix","$position","stellarConfig","stellarTarget"].concat(function(t,e,n,o,r){var i,s,l,a,c,f;return i=o.positionProperty,s=o.horizontalScrolling,l=o.verticalScrolling,a=angular.isFunction(i.setPosition)?i.setPosition:function(){var t,n,o;switch(t=e("transform"),i){case"position":n=function(t,e){t.css("top",e)},o=function(t,e){t.css("left",e)};break;case"transform":return function(e,n,o,r,i){e.css(t,"translate3d("+(n-o)+"px, "+(r-i)+"px, 0)")}}return function(t,e,r,i,a){s&&o(t,e+"px",r+"px"),l&&n(t,i+"px",a+"px")}}.call(this),c=function(e){return"fixed"===t(e,"position")},f=function(t,e){var n,o;return n=e.stellarRatio||1,o=c(t)?1:0,n+o-1},{restrict:"A",link:function(t,e,i){var u,p,h,g,d,m,v;u=c(e),p=-1*f(e,i),h=i.stellarVerticalOffset||o.verticalOffset,g=i.stellarHorizontalOffset||o.horizontalOffset,d=n.offset(e),m=n.position(e),v={top:0,left:0},d.positionTop=m.top,d.positionLeft=m.left,t.$on("$destroy",r("window").addCallbak(function(t){var n,r,i,c,f,m,T,$,_;n=d.positionTop,r=d.top,l&&(n+=p*(t.scrollTop+h+t.top+d.positionTop-d.top+v.top),r+=n-d.positionTop),i=d.positionLeft,c=d.left,s&&(i+=p*(t.scrollLeft+g+t.left+d.positionLeft-d.left+v.left),c+=i-d.positionLeft),o.hideDistantElements&&(f=u?0:t.scrollLeft,m=u?0:t.scrollTop,T=!s||c+d.width>f&&c<t.width+t.left+f,$=!l||r+d.height>m&&r<t.height+t.top+m),_=o.isElementHidden(e),T&&$?(_&&o.showElement(e),a(e,i,d.positionLeft,n,d.positionTop)):_||o.hideElement(e)}))}}}),angular.module("angular.stellar",["ui.bootstrap.position"]).constant("stellarConfig",i).factory("$requestAnimationFrame",r).factory("$css",l).factory("$vendorPrefix",a).factory("stellarTarget",c).directive("stellarRatio",u).directive("stellarBackgroundRatio",f)}).call(this);