relatively-sticky

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

commit
7565f8086735c700d03171bd8d101651b123bef4
parent
83b1e270399a1155013539ffa28226deac32a3e6
Author
leaf corcoran <leafot@gmail.com>
Date
2014-03-30 06:44
version bump :dancers:

Diffstat

M bower.json 2 +-
M jquery.sticky-kit.coffee 2 +-
M jquery.sticky-kit.js 2 +-
M jquery.sticky-kit.min.js 2 +-
M site/index.html 4 ++++
M site/site.moon 2 +-
M site/www/src/jquery.sticky-kit.js 13 +++++++------
M site/www/src/jquery.sticky-kit.min.js 12 ++++++------
M sticky-kit.jquery.json 2 +-

9 files changed, 23 insertions, 18 deletions


diff --git a/bower.json b/bower.json

@@ -1,6 +1,6 @@
    1     1 {
    2     2   "name": "sticky-kit",
    3    -1   "version": "1.0.3",
   -1     3   "version": "1.0.4",
    4     4   "homepage": "http://leafo.net/sticky-kit/",
    5     5   "authors": [
    6     6     "leaf corcoran <leafot@gmail.com>"

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

@@ -1,5 +1,5 @@
    1     1 ###*
    2    -1 @license Sticky-kit v1.0.3 | WTFPL | Leaf Corcoran 2013 | http://leafo.net
   -1     2 @license Sticky-kit v1.0.4 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
    3     3 ###
    4     4 
    5     5 $ = @jQuery

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

@@ -1,7 +1,7 @@
    1     1 // Generated by CoffeeScript 1.7.1
    2     2 
    3     3 /**
    4    -1 @license Sticky-kit v1.0.3 | WTFPL | Leaf Corcoran 2013 | http://leafo.net
   -1     4 @license Sticky-kit v1.0.4 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
    5     5  */
    6     6 
    7     7 (function() {

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

@@ -1,5 +1,5 @@
    1     1 /*
    2    -1  Sticky-kit v1.0.3 | WTFPL | Leaf Corcoran 2013 | http://leafo.net
   -1     2  Sticky-kit v1.0.4 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
    3     3 */
    4     4 (function(){var b,m;b=this.jQuery;m=b(window);b.fn.stick_in_parent=function(e){var u,n,f,s,B,l,C;null==e&&(e={});s=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==s&&(s="is_stuck");B=function(a,e,l,v,y,p,t){var q,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";q=k=!1;g=b("<div />");g.css("position",a.css("position"));A=function(){var c,
    5     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,q=!1,a.insertAfter(g).css({position:"",top:"",width:"",bottom:""}),g.detach(),!0):void 0;y=a.offset().top-parseInt(a.css("margin-top"),10)-n;p=a.outerHeight(!0);t=a.css("float");g.css({width:a.outerWidth(!0),height:p,display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":t});if(c)return h()};A();if(p!==v)return w=void 0,

diff --git a/site/index.html b/site/index.html

@@ -243,6 +243,10 @@ Note: only floated columns work in IE7.
  243   243 </h1>
  244   244 
  245   245 $markdown{[[
   -1   246   * **v1.0.4** - *Mar 29, 2014* -- `touchmove` events for mobile (Alfredo
   -1   247   Motta), support absolutely positioned element (Pierre Spring), `border-box`
   -1   248   element sets spacer correctly (jasonpolito), bug fix for bottomed state (Pierre
   -1   249   Spring)
  246   250   * **v1.0.2** *Nov 16, 2013* -- Add `sticky_kit:detach`, Bug fixes: remove
  247   251   stray top attribute when unfixing, fix issue with top when inner scrolling,
  248   252   handle variable width elements correctly, recalc is called on window resize

diff --git a/site/site.moon b/site/site.moon

@@ -9,7 +9,7 @@ exec = (cmd) ->
    9     9 
   10    10 site = sitegen.create_site =>
   11    11   @title = "Sticky-Kit | jQuery plugin for sticky elements"
   12    -1   @version = "1.0.3"
   -1    12   @version = "1.0.4"
   13    13 
   14    14   @full_size = exec("du -bh www/src/jquery.sticky-kit.js | cut -f 1")\lower!
   15    15   @compressed_size = exec("du -bh www/src/jquery.sticky-kit.min.js | cut -f 1")\lower!

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

@@ -1,7 +1,7 @@
    1     1 // Generated by CoffeeScript 1.7.1
    2     2 
    3     3 /**
    4    -1 @license Sticky-kit v1.0.3 | WTFPL | Leaf Corcoran 2013 | http://leafo.net
   -1     4 @license Sticky-kit v1.0.4 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
    5     5  */
    6     6 
    7     7 (function() {
@@ -43,6 +43,7 @@
   43    43         throw "failed to find stick parent";
   44    44       }
   45    45       fixed = false;
   -1    46       bottomed = false;
   46    47       spacer = $("<div />");
   47    48       spacer.css('position', elm.css('position'));
   48    49       recalc = function() {
@@ -52,10 +53,11 @@
   52    53         padding_bottom = parseInt(parent.css("padding-bottom"), 10);
   53    54         parent_top = parent.offset().top + border_top + padding_top;
   54    55         parent_height = parent.height();
   55    -1         restore = fixed ? (fixed = false, elm.insertAfter(spacer).css({
   -1    56         restore = fixed ? (fixed = false, bottomed = false, elm.insertAfter(spacer).css({
   56    57           position: "",
   57    58           top: "",
   58    -1           width: ""
   -1    59           width: "",
   -1    60           bottom: ""
   59    61         }), spacer.detach(), true) : void 0;
   60    62         top = elm.offset().top - parseInt(elm.css("margin-top"), 10) - offset_top;
   61    63         height = elm.outerHeight(true);
@@ -65,7 +67,7 @@
   65    67           height: height,
   66    68           display: elm.css("display"),
   67    69           "vertical-align": elm.css("vertical-align"),
   68    -1           float: el_float
   -1    70           "float": el_float
   69    71         });
   70    72         if (restore) {
   71    73           return tick();
@@ -75,7 +77,6 @@
   75    77       if (height === parent_height) {
   76    78         return;
   77    79       }
   78    -1       bottomed = false;
   79    80       last_pos = void 0;
   80    81       offset = offset_top;
   81    82       tick = function() {
@@ -131,7 +132,7 @@
  131   132               position: "fixed",
  132   133               top: offset
  133   134             };
  134    -1             css.width = elm.width() + "px";
   -1   135             css.width = elm.css("box-sizing") === "border-box" ? elm.outerWidth() + "px" : elm.width() + "px";
  135   136             elm.css(css).addClass(sticky_class).after(spacer);
  136   137             if (el_float === "left" || el_float === "right") {
  137   138               spacer.append(elm);

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    -1  Sticky-kit v1.0.3 | WTFPL | Leaf Corcoran 2013 | http://leafo.net
   -1     2  Sticky-kit v1.0.4 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
    3     3 */
    4    -1 (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,
    5    -1 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,
    6    -1 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"!==
    7    -1 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),
    8    -1 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);
   -1     4 (function(){var b,m;b=this.jQuery;m=b(window);b.fn.stick_in_parent=function(e){var u,n,f,s,B,l,C;null==e&&(e={});s=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==s&&(s="is_stuck");B=function(a,e,l,v,y,p,t){var q,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";q=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,q=!1,a.insertAfter(g).css({position:"",top:"",width:"",bottom:""}),g.detach(),!0):void 0;y=a.offset().top-parseInt(a.css("margin-top"),10)-n;p=a.outerHeight(!0);t=a.css("float");g.css({width:a.outerWidth(!0),height:p,display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":t});if(c)return h()};A();if(p!==v)return w=void 0,
   -1     6 c=n,h=function(){var b,h,r,f;r=m.scrollTop();null!=w&&(h=r-w);w=r;k?(f=r+p+c>v+l,q&&!f&&(q=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom")),r<y&&(k=!1,c=n,"left"!==t&&"right"!==t||a.insertAfter(g),g.detach(),b={position:"",width:"",top:""},a.css(b).removeClass(s).trigger("sticky_kit:unstick")),u&&(b=m.height(),p>b&&!q&&(c-=h,c=Math.max(b-p,c),c=Math.min(n,c),k&&a.css({top:c+"px"})))):r>y&&(k=!0,b={position:"fixed",top:c},b.width="border-box"===a.css("box-sizing")?a.outerWidth()+
   -1     7 "px":a.width()+"px",a.css(b).addClass(s).after(g),"left"!==t&&"right"!==t||g.append(a),a.trigger("sticky_kit:stick"));if(k&&(null==f&&(f=r+p+c>v+l),!q&&f))return q=!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:""});
   -1     8 d.position("position","");if(k)return a.insertAfter(g).removeClass(s),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/sticky-kit.jquery.json b/sticky-kit.jquery.json

@@ -1,6 +1,6 @@
    1     1 {
    2     2   "name": "sticky-kit",
    3    -1   "version": "1.0.3",
   -1     3   "version": "1.0.4",
    4     4 
    5     5   "title": "Sticky-kit",
    6     6   "homepage": "http://leafo.net/sticky-kit",