This repository has been archived by the owner on Feb 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangularStickTo.min.js
1 lines (1 loc) · 3.26 KB
/
angularStickTo.min.js
1
angular.module("angular-stick-to",[]),angular.module("angular-stick-to").directive("angularStickTo",["StickyElementRegistry","ElementFactory","$window","updateElement","postDigest",function(t,e,n,i,r){return function(o,c,a){function u(){i(g)}function s(){d.bind("scroll",u),d.bind("resize",u);var t=r(u);return function(){d.unbind("scroll",u),d.unbind("resize",u),t()}}function l(){var t=n.innerWidth||n.document.documentElement.clientWidth||n.document.body.clientWidth;return f>=t}var m={primaryLimit:a.angularStickTo,secondaryLimit:a.limit,element:c},f=isNaN(parseInt(a.breakpoint))?0:parseInt(a.breakpoint),g=e.createStickyElement(m);a.name&&(t[a.name]=g,o.$on("$destroy",function(){t[a.name]=void 0}));var y,d=angular.element(n);l()||(y=s()),o.$on("$destroy",function(){y&&y()}),d.bind("resize",function(){l()?y&&(y(),y=void 0,g.setSyntheticOffset(0)):y||(y=s())})}}]),angular.module("angular-stick-to").directive("angularStickToLimit",["LimitElementRegistry","ElementFactory",function(t,e){return function(n,i,r){var o=e.createSimpleElement(i);r.angularStickToLimit&&(t[r.angularStickToLimit]=o,n.$on("$destroy",function(){t[r.angularStickToLimit]=void 0}))}}]),angular.module("angular-stick-to").service("AccessorFactory",["StickyElementRegistry","LimitElementRegistry",function(t,e){function n(t){var e=parseInt(t);return isNaN(e)?0:e}this.createPrimaryLimitAccessor=function(e){var i=n(e);return function(){var n=t[e];return n?n.getBottom():i}},this.createSecondaryLimitAccessor=function(t){return function(){var n=e[t];return n?n.getTop():1/0}}}]),angular.module("angular-stick-to").service("ElementFactory",["AccessorFactory",function(t){function e(t){this.jqElement=t,this.element=t[0]}function n(n){e.call(this,n.element),this.getPrimaryLimit=t.createPrimaryLimitAccessor(n.primaryLimit),this.getSecondaryLimit=t.createSecondaryLimitAccessor(n.secondaryLimit),this._syntheticOffset=0,this.state=null}e.prototype={getTop:function(){return this.element.getBoundingClientRect().top},getBottom:function(){return this.element.getBoundingClientRect().bottom}},n.prototype=Object.create(e.prototype,{setSyntheticOffset:{value:function(t){var e="translate(0px,"+t+"px)";this.jqElement.css({"-ms-transform":e,"-webkit-transform":e,transform:e}),this._syntheticOffset=t}},getSyntheticOffset:{value:function(){return this._syntheticOffset}},getPristineTop:{value:function(){return this.getTop()-this.getSyntheticOffset()}},getPristineBottom:{value:function(){return this.getBottom()-this.getSyntheticOffset()}}}),n.prototype.constructor=n,this.createSimpleElement=function(t){return new e(t)},this.createStickyElement=function(t){return new n(t)}}]),angular.module("angular-stick-to").value("LimitElementRegistry",{}),angular.module("angular-stick-to").value("StickyElementRegistry",{}),angular.module("angular-stick-to").factory("postDigest",["$rootScope","$timeout",function(t,e){return function(n){var i=!1,r=!1,o=t.$watch(function(){i||(i=!0,e(function(){r||(n(),i=!1)},0,!1))});return function(){r=!0,o()}}}]),angular.module("angular-stick-to").factory("updateElement",[function(){return function(t){var e=t.getPrimaryLimit()-t.getPristineTop();if(e>0){var n=t.getPristineBottom()-t.getSecondaryLimit();if(n>0)t.setSyntheticOffset(-n);else{var i=-n;e>i?t.setSyntheticOffset(i):t.setSyntheticOffset(e)}}else t.setSyntheticOffset(0)}}]);