forked from jonathantneal/angular-sticky
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular-sticky.min.js
More file actions
1 lines (1 loc) · 1.12 KB
/
angular-sticky.min.js
File metadata and controls
1 lines (1 loc) · 1.12 KB
1
(function(e){angular.module(e,[]).directive(e,function(){return{link:function(t,n,r){function h(){if(!s.matches){l=f=false;return}var e=getComputedStyle(n[0]),t=l?"top:"+o:"bottom:"+i;u.append(n.replaceWith(u));u.attr("style","display:"+e.display+";height:"+n[0].offsetHeight+"px;margin:"+e.margin+";width:"+n[0].offsetWidth+"px");n.attr("style","left:"+c.left+"px;margin:0;position:fixed;transition:none;"+t+"px;width:"+e.width)}function p(){if(a===undefined){n.removeAttr("style")}else{n.attr("style",a)}u.removeAttr("style");u.replaceWith(n);l=f=false}function d(){if(l||f){c=u[0].getBoundingClientRect();f=!isNaN(i)&&c.top>window.innerHeight-i-u[0].offsetHeight;l=!isNaN(o)&&c.top<o;if(!l&&!f){p()}}else{c=n[0].getBoundingClientRect();f=!isNaN(i)&&c.top>window.innerHeight-i-n[0].offsetHeight;l=!isNaN(o)&&c.top<o;if(l||f){h()}}}function v(){if(l||f){p()}d()}var i=parseFloat(r[e+"Bottom"]),s=window.matchMedia(r[e+"Media"]||"all"),o=parseFloat(r[e+"Top"]),u=new angular.element(document.createElement("span")),a=n.attr("style"),f=false,l=false,c={};window.addEventListener("scroll",d);window.addEventListener("resize",v);d()}}})})("sticky")