relatively-sticky

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

commit
a4f62c0a39fbcc6e8ac5ea2d0fe369e025323efd
parent
2ec259c34d5e062f155d86bfa86a1ba303dc2257
Author
leaf corcoran <leafot@gmail.com>
Date
2014-11-24 07:09
version bump :smirk_cat:

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 5 ++++-
M site/site.moon 2 +-
M site/www/src/jquery.sticky-kit.js 16 ++++++++++++----
M site/www/src/jquery.sticky-kit.min.js 14 +++++++-------
M sticky-kit.jquery.json 2 +-

9 files changed, 29 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.1.0",
   -1     3   "version": "1.1.1",
    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.1.0 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
   -1     2 @license Sticky-kit v1.1.1 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
    3     3 ###
    4     4 
    5     5 $ = @jQuery or window.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.1.0 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
   -1     4 @license Sticky-kit v1.1.1 | 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.1.0 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
   -1     2  Sticky-kit v1.1.1 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
    3     3 */
    4     4 (function(){var k,e;k=this.jQuery||window.jQuery;e=k(window);k.fn.stick_in_parent=function(d){var v,y,n,p,h,C,s,G,q,H;null==d&&(d={});s=d.sticky_class;y=d.inner_scrolling;C=d.recalc_every;h=d.parent;p=d.offset_top;n=d.spacer;v=d.bottoming;null==p&&(p=0);null==h&&(h=void 0);null==y&&(y=!0);null==s&&(s="is_stuck");null==v&&(v=!0);G=function(a,d,q,z,D,t,r,E){var u,F,m,A,c,f,B,w,x,g,b;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);f=a.parent();null!=h&&(f=f.closest(h));if(!f.length)throw"failed to find stick parent";
    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;if(!E&&(c=parseInt(f.css("border-top-width"),10),e=parseInt(f.css("padding-top"),10),d=parseInt(f.css("padding-bottom"),10),q=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)-p,t=a.outerHeight(!0),r=a.css("float"),g&&g.css({width:a.outerWidth(!0),

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

@@ -273,7 +273,10 @@ Note: only floated columns work in IE7.
  273   273 </h1>
  274   274 
  275   275 $markdown{[[
  276    -1   * **v1.1.0** - *Nov 13, 2014* --  Add `recalc_every`, `bottoming`, and
   -1   276   * **v1.1.1** - *Nov 23, 2014* -- Fix issue where tick/recalc could get called
   -1   277   after detach which would cause sticky element to be removed. Full height
   -1   278   calculation takes offset into account (johnwchadwick)
   -1   279   * **v1.1.0** - *Nov 13, 2014* -- Add `recalc_every`, `bottoming`, and
  277   280   `spacer` options. Fix bug where some events weren't getting removed on
  278   281   detach. Fixed bug where sticky class was not removed on detach (poziworld),
  279   282   pull `jQuery` from `window` if it can't be found on `this` (Connor Peet)

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.1.0"
   -1    12   @version = "1.1.1"
   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.5 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
   -1     4 @license Sticky-kit v1.1.1 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
    5     5  */
    6     6 
    7     7 (function() {
@@ -32,7 +32,7 @@
   32    32     if (enable_bottoming == null) {
   33    33       enable_bottoming = true;
   34    34     }
   35    -1     _fn = function(elm, padding_bottom, parent_top, parent_height, top, height, el_float) {
   -1    35     _fn = function(elm, padding_bottom, parent_top, parent_height, top, height, el_float, detached) {
   36    36       var bottomed, detach, fixed, last_pos, offset, parent, recalc, recalc_and_tick, recalc_counter, spacer, tick;
   37    37       if (elm.data("sticky_kit")) {
   38    38         return;
@@ -53,6 +53,9 @@
   53    53       }
   54    54       recalc = function() {
   55    55         var border_top, padding_top, restore;
   -1    56         if (detached) {
   -1    57           return;
   -1    58         }
   56    59         border_top = parseInt(parent.css("border-top-width"), 10);
   57    60         padding_top = parseInt(parent.css("padding-top"), 10);
   58    61         padding_bottom = parseInt(parent.css("padding-bottom"), 10);
@@ -98,6 +101,9 @@
   98   101       recalc_counter = recalc_every;
   99   102       tick = function() {
  100   103         var css, delta, scroll, will_bottom, win_height;
   -1   104         if (detached) {
   -1   105           return;
   -1   106         }
  101   107         if (recalc_counter != null) {
  102   108           recalc_counter -= 1;
  103   109           if (recalc_counter <= 0) {
@@ -140,7 +146,7 @@
  140   146           }
  141   147           if (inner_scrolling) {
  142   148             win_height = win.height();
  143    -1             if (height > win_height) {
   -1   149             if (height + offset_top > win_height) {
  144   150               if (!bottomed) {
  145   151                 offset -= delta;
  146   152                 offset = Math.max(win_height - height, offset);
@@ -195,6 +201,7 @@
  195   201         return tick();
  196   202       };
  197   203       detach = function() {
   -1   204         detached = true;
  198   205         win.off("touchmove", tick);
  199   206         win.off("scroll", tick);
  200   207         win.off("resize", recalc_and_tick);
@@ -204,7 +211,8 @@
  204   211         elm.css({
  205   212           position: "",
  206   213           bottom: "",
  207    -1           top: ""
   -1   214           top: "",
   -1   215           width: ""
  208   216         });
  209   217         parent.position("position", "");
  210   218         if (fixed) {

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

@@ -1,9 +1,9 @@
    1     1 /*
    2    -1  Sticky-kit v1.0.5 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
   -1     2  Sticky-kit v1.1.1 | WTFPL | Leaf Corcoran 2014 | http://leafo.net
    3     3 */
    4    -1 (function(){var k,e;k=this.jQuery||window.jQuery;e=k(window);k.fn.stick_in_parent=function(d){var w,y,n,r,h,C,s,F,p,G;null==d&&(d={});s=d.sticky_class;y=d.inner_scrolling;C=d.recalc_every;h=d.parent;r=d.offset_top;n=d.spacer;w=d.bottoming;null==r&&(r=0);null==h&&(h=void 0);null==y&&(y=!0);null==s&&(s="is_stuck");null==w&&(w=!0);F=function(a,d,p,z,D,t,q){var u,E,m,A,c,f,B,x,v,g,b;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);f=a.parent();null!=h&&(f=f.closest(h));if(!f.length)throw"failed to find stick parent";
    5    -1 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    -1 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,v=C,b=function(){var b,k,l,h;null!=v&&(v-=1,0>=v&&(v=C,B()));l=e.scrollTop();null!=A&&(k=l-A);A=l;m?(w&&(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    -1 (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&&w&&(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 x=function(){B();return b()},E=function(){e.off("touchmove",b);e.off("scroll",b);e.off("resize",x);k(document.body).off("sticky_kit:recalc",x);a.off("sticky_kit:detach",E);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:""});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",x),k(document.body).on("sticky_kit:recalc",x),a.on("sticky_kit:detach",E),setTimeout(b,0)}};p=
    9    -1 0;for(G=this.length;p<G;p++)d=this[p],F(k(d));return this}}).call(this);
   -1     4 (function(){var k,e;k=this.jQuery||window.jQuery;e=k(window);k.fn.stick_in_parent=function(d){var v,y,n,p,h,C,s,G,q,H;null==d&&(d={});s=d.sticky_class;y=d.inner_scrolling;C=d.recalc_every;h=d.parent;p=d.offset_top;n=d.spacer;v=d.bottoming;null==p&&(p=0);null==h&&(h=void 0);null==y&&(y=!0);null==s&&(s="is_stuck");null==v&&(v=!0);G=function(a,d,q,z,D,t,r,E){var u,F,m,A,c,f,B,w,x,g,b;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);f=a.parent();null!=h&&(f=f.closest(h));if(!f.length)throw"failed to find stick parent";
   -1     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;if(!E&&(c=parseInt(f.css("border-top-width"),10),e=parseInt(f.css("padding-top"),10),d=parseInt(f.css("padding-bottom"),10),q=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)-p,t=a.outerHeight(!0),r=a.css("float"),g&&g.css({width:a.outerWidth(!0),
   -1     6 height:t,display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":r}),l))return b()};B();if(t!==z)return A=void 0,c=p,x=C,b=function(){var b,k,l,h;if(!E&&(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+q,u&&!h&&(u=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom"))),l<D&&(m=!1,c=p,null==n&&("left"!==r&&"right"!==r||a.insertAfter(g),g.detach()),b={position:"",width:"",top:""},a.css(b).removeClass(s).trigger("sticky_kit:unstick")),
   -1     7 y&&(b=e.height(),t+p>b&&!u&&(c-=k,c=Math.max(b-t,c),c=Math.min(p,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"!==r&&"right"!==r||g.append(a)),a.trigger("sticky_kit:stick")),m&&v&&(null==h&&(h=l+t+c>z+q),!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")},
   -1     8 w=function(){B();return b()},F=function(){E=!0;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",F);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:"",width:""});f.position("position","");if(m)return null==n&&("left"!==r&&"right"!==r||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",F),setTimeout(b,
   -1     9 0)}};q=0;for(H=this.length;q<H;q++)d=this[q],G(k(d));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.1.0",
   -1     3   "version": "1.1.1",
    4     4 
    5     5   "title": "Sticky-kit",
    6     6   "homepage": "http://leafo.net/sticky-kit",