relatively-sticky

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

commit
f4be6d274f974f9cebc88b8ab9bf53ba871719b5
parent
72350acb534927430fe86aa668f4be4fab82e3c1
Author
Pierre Spring <pierre@nelm.io>
Date
2014-03-20 16:52
build and minify for absolute elements

Diffstat

M jquery.sticky-kit.js 9 +++++----
M jquery.sticky-kit.min.js 10 +++++-----
M site/www/src/jquery.sticky-kit.js 10 ++++++----
M site/www/src/jquery.sticky-kit.min.js 10 +++++-----

4 files changed, 21 insertions, 18 deletions


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

@@ -1,8 +1,8 @@
    1    -1 // Generated by CoffeeScript 1.6.3
   -1     1 // Generated by CoffeeScript 1.7.1
   -1     2 
    2     3 /**
    3     4 @license Sticky-kit v1.0.3 | WTFPL | Leaf Corcoran 2013 | http://leafo.net
    4    -1 */
    5    -1 
   -1     5  */
    6     6 
    7     7 (function() {
    8     8   var $, win;
@@ -44,6 +44,7 @@
   44    44       }
   45    45       fixed = false;
   46    46       spacer = $("<div />");
   -1    47       spacer.css('position', elm.css('position'));
   47    48       recalc = function() {
   48    49         var border_top, padding_top, restore;
   49    50         border_top = parseInt(parent.css("border-top-width"), 10);
@@ -152,7 +153,7 @@
  152   153             return elm.css({
  153   154               position: "absolute",
  154   155               bottom: padding_bottom,
  155    -1               top: ""
   -1   156               top: "auto"
  156   157             }).trigger("sticky_kit:bottom");
  157   158           }
  158   159         }

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

@@ -1,8 +1,8 @@
    1     1 /*
    2     2  Sticky-kit v1.0.3 | WTFPL | Leaf Corcoran 2013 | http://leafo.net
    3     3 */
    4    -1 (function(){var b,q;b=this.jQuery;q=b(window);b.fn.stick_in_parent=function(e){var u,m,f,r,B,l,C;null==e&&(e={});r=e.sticky_class;u=e.inner_scrolling;f=e.parent;m=e.offset_top;null==m&&(m=0);null==f&&(f=void 0);null==u&&(u=!0);null==r&&(r="is_stuck");B=function(a,e,l,v,y,n,s){var t,z,h,w,c,d,A,x,g,k;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);d=a.parent();null!=f&&(d=d.closest(f));if(!d.length)throw"failed to find stick parent";h=!1;g=b("<div />");A=function(){var c,b;c=parseInt(d.css("border-top-width"),
    5    -1 10);b=parseInt(d.css("padding-top"),10);e=parseInt(d.css("padding-bottom"),10);l=d.offset().top+c+b;v=d.height();c=h?(h=!1,a.insertAfter(g).css({position:"",top:"",width:""}),g.detach(),!0):void 0;y=a.offset().top-parseInt(a.css("margin-top"),10)-m;n=a.outerHeight(!0);s=a.css("float");g.css({width:a.outerWidth(!0),height:n,display:a.css("display"),"vertical-align":a.css("vertical-align"),float:s});if(c)return k()};A();if(n!==v)return t=!1,w=void 0,c=m,k=function(){var b,k,p,f;p=q.scrollTop();null!=
    6    -1 w&&(k=p-w);w=p;h?(f=p+n+c>v+l,t&&!f&&(t=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom")),p<y&&(h=!1,c=m,"left"!==s&&"right"!==s||a.insertAfter(g),g.detach(),b={position:"",width:"",top:""},a.css(b).removeClass(r).trigger("sticky_kit:unstick")),u&&(b=q.height(),n>b&&!t&&(c-=k,c=Math.max(b-n,c),c=Math.min(m,c),h&&a.css({top:c+"px"})))):p>y&&(h=!0,b={position:"fixed",top:c},b.width=a.width()+"px",a.css(b).addClass(r).after(g),"left"!==s&&"right"!==s||g.append(a),a.trigger("sticky_kit:stick"));
    7    -1 if(h&&(null==f&&(f=p+n+c>v+l),!t&&f))return t=!0,"static"===d.css("position")&&d.css({position:"relative"}),a.css({position:"absolute",bottom:e,top:""}).trigger("sticky_kit:bottom")},x=function(){A();return k()},z=function(){q.off("scroll",k);b(document.body).off("sticky_kit:recalc",x);a.off("sticky_kit:detach",z);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:""});d.position("position","");if(h)return a.insertAfter(g).removeClass(r),g.remove()},q.on("scroll",k),q.on("resize",x),b(document.body).on("sticky_kit:recalc",
    8    -1 x),a.on("sticky_kit:detach",z),setTimeout(k,0)}};l=0;for(C=this.length;l<C;l++)e=this[l],B(b(e));return this}}).call(this);
   -1     4 (function(){var b,m;b=this.jQuery;m=b(window);b.fn.stick_in_parent=function(e){var u,n,f,r,B,l,C;null==e&&(e={});r=e.sticky_class;u=e.inner_scrolling;f=e.parent;n=e.offset_top;null==n&&(n=0);null==f&&(f=void 0);null==u&&(u=!0);null==r&&(r="is_stuck");B=function(a,e,l,v,y,p,s){var t,z,k,w,c,d,A,x,g,h;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);d=a.parent();null!=f&&(d=d.closest(f));if(!d.length)throw"failed to find stick parent";k=!1;g=b("<div />");g.css("position",a.css("position"));A=function(){var c,
   -1     5 b;c=parseInt(d.css("border-top-width"),10);b=parseInt(d.css("padding-top"),10);e=parseInt(d.css("padding-bottom"),10);l=d.offset().top+c+b;v=d.height();c=k?(k=!1,a.insertAfter(g).css({position:"",top:"",width:""}),g.detach(),!0):void 0;y=a.offset().top-parseInt(a.css("margin-top"),10)-n;p=a.outerHeight(!0);s=a.css("float");g.css({width:a.outerWidth(!0),height:p,display:a.css("display"),"vertical-align":a.css("vertical-align"),float:s});if(c)return h()};A();if(p!==v)return t=!1,w=void 0,c=n,h=function(){var b,
   -1     6 h,q,f;q=m.scrollTop();null!=w&&(h=q-w);w=q;k?(f=q+p+c>v+l,t&&!f&&(t=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom")),q<y&&(k=!1,c=n,"left"!==s&&"right"!==s||a.insertAfter(g),g.detach(),b={position:"",width:"",top:""},a.css(b).removeClass(r).trigger("sticky_kit:unstick")),u&&(b=m.height(),p>b&&!t&&(c-=h,c=Math.max(b-p,c),c=Math.min(n,c),k&&a.css({top:c+"px"})))):q>y&&(k=!0,b={position:"fixed",top:c},b.width=a.width()+"px",a.css(b).addClass(r).after(g),"left"!==s&&"right"!==
   -1     7 s||g.append(a),a.trigger("sticky_kit:stick"));if(k&&(null==f&&(f=q+p+c>v+l),!t&&f))return t=!0,"static"===d.css("position")&&d.css({position:"relative"}),a.css({position:"absolute",bottom:e,top:"auto"}).trigger("sticky_kit:bottom")},x=function(){A();return h()},z=function(){m.off("scroll",h);b(document.body).off("sticky_kit:recalc",x);a.off("sticky_kit:detach",z);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:""});d.position("position","");if(k)return a.insertAfter(g).removeClass(r),
   -1     8 g.remove()},m.on("touchmove",h),m.on("scroll",h),m.on("resize",x),b(document.body).on("sticky_kit:recalc",x),a.on("sticky_kit:detach",z),setTimeout(h,0)}};l=0;for(C=this.length;l<C;l++)e=this[l],B(b(e));return this}}).call(this);

diff --git a/site/www/src/jquery.sticky-kit.js b/site/www/src/jquery.sticky-kit.js

@@ -1,8 +1,8 @@
    1    -1 // Generated by CoffeeScript 1.6.3
   -1     1 // Generated by CoffeeScript 1.7.1
   -1     2 
    2     3 /**
    3     4 @license Sticky-kit v1.0.3 | WTFPL | Leaf Corcoran 2013 | http://leafo.net
    4    -1 */
    5    -1 
   -1     5  */
    6     6 
    7     7 (function() {
    8     8   var $, win;
@@ -44,6 +44,7 @@
   44    44       }
   45    45       fixed = false;
   46    46       spacer = $("<div />");
   -1    47       spacer.css('position', elm.css('position'));
   47    48       recalc = function() {
   48    49         var border_top, padding_top, restore;
   49    50         border_top = parseInt(parent.css("border-top-width"), 10);
@@ -152,7 +153,7 @@
  152   153             return elm.css({
  153   154               position: "absolute",
  154   155               bottom: padding_bottom,
  155    -1               top: ""
   -1   156               top: "auto"
  156   157             }).trigger("sticky_kit:bottom");
  157   158           }
  158   159         }
@@ -177,6 +178,7 @@
  177   178           return spacer.remove();
  178   179         }
  179   180       };
   -1   181       win.on("touchmove", tick);
  180   182       win.on("scroll", tick);
  181   183       win.on("resize", recalc_and_tick);
  182   184       $(document.body).on("sticky_kit:recalc", recalc_and_tick);

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

@@ -1,8 +1,8 @@
    1     1 /*
    2     2  Sticky-kit v1.0.3 | WTFPL | Leaf Corcoran 2013 | http://leafo.net
    3     3 */
    4    -1 (function(){var b,q;b=this.jQuery;q=b(window);b.fn.stick_in_parent=function(e){var u,m,f,r,B,l,C;null==e&&(e={});r=e.sticky_class;u=e.inner_scrolling;f=e.parent;m=e.offset_top;null==m&&(m=0);null==f&&(f=void 0);null==u&&(u=!0);null==r&&(r="is_stuck");B=function(a,e,l,v,y,n,s){var t,z,h,w,c,d,A,x,g,k;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);d=a.parent();null!=f&&(d=d.closest(f));if(!d.length)throw"failed to find stick parent";h=!1;g=b("<div />");A=function(){var c,b;c=parseInt(d.css("border-top-width"),
    5    -1 10);b=parseInt(d.css("padding-top"),10);e=parseInt(d.css("padding-bottom"),10);l=d.offset().top+c+b;v=d.height();c=h?(h=!1,a.insertAfter(g).css({position:"",top:"",width:""}),g.detach(),!0):void 0;y=a.offset().top-parseInt(a.css("margin-top"),10)-m;n=a.outerHeight(!0);s=a.css("float");g.css({width:a.outerWidth(!0),height:n,display:a.css("display"),"vertical-align":a.css("vertical-align"),float:s});if(c)return k()};A();if(n!==v)return t=!1,w=void 0,c=m,k=function(){var b,k,p,f;p=q.scrollTop();null!=
    6    -1 w&&(k=p-w);w=p;h?(f=p+n+c>v+l,t&&!f&&(t=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom")),p<y&&(h=!1,c=m,"left"!==s&&"right"!==s||a.insertAfter(g),g.detach(),b={position:"",width:"",top:""},a.css(b).removeClass(r).trigger("sticky_kit:unstick")),u&&(b=q.height(),n>b&&!t&&(c-=k,c=Math.max(b-n,c),c=Math.min(m,c),h&&a.css({top:c+"px"})))):p>y&&(h=!0,b={position:"fixed",top:c},b.width=a.width()+"px",a.css(b).addClass(r).after(g),"left"!==s&&"right"!==s||g.append(a),a.trigger("sticky_kit:stick"));
    7    -1 if(h&&(null==f&&(f=p+n+c>v+l),!t&&f))return t=!0,"static"===d.css("position")&&d.css({position:"relative"}),a.css({position:"absolute",bottom:e,top:""}).trigger("sticky_kit:bottom")},x=function(){A();return k()},z=function(){q.off("scroll",k);b(document.body).off("sticky_kit:recalc",x);a.off("sticky_kit:detach",z);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:""});d.position("position","");if(h)return a.insertAfter(g).removeClass(r),g.remove()},q.on("scroll",k),q.on("resize",x),b(document.body).on("sticky_kit:recalc",
    8    -1 x),a.on("sticky_kit:detach",z),setTimeout(k,0)}};l=0;for(C=this.length;l<C;l++)e=this[l],B(b(e));return this}}).call(this);
   -1     4 (function(){var b,m;b=this.jQuery;m=b(window);b.fn.stick_in_parent=function(e){var u,n,f,r,B,l,C;null==e&&(e={});r=e.sticky_class;u=e.inner_scrolling;f=e.parent;n=e.offset_top;null==n&&(n=0);null==f&&(f=void 0);null==u&&(u=!0);null==r&&(r="is_stuck");B=function(a,e,l,v,y,p,s){var t,z,k,w,c,d,A,x,g,h;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);d=a.parent();null!=f&&(d=d.closest(f));if(!d.length)throw"failed to find stick parent";k=!1;g=b("<div />");g.css("position",a.css("position"));A=function(){var c,
   -1     5 b;c=parseInt(d.css("border-top-width"),10);b=parseInt(d.css("padding-top"),10);e=parseInt(d.css("padding-bottom"),10);l=d.offset().top+c+b;v=d.height();c=k?(k=!1,a.insertAfter(g).css({position:"",top:"",width:""}),g.detach(),!0):void 0;y=a.offset().top-parseInt(a.css("margin-top"),10)-n;p=a.outerHeight(!0);s=a.css("float");g.css({width:a.outerWidth(!0),height:p,display:a.css("display"),"vertical-align":a.css("vertical-align"),float:s});if(c)return h()};A();if(p!==v)return t=!1,w=void 0,c=n,h=function(){var b,
   -1     6 h,q,f;q=m.scrollTop();null!=w&&(h=q-w);w=q;k?(f=q+p+c>v+l,t&&!f&&(t=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom")),q<y&&(k=!1,c=n,"left"!==s&&"right"!==s||a.insertAfter(g),g.detach(),b={position:"",width:"",top:""},a.css(b).removeClass(r).trigger("sticky_kit:unstick")),u&&(b=m.height(),p>b&&!t&&(c-=h,c=Math.max(b-p,c),c=Math.min(n,c),k&&a.css({top:c+"px"})))):q>y&&(k=!0,b={position:"fixed",top:c},b.width=a.width()+"px",a.css(b).addClass(r).after(g),"left"!==s&&"right"!==
   -1     7 s||g.append(a),a.trigger("sticky_kit:stick"));if(k&&(null==f&&(f=q+p+c>v+l),!t&&f))return t=!0,"static"===d.css("position")&&d.css({position:"relative"}),a.css({position:"absolute",bottom:e,top:"auto"}).trigger("sticky_kit:bottom")},x=function(){A();return h()},z=function(){m.off("scroll",h);b(document.body).off("sticky_kit:recalc",x);a.off("sticky_kit:detach",z);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:""});d.position("position","");if(k)return a.insertAfter(g).removeClass(r),
   -1     8 g.remove()},m.on("touchmove",h),m.on("scroll",h),m.on("resize",x),b(document.body).on("sticky_kit:recalc",x),a.on("sticky_kit:detach",z),setTimeout(h,0)}};l=0;for(C=this.length;l<C;l++)e=this[l],B(b(e));return this}}).call(this);