relatively-sticky

A jQuery plugin for creating smart sticky elements
git clone https://git.ce9e.org/relatively-sticky.git

commit
a6a4ddcc897a8ce8a1f9daacfa82e8d2ab4741c0
parent
1ddffdd98c9e0c4294b160dca22a38c113ad1f7b
Author
leaf corcoran <leafot@gmail.com>
Date
2014-11-20 08:01
oops that should be width

Diffstat

M jquery.sticky-kit.coffee 2 +-
M jquery.sticky-kit.js 2 +-
M jquery.sticky-kit.min.js 2 +-

3 files changed, 3 insertions, 3 deletions


diff --git a/jquery.sticky-kit.coffee b/jquery.sticky-kit.coffee

@@ -208,7 +208,7 @@ $.fn.stick_in_parent = (opts={}) ->
  208   208           position: ""
  209   209           bottom: ""
  210   210           top: ""
  211    -1           height: ""
   -1   211           width: ""
  212   212         }
  213   213 
  214   214         parent.position "position", ""

diff --git a/jquery.sticky-kit.js b/jquery.sticky-kit.js

@@ -205,7 +205,7 @@
  205   205           position: "",
  206   206           bottom: "",
  207   207           top: "",
  208    -1           height: ""
   -1   208           width: ""
  209   209         });
  210   210         parent.position("position", "");
  211   211         if (fixed) {

diff --git a/jquery.sticky-kit.min.js b/jquery.sticky-kit.min.js

@@ -5,5 +5,5 @@
    5     5 u=m=!1;(g=null!=n?n&&a.closest(n):k("<div />"))&&g.css("position",a.css("position"));B=function(){var c,e,l;c=parseInt(f.css("border-top-width"),10);e=parseInt(f.css("padding-top"),10);d=parseInt(f.css("padding-bottom"),10);p=f.offset().top+c+e;z=f.height();m&&(u=m=!1,null==n&&(a.insertAfter(g),g.detach()),a.css({position:"",top:"",width:"",bottom:""}).removeClass(s),l=!0);D=a.offset().top-parseInt(a.css("margin-top"),10)-r;t=a.outerHeight(!0);q=a.css("float");g&&g.css({width:a.outerWidth(!0),height:t,
    6     6 display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":q});if(l)return b()};B();if(t!==z)return A=void 0,c=r,x=C,b=function(){var b,k,l,h;null!=x&&(--x,0>=x&&(x=C,B()));l=e.scrollTop();null!=A&&(k=l-A);A=l;m?(v&&(h=l+t+c>z+p,u&&!h&&(u=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom"))),l<D&&(m=!1,c=r,null==n&&("left"!==q&&"right"!==q||a.insertAfter(g),g.detach()),b={position:"",width:"",top:""},a.css(b).removeClass(s).trigger("sticky_kit:unstick")),y&&
    7     7 (b=e.height(),t>b&&!u&&(c-=k,c=Math.max(b-t,c),c=Math.min(r,c),m&&a.css({top:c+"px"})))):l>D&&(m=!0,b={position:"fixed",top:c},b.width="border-box"===a.css("box-sizing")?a.outerWidth()+"px":a.width()+"px",a.css(b).addClass(s),null==n&&(a.after(g),"left"!==q&&"right"!==q||g.append(a)),a.trigger("sticky_kit:stick"));if(m&&v&&(null==h&&(h=l+t+c>z+p),!u&&h))return u=!0,"static"===f.css("position")&&f.css({position:"relative"}),a.css({position:"absolute",bottom:d,top:"auto"}).trigger("sticky_kit:bottom")},
    8    -1 w=function(){B();return b()},E=function(){e.off("touchmove",b);e.off("scroll",b);e.off("resize",w);k(document.body).off("sticky_kit:recalc",w);a.off("sticky_kit:detach",E);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:"",height:""});f.position("position","");if(m)return null==n&&("left"!==q&&"right"!==q||a.insertAfter(g),g.remove()),a.removeClass(s)},e.on("touchmove",b),e.on("scroll",b),e.on("resize",w),k(document.body).on("sticky_kit:recalc",w),a.on("sticky_kit:detach",E),setTimeout(b,
   -1     8 w=function(){B();return b()},E=function(){e.off("touchmove",b);e.off("scroll",b);e.off("resize",w);k(document.body).off("sticky_kit:recalc",w);a.off("sticky_kit:detach",E);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:"",width:""});f.position("position","");if(m)return null==n&&("left"!==q&&"right"!==q||a.insertAfter(g),g.remove()),a.removeClass(s)},e.on("touchmove",b),e.on("scroll",b),e.on("resize",w),k(document.body).on("sticky_kit:recalc",w),a.on("sticky_kit:detach",E),setTimeout(b,
    9     9 0)}};p=0;for(G=this.length;p<G;p++)d=this[p],F(k(d));return this}}).call(this);