Socket
Socket
Sign inDemoInstall

stickybits

Package Overview
Dependencies
0
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.5.2 to 3.5.3

5

CHANGELOG.md

@@ -0,1 +1,6 @@

## [3.5.2](https://github.com/dollarshaveclub/stickybits/compare/3.5.1...3.5.2) (2018-08-26)
## [3.5.1](https://github.com/dollarshaveclub/stickybits/compare/3.5.0...3.5.1) (2018-08-25)

@@ -2,0 +7,0 @@

10

dist/jquery.stickybits.js
/**
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills
@version v3.5.2
@version v3.5.3
@link https://github.com/dollarshaveclub/stickybits#readme

@@ -74,3 +74,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in)

var o = typeof obj !== 'undefined' ? obj : {};
this.version = '3.5.2';
this.version = '3.5.3';
this.userAgent = window.navigator.userAgent || 'no `userAgent` provided by the browser';

@@ -234,6 +234,10 @@ this.props = {

_proto.getTopPosition = function getTopPosition(el) {
if (this.props.useGetBoundingClientRect) {
return el.getBoundingClientRect().top + (this.props.scrollEl.pageYOffset || document.documentElement.scrollTop);
}
var topPosition = 0;
do {
topPosition = this.props.useGetBoundingClientRect ? el.getBoundingClientRect().top + this.props.scrollEl.scrollY : topPosition = el.offsetTop + topPosition;
topPosition = el.offsetTop + topPosition;
} while (el = el.offsetParent);

@@ -240,0 +244,0 @@

/**
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills
@version v3.5.2
@version v3.5.3
@link https://github.com/dollarshaveclub/stickybits#readme

@@ -8,2 +8,2 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in)

**/
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s():"function"==typeof define&&define.amd?define(s):s()}(0,function(){"use strict";var s=function(){function t(t,s){var e=void 0!==s?s:{};this.version="3.5.2",this.userAgent=window.navigator.userAgent||"no `userAgent` provided by the browser",this.props={customStickyChangeNumber:e.customStickyChangeNumber||null,noStyles:e.noStyles||!1,stickyBitStickyOffset:e.stickyBitStickyOffset||0,parentClass:e.parentClass||"js-stickybit-parent",scrollEl:"string"==typeof e.scrollEl?document.querySelector(e.scrollEl):e.scrollEl||window,stickyClass:e.stickyClass||"js-is-sticky",stuckClass:e.stuckClass||"js-is-stuck",stickyChangeClass:e.stickyChangeClass||"js-is-sticky--change",useStickyClasses:e.useStickyClasses||!1,useFixed:e.useFixed||!1,useGetBoundingClientRect:e.useGetBoundingClientRect||!1,verticalPosition:e.verticalPosition||"top"};var i=this.props;i.positionVal=this.definePosition()||"fixed";var n=i.verticalPosition,o=i.noStyles,r=i.positionVal;this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]),this.instances=[];for(var a=0;a<this.els.length;a+=1){var l=this.els[a],c=l.style;if(c[n]="top"!==n||o?"":i.stickyBitStickyOffset+"px",c.position="fixed"!==r?r:"","fixed"===r||i.useStickyClasses){var f=this.addInstance(l,i);this.instances.push(f)}}return this}var s=t.prototype;return s.definePosition=function(){var t;if(this.props.useFixed)t="fixed";else{for(var s=["","-o-","-webkit-","-moz-","-ms-"],e=document.head.style,i=0;i<s.length;i+=1)e.position=s[i]+"sticky";t=e.position?e.position:"fixed",e.position=""}return t},s.addInstance=function(t,s){var e=this,i={el:t,parent:t.parentNode,props:s};this.isWin=this.props.scrollEl===window;var n=this.isWin?window:this.getClosestParent(i.el,i.props.scrollEl);return this.computeScrollOffsets(i),i.parent.className+=" "+s.parentClass,i.state="default",i.stateContainer=function(){return e.manageState(i)},n.addEventListener("scroll",i.stateContainer),i},s.getClosestParent=function(t,s){var e=s,i=t;if(i.parentElement===e)return e;for(;i.parentElement!==e;)i=i.parentElement;return e},s.getTopPosition=function(t){for(var s=0;s=this.props.useGetBoundingClientRect?t.getBoundingClientRect().top+this.props.scrollEl.scrollY:s=t.offsetTop+s,t=t.offsetParent;);return s},s.computeScrollOffsets=function(t){var s=t,e=s.props,i=s.el,n=s.parent,o=!this.isWin&&"fixed"===e.positionVal,r="bottom"!==e.verticalPosition,a=o?this.getTopPosition(e.scrollEl):0,l=o?this.getTopPosition(n)-a:this.getTopPosition(n),c=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight;return s.offset=a+e.stickyBitStickyOffset,s.stickyStart=r?l-s.offset:0,s.stickyChange=s.stickyStart+c,s.stickyStop=r?l+n.offsetHeight-(s.el.offsetHeight+s.offset):l+n.offsetHeight,s},s.toggleClasses=function(t,s,e){var i=t,n=i.className.split(" ");e&&-1===n.indexOf(e)&&n.push(e);var o=n.indexOf(s);-1!==o&&n.splice(o,1),i.className=n.join(" ")},s.manageState=function(t){var s=t,e=s.el,i=s.props,n=s.state,o=s.stickyStart,r=s.stickyChange,a=s.stickyStop,l=e.style,c=i.noStyles,f=i.positionVal,u=i.scrollEl,p=i.stickyClass,h=i.stickyChangeClass,d=i.stuckClass,y=i.verticalPosition,k=function(t){t()},g=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||k,m=this.toggleClasses,v=this.isWin?window.scrollY||window.pageYOffset:u.scrollTop,C=v<=o&&"sticky"===n,w=a<=v&&"sticky"===n;o<v&&v<a&&("default"===n||"stuck"===n)?(s.state="sticky",g(function(){m(e,d,p),l.position=f,c||(l.bottom="",l[y]=i.stickyBitStickyOffset+"px")})):C?(s.state="default",g(function(){m(e,p),"fixed"===f&&(l.position="")})):w&&(s.state="stuck",g(function(){m(e,p,d),"fixed"!==f||c||(l.top="",l.bottom="0",l.position="absolute")}));var S=r<=v&&v<=a;return v<r||a<v?g(function(){m(e,h)}):S&&g(function(){m(e,"stub",h)}),s},s.update=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];this.computeScrollOffsets(s)}return this},s.removeInstance=function(t){var s=t.el,e=t.props,i=this.toggleClasses;s.style.position="",s.style[e.verticalPosition]="",i(s,e.stickyClass),i(s,e.stuckClass),i(s.parentNode,e.parentClass)},s.cleanup=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];s.props.scrollEl.removeEventListener("scroll",s.stateContainer),this.removeInstance(s)}this.manageState=!1,this.instances=[]},t}();if("undefined"!=typeof window){var t=window.$||window.jQuery||window.Zepto;t&&(t.fn.stickybits=function(t){return new s(this,t)})}});
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s():"function"==typeof define&&define.amd?define(s):s()}(0,function(){"use strict";var s=function(){function t(t,s){var e=void 0!==s?s:{};this.version="3.5.3",this.userAgent=window.navigator.userAgent||"no `userAgent` provided by the browser",this.props={customStickyChangeNumber:e.customStickyChangeNumber||null,noStyles:e.noStyles||!1,stickyBitStickyOffset:e.stickyBitStickyOffset||0,parentClass:e.parentClass||"js-stickybit-parent",scrollEl:"string"==typeof e.scrollEl?document.querySelector(e.scrollEl):e.scrollEl||window,stickyClass:e.stickyClass||"js-is-sticky",stuckClass:e.stuckClass||"js-is-stuck",stickyChangeClass:e.stickyChangeClass||"js-is-sticky--change",useStickyClasses:e.useStickyClasses||!1,useFixed:e.useFixed||!1,useGetBoundingClientRect:e.useGetBoundingClientRect||!1,verticalPosition:e.verticalPosition||"top"};var i=this.props;i.positionVal=this.definePosition()||"fixed";var n=i.verticalPosition,o=i.noStyles,r=i.positionVal;this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]),this.instances=[];for(var a=0;a<this.els.length;a+=1){var l=this.els[a],c=l.style;if(c[n]="top"!==n||o?"":i.stickyBitStickyOffset+"px",c.position="fixed"!==r?r:"","fixed"===r||i.useStickyClasses){var f=this.addInstance(l,i);this.instances.push(f)}}return this}var s=t.prototype;return s.definePosition=function(){var t;if(this.props.useFixed)t="fixed";else{for(var s=["","-o-","-webkit-","-moz-","-ms-"],e=document.head.style,i=0;i<s.length;i+=1)e.position=s[i]+"sticky";t=e.position?e.position:"fixed",e.position=""}return t},s.addInstance=function(t,s){var e=this,i={el:t,parent:t.parentNode,props:s};this.isWin=this.props.scrollEl===window;var n=this.isWin?window:this.getClosestParent(i.el,i.props.scrollEl);return this.computeScrollOffsets(i),i.parent.className+=" "+s.parentClass,i.state="default",i.stateContainer=function(){return e.manageState(i)},n.addEventListener("scroll",i.stateContainer),i},s.getClosestParent=function(t,s){var e=s,i=t;if(i.parentElement===e)return e;for(;i.parentElement!==e;)i=i.parentElement;return e},s.getTopPosition=function(t){if(this.props.useGetBoundingClientRect)return t.getBoundingClientRect().top+(this.props.scrollEl.pageYOffset||document.documentElement.scrollTop);for(var s=0;s=t.offsetTop+s,t=t.offsetParent;);return s},s.computeScrollOffsets=function(t){var s=t,e=s.props,i=s.el,n=s.parent,o=!this.isWin&&"fixed"===e.positionVal,r="bottom"!==e.verticalPosition,a=o?this.getTopPosition(e.scrollEl):0,l=o?this.getTopPosition(n)-a:this.getTopPosition(n),c=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight;return s.offset=a+e.stickyBitStickyOffset,s.stickyStart=r?l-s.offset:0,s.stickyChange=s.stickyStart+c,s.stickyStop=r?l+n.offsetHeight-(s.el.offsetHeight+s.offset):l+n.offsetHeight,s},s.toggleClasses=function(t,s,e){var i=t,n=i.className.split(" ");e&&-1===n.indexOf(e)&&n.push(e);var o=n.indexOf(s);-1!==o&&n.splice(o,1),i.className=n.join(" ")},s.manageState=function(t){var s=t,e=s.el,i=s.props,n=s.state,o=s.stickyStart,r=s.stickyChange,a=s.stickyStop,l=e.style,c=i.noStyles,f=i.positionVal,u=i.scrollEl,p=i.stickyClass,h=i.stickyChangeClass,d=i.stuckClass,y=i.verticalPosition,k=function(t){t()},g=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||k,m=this.toggleClasses,v=this.isWin?window.scrollY||window.pageYOffset:u.scrollTop,C=v<=o&&"sticky"===n,w=a<=v&&"sticky"===n;o<v&&v<a&&("default"===n||"stuck"===n)?(s.state="sticky",g(function(){m(e,d,p),l.position=f,c||(l.bottom="",l[y]=i.stickyBitStickyOffset+"px")})):C?(s.state="default",g(function(){m(e,p),"fixed"===f&&(l.position="")})):w&&(s.state="stuck",g(function(){m(e,p,d),"fixed"!==f||c||(l.top="",l.bottom="0",l.position="absolute")}));var S=r<=v&&v<=a;return v<r||a<v?g(function(){m(e,h)}):S&&g(function(){m(e,"stub",h)}),s},s.update=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];this.computeScrollOffsets(s)}return this},s.removeInstance=function(t){var s=t.el,e=t.props,i=this.toggleClasses;s.style.position="",s.style[e.verticalPosition]="",i(s,e.stickyClass),i(s,e.stuckClass),i(s.parentNode,e.parentClass)},s.cleanup=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];s.props.scrollEl.removeEventListener("scroll",s.stateContainer),this.removeInstance(s)}this.manageState=!1,this.instances=[]},t}();if("undefined"!=typeof window){var t=window.$||window.jQuery||window.Zepto;t&&(t.fn.stickybits=function(t){return new s(this,t)})}});
/**
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills
@version v3.5.2
@version v3.5.3
@link https://github.com/dollarshaveclub/stickybits#readme

@@ -68,3 +68,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in)

var o = typeof obj !== 'undefined' ? obj : {};
this.version = '3.5.2';
this.version = '3.5.3';
this.userAgent = window.navigator.userAgent || 'no `userAgent` provided by the browser';

@@ -228,6 +228,10 @@ this.props = {

_proto.getTopPosition = function getTopPosition(el) {
if (this.props.useGetBoundingClientRect) {
return el.getBoundingClientRect().top + (this.props.scrollEl.pageYOffset || document.documentElement.scrollTop);
}
var topPosition = 0;
do {
topPosition = this.props.useGetBoundingClientRect ? el.getBoundingClientRect().top + this.props.scrollEl.scrollY : topPosition = el.offsetTop + topPosition;
topPosition = el.offsetTop + topPosition;
} while (el = el.offsetParent);

@@ -234,0 +238,0 @@

/**
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills
@version v3.5.2
@version v3.5.3
@link https://github.com/dollarshaveclub/stickybits#readme

@@ -74,3 +74,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in)

var o = typeof obj !== 'undefined' ? obj : {};
this.version = '3.5.2';
this.version = '3.5.3';
this.userAgent = window.navigator.userAgent || 'no `userAgent` provided by the browser';

@@ -234,6 +234,10 @@ this.props = {

_proto.getTopPosition = function getTopPosition(el) {
if (this.props.useGetBoundingClientRect) {
return el.getBoundingClientRect().top + (this.props.scrollEl.pageYOffset || document.documentElement.scrollTop);
}
var topPosition = 0;
do {
topPosition = this.props.useGetBoundingClientRect ? el.getBoundingClientRect().top + this.props.scrollEl.scrollY : topPosition = el.offsetTop + topPosition;
topPosition = el.offsetTop + topPosition;
} while (el = el.offsetParent);

@@ -240,0 +244,0 @@

/**
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills
@version v3.5.2
@version v3.5.3
@link https://github.com/dollarshaveclub/stickybits#readme

@@ -8,2 +8,2 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in)

**/
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):t.stickybits=s()}(this,function(){"use strict";var e=function(){function t(t,s){var e=void 0!==s?s:{};this.version="3.5.2",this.userAgent=window.navigator.userAgent||"no `userAgent` provided by the browser",this.props={customStickyChangeNumber:e.customStickyChangeNumber||null,noStyles:e.noStyles||!1,stickyBitStickyOffset:e.stickyBitStickyOffset||0,parentClass:e.parentClass||"js-stickybit-parent",scrollEl:"string"==typeof e.scrollEl?document.querySelector(e.scrollEl):e.scrollEl||window,stickyClass:e.stickyClass||"js-is-sticky",stuckClass:e.stuckClass||"js-is-stuck",stickyChangeClass:e.stickyChangeClass||"js-is-sticky--change",useStickyClasses:e.useStickyClasses||!1,useFixed:e.useFixed||!1,useGetBoundingClientRect:e.useGetBoundingClientRect||!1,verticalPosition:e.verticalPosition||"top"};var i=this.props;i.positionVal=this.definePosition()||"fixed";var n=i.verticalPosition,o=i.noStyles,r=i.positionVal;this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]),this.instances=[];for(var a=0;a<this.els.length;a+=1){var l=this.els[a],c=l.style;if(c[n]="top"!==n||o?"":i.stickyBitStickyOffset+"px",c.position="fixed"!==r?r:"","fixed"===r||i.useStickyClasses){var u=this.addInstance(l,i);this.instances.push(u)}}return this}var s=t.prototype;return s.definePosition=function(){var t;if(this.props.useFixed)t="fixed";else{for(var s=["","-o-","-webkit-","-moz-","-ms-"],e=document.head.style,i=0;i<s.length;i+=1)e.position=s[i]+"sticky";t=e.position?e.position:"fixed",e.position=""}return t},s.addInstance=function(t,s){var e=this,i={el:t,parent:t.parentNode,props:s};this.isWin=this.props.scrollEl===window;var n=this.isWin?window:this.getClosestParent(i.el,i.props.scrollEl);return this.computeScrollOffsets(i),i.parent.className+=" "+s.parentClass,i.state="default",i.stateContainer=function(){return e.manageState(i)},n.addEventListener("scroll",i.stateContainer),i},s.getClosestParent=function(t,s){var e=s,i=t;if(i.parentElement===e)return e;for(;i.parentElement!==e;)i=i.parentElement;return e},s.getTopPosition=function(t){for(var s=0;s=this.props.useGetBoundingClientRect?t.getBoundingClientRect().top+this.props.scrollEl.scrollY:s=t.offsetTop+s,t=t.offsetParent;);return s},s.computeScrollOffsets=function(t){var s=t,e=s.props,i=s.el,n=s.parent,o=!this.isWin&&"fixed"===e.positionVal,r="bottom"!==e.verticalPosition,a=o?this.getTopPosition(e.scrollEl):0,l=o?this.getTopPosition(n)-a:this.getTopPosition(n),c=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight;return s.offset=a+e.stickyBitStickyOffset,s.stickyStart=r?l-s.offset:0,s.stickyChange=s.stickyStart+c,s.stickyStop=r?l+n.offsetHeight-(s.el.offsetHeight+s.offset):l+n.offsetHeight,s},s.toggleClasses=function(t,s,e){var i=t,n=i.className.split(" ");e&&-1===n.indexOf(e)&&n.push(e);var o=n.indexOf(s);-1!==o&&n.splice(o,1),i.className=n.join(" ")},s.manageState=function(t){var s=t,e=s.el,i=s.props,n=s.state,o=s.stickyStart,r=s.stickyChange,a=s.stickyStop,l=e.style,c=i.noStyles,u=i.positionVal,f=i.scrollEl,p=i.stickyClass,h=i.stickyChangeClass,y=i.stuckClass,d=i.verticalPosition,k=function(t){t()},g=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||k,m=this.toggleClasses,v=this.isWin?window.scrollY||window.pageYOffset:f.scrollTop,C=v<=o&&"sticky"===n,S=a<=v&&"sticky"===n;o<v&&v<a&&("default"===n||"stuck"===n)?(s.state="sticky",g(function(){m(e,y,p),l.position=u,c||(l.bottom="",l[d]=i.stickyBitStickyOffset+"px")})):C?(s.state="default",g(function(){m(e,p),"fixed"===u&&(l.position="")})):S&&(s.state="stuck",g(function(){m(e,p,y),"fixed"!==u||c||(l.top="",l.bottom="0",l.position="absolute")}));var w=r<=v&&v<=a;return v<r||a<v?g(function(){m(e,h)}):w&&g(function(){m(e,"stub",h)}),s},s.update=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];this.computeScrollOffsets(s)}return this},s.removeInstance=function(t){var s=t.el,e=t.props,i=this.toggleClasses;s.style.position="",s.style[e.verticalPosition]="",i(s,e.stickyClass),i(s,e.stuckClass),i(s.parentNode,e.parentClass)},s.cleanup=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];s.props.scrollEl.removeEventListener("scroll",s.stateContainer),this.removeInstance(s)}this.manageState=!1,this.instances=[]},t}();return function(t,s){return new e(t,s)}});
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):t.stickybits=s()}(this,function(){"use strict";var e=function(){function t(t,s){var e=void 0!==s?s:{};this.version="3.5.3",this.userAgent=window.navigator.userAgent||"no `userAgent` provided by the browser",this.props={customStickyChangeNumber:e.customStickyChangeNumber||null,noStyles:e.noStyles||!1,stickyBitStickyOffset:e.stickyBitStickyOffset||0,parentClass:e.parentClass||"js-stickybit-parent",scrollEl:"string"==typeof e.scrollEl?document.querySelector(e.scrollEl):e.scrollEl||window,stickyClass:e.stickyClass||"js-is-sticky",stuckClass:e.stuckClass||"js-is-stuck",stickyChangeClass:e.stickyChangeClass||"js-is-sticky--change",useStickyClasses:e.useStickyClasses||!1,useFixed:e.useFixed||!1,useGetBoundingClientRect:e.useGetBoundingClientRect||!1,verticalPosition:e.verticalPosition||"top"};var i=this.props;i.positionVal=this.definePosition()||"fixed";var n=i.verticalPosition,o=i.noStyles,r=i.positionVal;this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]),this.instances=[];for(var a=0;a<this.els.length;a+=1){var l=this.els[a],c=l.style;if(c[n]="top"!==n||o?"":i.stickyBitStickyOffset+"px",c.position="fixed"!==r?r:"","fixed"===r||i.useStickyClasses){var u=this.addInstance(l,i);this.instances.push(u)}}return this}var s=t.prototype;return s.definePosition=function(){var t;if(this.props.useFixed)t="fixed";else{for(var s=["","-o-","-webkit-","-moz-","-ms-"],e=document.head.style,i=0;i<s.length;i+=1)e.position=s[i]+"sticky";t=e.position?e.position:"fixed",e.position=""}return t},s.addInstance=function(t,s){var e=this,i={el:t,parent:t.parentNode,props:s};this.isWin=this.props.scrollEl===window;var n=this.isWin?window:this.getClosestParent(i.el,i.props.scrollEl);return this.computeScrollOffsets(i),i.parent.className+=" "+s.parentClass,i.state="default",i.stateContainer=function(){return e.manageState(i)},n.addEventListener("scroll",i.stateContainer),i},s.getClosestParent=function(t,s){var e=s,i=t;if(i.parentElement===e)return e;for(;i.parentElement!==e;)i=i.parentElement;return e},s.getTopPosition=function(t){if(this.props.useGetBoundingClientRect)return t.getBoundingClientRect().top+(this.props.scrollEl.pageYOffset||document.documentElement.scrollTop);for(var s=0;s=t.offsetTop+s,t=t.offsetParent;);return s},s.computeScrollOffsets=function(t){var s=t,e=s.props,i=s.el,n=s.parent,o=!this.isWin&&"fixed"===e.positionVal,r="bottom"!==e.verticalPosition,a=o?this.getTopPosition(e.scrollEl):0,l=o?this.getTopPosition(n)-a:this.getTopPosition(n),c=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight;return s.offset=a+e.stickyBitStickyOffset,s.stickyStart=r?l-s.offset:0,s.stickyChange=s.stickyStart+c,s.stickyStop=r?l+n.offsetHeight-(s.el.offsetHeight+s.offset):l+n.offsetHeight,s},s.toggleClasses=function(t,s,e){var i=t,n=i.className.split(" ");e&&-1===n.indexOf(e)&&n.push(e);var o=n.indexOf(s);-1!==o&&n.splice(o,1),i.className=n.join(" ")},s.manageState=function(t){var s=t,e=s.el,i=s.props,n=s.state,o=s.stickyStart,r=s.stickyChange,a=s.stickyStop,l=e.style,c=i.noStyles,u=i.positionVal,f=i.scrollEl,p=i.stickyClass,h=i.stickyChangeClass,d=i.stuckClass,y=i.verticalPosition,k=function(t){t()},g=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||k,m=this.toggleClasses,v=this.isWin?window.scrollY||window.pageYOffset:f.scrollTop,C=v<=o&&"sticky"===n,S=a<=v&&"sticky"===n;o<v&&v<a&&("default"===n||"stuck"===n)?(s.state="sticky",g(function(){m(e,d,p),l.position=u,c||(l.bottom="",l[y]=i.stickyBitStickyOffset+"px")})):C?(s.state="default",g(function(){m(e,p),"fixed"===u&&(l.position="")})):S&&(s.state="stuck",g(function(){m(e,p,d),"fixed"!==u||c||(l.top="",l.bottom="0",l.position="absolute")}));var w=r<=v&&v<=a;return v<r||a<v?g(function(){m(e,h)}):w&&g(function(){m(e,"stub",h)}),s},s.update=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];this.computeScrollOffsets(s)}return this},s.removeInstance=function(t){var s=t.el,e=t.props,i=this.toggleClasses;s.style.position="",s.style[e.verticalPosition]="",i(s,e.stickyClass),i(s,e.stuckClass),i(s.parentNode,e.parentClass)},s.cleanup=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];s.props.scrollEl.removeEventListener("scroll",s.stateContainer),this.removeInstance(s)}this.manageState=!1,this.instances=[]},t}();return function(t,s){return new e(t,s)}});
/**
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills
@version v3.5.2
@version v3.5.3
@link https://github.com/dollarshaveclub/stickybits#readme

@@ -74,3 +74,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in)

var o = typeof obj !== 'undefined' ? obj : {};
this.version = '3.5.2';
this.version = '3.5.3';
this.userAgent = window.navigator.userAgent || 'no `userAgent` provided by the browser';

@@ -234,6 +234,10 @@ this.props = {

_proto.getTopPosition = function getTopPosition(el) {
if (this.props.useGetBoundingClientRect) {
return el.getBoundingClientRect().top + (this.props.scrollEl.pageYOffset || document.documentElement.scrollTop);
}
var topPosition = 0;
do {
topPosition = this.props.useGetBoundingClientRect ? el.getBoundingClientRect().top + this.props.scrollEl.scrollY : topPosition = el.offsetTop + topPosition;
topPosition = el.offsetTop + topPosition;
} while (el = el.offsetParent);

@@ -240,0 +244,0 @@

{
"name": "stickybits",
"version": "3.5.2",
"version": "3.5.3",
"description": "Stickybits is a lightweight alternative to `position: sticky` polyfills",

@@ -14,7 +14,12 @@ "main": "dist/stickybits.js",

"lint:ci": "eslint .",
"chore:delete-branch": "if git show-ref --quiet refs/heads/chore-changelog; then git branch -D chore-changelog; fi",
"chore:delete-changelog-branch": "if git show-ref --quiet refs/heads/chore-changelog; then git branch -D chore-changelog; fi",
"chore:branch": "git checkout -b chore-changelog",
"chore:changelog": "conventional-changelog -p eslint -i CHANGELOG.md -s -r 0",
"chore:setup-next-work": "git checkout master && npm run chore:delete-changelog-branch",
"chore:pr": "git add . && git commit -m '[chore] updates changelog' --no-verify && git push origin chore-changelog -f",
"chore": "npm run chore:delete-branch && npm run chore:branch && npm run chore:changelog && npm run chore:pr",
"chore:setup-changelog": "git checkout master && git pull",
"chore": "npm run chore:delete-changelog-branch && npm run chore:branch && npm run chore:changelog && npm run chore:pr && npm run chore:setup-next-work",
"grammar": "write-good *.md --no-passive",
"markdownlint": "markdownlint *.md",
"prepush": "npm run build && npm test",
"pre-commit-msg": "Echo 'Running pre-commit checks...' && exit 0",

@@ -24,6 +29,9 @@ "postpublish": "git tag $npm_package_version && git push origin --tags && npm run chore",

"report:coverage": "nyc report --reporter=lcov > coverage.lcov && codecov",
"spelling": "mdspell '**/*.md' '!**/node_modules/**/*.md' --ignore-numbers",
"spelling:ci": "mdspell '**/*.md' '!**/node_modules/**/*.md' --ignore-numbers --report",
"start": "npm i",
"test:es-check": "es-check es5 dist/stickybits.min.js dist/stickybits.js dist/jquery.stickybits.js dist/jquery.stickybits.min.js dist/umbrella.stickybits.js dist/umbrella.stickybits.min.js",
"test:unit": "jest --coverage",
"test:acceptance": "node ./scripts/acceptance.js --coverage",
"test": "npm run test:unit && npm run test:acceptance"
"test": "npm run markdownlint && npm run test:unit && npm run test:acceptance"
},

@@ -33,10 +41,2 @@ "jest": {

},
"pre-commit": {
"run": [
"pre-commit-msg",
"build",
"lint",
"test"
]
},
"bugs": {

@@ -69,7 +69,9 @@ "url": "https://github.com/dollarshaveclub/stickybits/issues"

"eslint-config-dollarshaveclub": "^3.1.0",
"husky": "^0.14.3",
"jest": "^22.0.0",
"jquery": "^3.2.1",
"markdown-spellcheck": "^1.3.1",
"markdownlint-cli": "^0.13.0",
"node-qunit-phantomjs": "^2.0.0",
"nyc": "^12.0.1",
"pre-commit": "^1.2.2",
"qunit": "^2.6.1",

@@ -79,3 +81,4 @@ "rollup": "0.65.0",

"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^4.0.0"
"rollup-plugin-uglify": "^4.0.0",
"write-good": "^0.13.1"
},

@@ -82,0 +85,0 @@ "keywords": [

@@ -28,3 +28,4 @@ <p align="center">

**Stickybits is awesome because:**
#### Stickybits is awesome because
- it can add a CSS Sticky Class (`.js-is-sticky`) when [position: sticky](http://caniuse.com/#search=sticky) elements become active and a CSS Stuck Class (`.js-is-stuck`) when they become stuck. See [useStickyClasses](#feature).

@@ -37,5 +38,6 @@ - it loosely mimics [position: sticky](http://caniuse.com/#search=sticky) to consistently stick elements vertically across multiple platforms

<hr />
----
<p align="center">
<a href="#install">Installation</a>&nbsp;&nbsp;
<a href="#installing-from-a-package-manager">Installation</a>&nbsp;&nbsp;
<a href="#setup">Setup</a>&nbsp;&nbsp;

@@ -51,10 +53,13 @@ <a href="#usage">Usage</a>&nbsp;&nbsp;

</p>
<hr />
<h2 id="install">Installing from a package manager</h2>
----
## Installing from a package manager
yarn
```sh
yarn add stickybits
```

@@ -65,6 +70,8 @@

```sh
npm i stickybits
```
<h2 id="setup">Setup</h2>
## Setup

@@ -78,6 +85,8 @@ Add **dist/stickybits.min.js**

```javascript
stickybits('selector');
```
#### By default, a selected stickybits element will
### By default, a selected stickybits element will

@@ -87,3 +96,3 @@ - Stick elements to the top of the viewport when scrolled to vertically.

---
----

@@ -100,3 +109,3 @@ **Key Note:** Stickybits expects and works best when the element that will become sticky is wrapped within a parent element that defines when the element starts being sticky and stops being sticky. See below for visual reference.

---
----

@@ -116,3 +125,5 @@ <h2 id="feature"><code>useStickyClasses</code> Feature</h2>

```javascript
stickybits('selector', {useStickyClasses: true});
```

@@ -123,2 +134,3 @@

```css
.some-sticky-element.js-is-sticky {

@@ -133,2 +145,3 @@ background-color: red;

}
```

@@ -138,3 +151,3 @@

<h2 id="options">Options</h2>
## Options

@@ -150,3 +163,5 @@ ### Vertical Layout Position

```javascript
stickybits('selector', {verticalPosition: 'bottom'});
```

@@ -161,3 +176,5 @@

```javascript
stickybits('selector', {scrollEl: 'an-id'});
```

@@ -172,3 +189,5 @@

```javascript
stickybits('selector', {stickyBitStickyOffset: 20});
```

@@ -181,4 +200,6 @@

```javascript
const stickybitsInstancetoBeCleanedup = stickybits('selector');
stickybitsInstancetoBeCleanedup.cleanup();
```

@@ -191,4 +212,6 @@

```javascript
const stickybitsInstancetoBeUpdated = stickybits('selector');
stickybitsInstancetoBeUpdated.update();
```

@@ -199,4 +222,6 @@

**Examples**
#### More Stickybits Update Examples
```javascript
// when the window is resized

@@ -211,2 +236,3 @@ const stickybitsInstancetoBeUpdated = stickybits('selector');

});
```

@@ -221,3 +247,5 @@

```javascript
stickybits('selector', {noStyles: true});
```

@@ -232,3 +260,5 @@

```javascript
stickybits('selector', {parentClass: 'new-parent-classname'});
```

@@ -239,3 +269,5 @@

```javascript
stickybits('selector', {stickyClass: 'new-sticky-classname'});
```

@@ -246,3 +278,5 @@

```javascript
stickybits('selector', {stuckClass: 'new-stuck-classname'});
```

@@ -257,7 +291,11 @@

```javascript
stickybits('selector', {useFixed: true});
```
To change all of the CSS classes
```javascript
stickybits('selector', {

@@ -269,2 +307,3 @@ parentClass: 'new-parent-classname',

});
```

@@ -278,3 +317,5 @@

```javascript
stickybits('selector', {useGetBoundingClientRect: true});
```

@@ -284,3 +325,3 @@

<h2 id="examples">Examples</h2>
## Examples

@@ -299,3 +340,3 @@ - [Basic Usage](https://codepen.io/yowainwright/pen/QdedaO)

### Examples extended
### Extended Examples

@@ -308,7 +349,7 @@ - [Custom vertical position (at bottom of parent element)](http://codepen.io/yowainwright/pen/e32cc7b82907ed9715a0a482ffa57596)

-----
----
Have another example or question? Feel free to [comment](https://github.com/dollarshaveclub/stickybits/issues). πŸ™Œ
<h2 id="notes">Notes</h2>
## Notes

@@ -335,3 +376,3 @@ ### CSS Class Usage

<h3 id="jquery">jQuery and Zepto Usage</h3>
### jQuery and Zepto Usage

@@ -341,3 +382,5 @@ Basic

```javascript
$('selector').stickybits();
```

@@ -348,2 +391,3 @@

```javascript
$('selector').stickybits({scrollEl: '#scrollEl'});

@@ -355,2 +399,3 @@

$('selector').stickybits({scrollEl: el});
```

@@ -361,4 +406,6 @@

```javascript
var instance = $('selector').stickybits();
const instance = $('selector').stickybits();
instance.update();
```

@@ -369,3 +416,5 @@

```javascript
$('selector').stickybits({useStickyClasses: true});
```

@@ -376,3 +425,5 @@

```javascript
$('selector').stickybits({verticalPosition: 'bottom'});
```

@@ -383,3 +434,5 @@

```javascript
$('selector').stickybits({stickyBitStickyOffset: 20});
```

@@ -392,5 +445,8 @@

To view the Stickybits API in it's simpliest form:
```javascript
var stickybit = stickybits('a selection')
console.log(stickybit)
const stickybit = stickybits('a selection');
console.log(stickybit);
```

@@ -400,3 +456,3 @@

---
----

@@ -410,5 +466,7 @@ ### Utility properties

```javascript
var stickybit = stickybits('a selection')
const stickybit = stickybits('a selection')
stickybit.version // will show the version of stickybits being used
stickybit.userAgent // will show which userAgent stickybits is detecting
```

@@ -415,0 +473,0 @@

@@ -195,7 +195,8 @@ /*

getTopPosition (el) {
if (this.props.useGetBoundingClientRect) {
return el.getBoundingClientRect().top + (this.props.scrollEl.pageYOffset || document.documentElement.scrollTop)
}
let topPosition = 0
do {
topPosition = this.props.useGetBoundingClientRect
? (el.getBoundingClientRect().top + this.props.scrollEl.scrollY)
: (topPosition = el.offsetTop + topPosition)
topPosition = el.offsetTop + topPosition
} while ((el = el.offsetParent))

@@ -202,0 +203,0 @@ return topPosition

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc