From 95a9d350524125f99f59e0e74137a1c2c3cd3c0c Mon Sep 17 00:00:00 2001 From: David Oliveros Date: Mon, 12 Jan 2015 14:02:10 -0600 Subject: [PATCH] Cleaned up, bumped version number --- bower.json | 2 +- dist/sticky.min.js | 2 +- lib/sticky.js | 11 +++++------ test/demo.html | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/bower.json b/bower.json index 3a39c3d..4c68af7 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-sticky", - "version": "1.7.6", + "version": "1.7.8", "homepage": "https://github.com/d-oliveros/angular-sticky", "authors": [ "David Oliveros " diff --git a/dist/sticky.min.js b/dist/sticky.min.js index 3940666..354e8ba 100644 --- a/dist/sticky.min.js +++ b/dist/sticky.min.js @@ -1 +1 @@ -!function(){"use strict";var t=angular.module("sticky",[]);t.directive("sticky",function(){function t(t,o,e){function s(){g.offsetWidth=u.offsetWidth,i()}function n(){h.off("scroll",i),h.off("resize",s),p&&w.removeClass(p)}function i(){var t,o,e,s;(!l||x("("+l+")").matches)&&("top"===T?(s=window.pageYOffset||m.scrollTop,t=s-(m.clientTop||0),o=t>=C):(e=window.pageYOffset+window.innerHeight,o=C>=e),o&&!b?r():!o&&b&&a())}function r(){var t,e;t=o[0].getBoundingClientRect(),e=t.left,g.offsetWidth=u.offsetWidth,b=!0,p&&(w.addClass(p),o.addClass(d)),o.css("width",u.offsetWidth+"px").css("position","fixed").css(T,k+"px").css("margin-top",0),"bottom"===T&&o.css("margin-bottom",0)}function a(){o.attr("style",o.initialStyle),b=!1,p&&w.removeClass(p),d&&o.removeClass(d),o.css("width",g.offsetWidth+"px").css("top",g.top).css("position",g.position).css("margin-top",g.marginTop)}function c(t){var o=0;if(t.offsetParent)do o+=t.offsetTop,t=t.offsetParent;while(t);return o}function f(t){return t.offsetTop+t.clientHeight}var l,d,p,u,h,w,m,g,y,v,b,C,k,T,W,x;switch(v=!1,b=!1,x=window.matchMedia,h=angular.element(window),w=angular.element(document.body),u=o[0],m=document.documentElement,l=e.mediaQuery||!1,d=e.stickyClass||"",p=e.bodyClass||"",y=o.attr("style"),k="string"==typeof e.offset?parseInt(e.offset.replace(/px;?/,"")):0,T="string"==typeof e.anchor?e.anchor.toLowerCase().trim():"top",g={top:o.css("top"),width:o.css("width"),position:o.css("position"),marginTop:o.css("margin-top"),cssLeft:o.css("left")},T){case"top":case"bottom":break;default:console.log("Unknown anchor "+T+", defaulting to top"),T="top"}h.on("scroll",i),h.on("resize",t.$apply.bind(t,s)),t.$on("$destroy",n),W=c(u),t.$watch(function(){return b?W:W="top"===T?c(u):f(u)},function(t,o){(t!==o||void 0===C)&&(C=t-k,i())})}return{restrict:"A",link:t}}),window.matchMedia=window.matchMedia||function(){var t="angular-sticky: This browser does not support matchMedia, therefore the minWidth option will not work on this browser. Polyfill matchMedia to fix this issue.";return window.console&&console.warn&&console.warn(t),function(){return{matches:!0}}}()}(); \ No newline at end of file +!function(){"use strict";var t=angular.module("sticky",[]);t.directive("sticky",function(){function t(t,o,e){function n(){if(g.offsetWidth=u.offsetWidth,i(),C){var t=window.getComputedStyle(u.parentElement,null),e=u.parentElement.offsetWidth-t.getPropertyValue("padding-right").replace("px","")-t.getPropertyValue("padding-left").replace("px","");o.css("width",e+"px")}}function s(){w.off("scroll",i),w.off("resize",n),p&&h.removeClass(p)}function i(){var t,o,e,n;(!l||W("("+l+")").matches)&&("top"===x?(n=window.pageYOffset||m.scrollTop,t=n-(m.clientTop||0),o=t>=b):(e=window.pageYOffset+window.innerHeight,o=b>=e),o&&!C?r():!o&&C&&a())}function r(){var t,e;t=o[0].getBoundingClientRect(),e=t.left,g.offsetWidth=u.offsetWidth,C=!0,p&&h.addClass(p),d&&o.addClass(d),o.css("width",u.offsetWidth+"px").css("position","fixed").css(x,k+"px").css("margin-top",0),"bottom"===x&&o.css("margin-bottom",0)}function a(){o.attr("style",o.initialStyle),C=!1,p&&h.removeClass(p),d&&o.removeClass(d),o.css("width","").css("top",g.top).css("position",g.position).css("margin-top",g.marginTop)}function c(t){var o=0;if(t.offsetParent)do o+=t.offsetTop,t=t.offsetParent;while(t);return o}function f(t){return t.offsetTop+t.clientHeight}var l,d,p,u,w,h,m,g,y,v,C,b,k,x,T,W;switch(v=!1,C=!1,W=window.matchMedia,w=angular.element(window),h=angular.element(document.body),u=o[0],m=document.documentElement,l=e.mediaQuery||!1,d=e.stickyClass||"",p=e.bodyClass||"",y=o.attr("style"),k="string"==typeof e.offset?parseInt(e.offset.replace(/px;?/,"")):0,x="string"==typeof e.anchor?e.anchor.toLowerCase().trim():"top",g={top:o.css("top"),width:o.css("width"),position:o.css("position"),marginTop:o.css("margin-top"),cssLeft:o.css("left")},x){case"top":case"bottom":break;default:console.log("Unknown anchor "+x+", defaulting to top"),x="top"}w.on("scroll",i),w.on("resize",t.$apply.bind(t,n)),t.$on("$destroy",s),T=c(u),t.$watch(function(){return C?T:T="top"===x?c(u):f(u)},function(t,o){(t!==o||void 0===b)&&(b=t-k,i())})}return{restrict:"A",link:t}}),window.matchMedia=window.matchMedia||function(){var t="angular-sticky: This browser does not support matchMedia, therefore the minWidth option will not work on this browser. Polyfill matchMedia to fix this issue.";return window.console&&console.warn&&console.warn(t),function(){return{matches:!0}}}()}(); \ No newline at end of file diff --git a/lib/sticky.js b/lib/sticky.js index 818d218..2f3fbe0 100644 --- a/lib/sticky.js +++ b/lib/sticky.js @@ -74,9 +74,9 @@ if(isSticking){ var parent = window.getComputedStyle(elem.parentElement, null), - initialOffsetWidth = elem.parentElement.offsetWidth - - parent.getPropertyValue('padding-right').replace('px', '') - - parent.getPropertyValue('padding-left').replace('px', ''); + initialOffsetWidth = elem.parentElement.offsetWidth - + parent.getPropertyValue('padding-right').replace('px', '') - + parent.getPropertyValue('padding-left').replace('px', ''); $elem.css('width', initialOffsetWidth+'px'); } @@ -153,10 +153,10 @@ $body.addClass(bodyClass); } - if(stickyClass){ + if ( stickyClass ) { $elem.addClass(stickyClass); } - + $elem .css('width', elem.offsetWidth+'px') .css('position', 'fixed') @@ -169,7 +169,6 @@ } function unstickElement() { - //$elem[0].removeAttribute("style"); $elem.attr('style', $elem.initialStyle); isSticking = false; diff --git a/test/demo.html b/test/demo.html index 535063c..7357692 100644 --- a/test/demo.html +++ b/test/demo.html @@ -1,7 +1,7 @@ - Angular-Sticky Demo v1.7.6 + Angular-Sticky Demo v1.7.8