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.3.2 to 3.3.5

6

CHANGELOG.md

@@ -0,1 +1,7 @@

<a name="3.3.2"></a>
## [3.3.2](https://github.com/dollarshaveclub/stickybits/compare/3.3.1...3.3.2) (2018-05-05)
<a name="3.3.1"></a>

@@ -2,0 +8,0 @@ ## [3.3.1](https://github.com/dollarshaveclub/stickybits/compare/3.3.0...3.3.1) (2018-04-29)

4

dist/jquery.stickybits.min.js
/**
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills
@version v3.3.2
@version v3.3.5
@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 t=function(){function t(t,s){var e=void 0!==s?s:{};this.version="3.3.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:document.querySelector(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,verticalPosition:e.verticalPosition||"top"};var i=this.props;i.positionVal=this.definePosition()||"fixed";var n=i.verticalPosition,o=i.noStyles,a=i.positionVal;this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]),this.instances=[];for(var r=0;r<this.els.length;r+=1){var c=this.els[r],l=c.style;if(l[n]="top"!==n||o?"":i.stickyBitStickyOffset+"px",l.position="fixed"!==a?a:"","fixed"===a||i.useStickyClasses){var f=this.addInstance(c,i);this.instances.push(f)}}return this}var s=t.prototype;return s.definePosition=function(){for(var t=["","-o-","-webkit-","-moz-","-ms-"],s=document.head.style,e=0;e<t.length;e+=1)s.position=t[e]+"sticky";var i=s.position?s.position:"fixed";return s.position="",i},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.getOffsetTop=function(t){var s=0;do{s=t.offsetTop+s}while(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,a="bottom"!==e.verticalPosition,r=o?this.getOffsetTop(e.scrollEl):0,c=o?this.getOffsetTop(n)-r:this.getOffsetTop(n),l=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight;return s.offset=r+e.stickyBitStickyOffset,s.stickyStart=a?c-s.offset:0,s.stickyChange=s.stickyStart+l,s.stickyStop=a?c+n.offsetHeight-(s.el.offsetHeight+s.offset):c+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,a=s.stickyChange,r=s.stickyStop,c=e.style,l=i.noStyles,f=i.positionVal,u=i.scrollEl,p=i.stickyClass,h=i.stickyChangeClass,y=i.stuckClass,d=i.verticalPosition,k=function(t){t()},m=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||k,g=this.toggleClasses,v=this.isWin?window.scrollY||window.pageYOffset:u.scrollTop,C=v<=o&&"sticky"===n,w=v>=r&&"sticky"===n;v>o&&v<r&&("default"===n||"stuck"===n)?(s.state="sticky",m(function(){g(e,y,p),c.position=f,l||(c.bottom="",c[d]=i.stickyBitStickyOffset+"px")})):C?(s.state="default",m(function(){g(e,p),"fixed"===f&&(c.position="")})):w&&(s.state="stuck",m(function(){g(e,p,y),"fixed"!==f||l||(c.top="",c.bottom="0",c.position="absolute")}));var S=v>=a&&v<=r;return v<a||v>r?m(function(){g(e,h)}):S&&m(function(){g(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 s=window.$||window.jQuery||window.Zepto;s&&(s.fn.stickybits=function(s){new t(this,s)})}});
!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.3.5",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:document.querySelector(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,verticalPosition:e.verticalPosition||"top"};var i=this.props;i.positionVal=this.definePosition()||"fixed";var n=i.verticalPosition,o=i.noStyles,a=i.positionVal;this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]),this.instances=[];for(var r=0;r<this.els.length;r+=1){var c=this.els[r],l=c.style;if(l[n]="top"!==n||o?"":i.stickyBitStickyOffset+"px",l.position="fixed"!==a?a:"","fixed"===a||i.useStickyClasses){var f=this.addInstance(c,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.getOffsetTop=function(t){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,a="bottom"!==e.verticalPosition,r=o?this.getOffsetTop(e.scrollEl):0,c=o?this.getOffsetTop(n)-r:this.getOffsetTop(n),l=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight;return s.offset=r+e.stickyBitStickyOffset,s.stickyStart=a?c-s.offset:0,s.stickyChange=s.stickyStart+l,s.stickyStop=a?c+n.offsetHeight-(s.el.offsetHeight+s.offset):c+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,a=s.stickyChange,r=s.stickyStop,c=e.style,l=i.noStyles,f=i.positionVal,u=i.scrollEl,p=i.stickyClass,h=i.stickyChangeClass,y=i.stuckClass,d=i.verticalPosition,k=function(t){t()},m=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||k,g=this.toggleClasses,v=this.isWin?window.scrollY||window.pageYOffset:u.scrollTop,C=v<=o&&"sticky"===n,w=r<=v&&"sticky"===n;o<v&&v<r&&("default"===n||"stuck"===n)?(s.state="sticky",m(function(){g(e,y,p),c.position=f,l||(c.bottom="",c[d]=i.stickyBitStickyOffset+"px")})):C?(s.state="default",m(function(){g(e,p),"fixed"===f&&(c.position="")})):w&&(s.state="stuck",m(function(){g(e,p,y),"fixed"!==f||l||(c.top="",c.bottom="0",c.position="absolute")}));var S=a<=v&&v<=r;return v<a||r<v?m(function(){g(e,h)}):S&&m(function(){g(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){new s(this,t)})}});
/**
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills
@version v3.3.2
@version v3.3.5
@link https://github.com/dollarshaveclub/stickybits#readme

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

- useStickyClasses = boolean
- useFixed = boolean
- verticalPosition = 'string'

@@ -67,3 +68,3 @@ --------

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

@@ -80,2 +81,3 @@ this.props = {

useStickyClasses: o.useStickyClasses || false,
useFixed: o.useFixed || false,
verticalPosition: o.verticalPosition || 'top'

@@ -128,11 +130,18 @@ };

_proto.definePosition = function definePosition() {
var prefix = ['', '-o-', '-webkit-', '-moz-', '-ms-'];
var test = document.head.style;
var stickyProp;
for (var i = 0; i < prefix.length; i += 1) {
test.position = prefix[i] + "sticky";
if (this.props.useFixed) {
stickyProp = 'fixed';
} else {
var prefix = ['', '-o-', '-webkit-', '-moz-', '-ms-'];
var test = document.head.style;
for (var i = 0; i < prefix.length; i += 1) {
test.position = prefix[i] + "sticky";
}
stickyProp = test.position ? test.position : 'fixed';
test.position = '';
}
var stickyProp = test.position ? test.position : 'fixed';
test.position = '';
return stickyProp;

@@ -139,0 +148,0 @@ };

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

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

- useStickyClasses = boolean
- useFixed = boolean
- verticalPosition = 'string'

@@ -73,3 +74,3 @@ --------

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

@@ -86,2 +87,3 @@ this.props = {

useStickyClasses: o.useStickyClasses || false,
useFixed: o.useFixed || false,
verticalPosition: o.verticalPosition || 'top'

@@ -134,11 +136,18 @@ };

_proto.definePosition = function definePosition() {
var prefix = ['', '-o-', '-webkit-', '-moz-', '-ms-'];
var test = document.head.style;
var stickyProp;
for (var i = 0; i < prefix.length; i += 1) {
test.position = prefix[i] + "sticky";
if (this.props.useFixed) {
stickyProp = 'fixed';
} else {
var prefix = ['', '-o-', '-webkit-', '-moz-', '-ms-'];
var test = document.head.style;
for (var i = 0; i < prefix.length; i += 1) {
test.position = prefix[i] + "sticky";
}
stickyProp = test.position ? test.position : 'fixed';
test.position = '';
}
var stickyProp = test.position ? test.position : 'fixed';
test.position = '';
return stickyProp;

@@ -145,0 +154,0 @@ };

/**
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills
@version v3.3.2
@version v3.3.5
@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 t=function(){function t(t,s){var e=void 0!==s?s:{};this.version="3.3.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:document.querySelector(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,verticalPosition:e.verticalPosition||"top"};var i=this.props;i.positionVal=this.definePosition()||"fixed";var n=i.verticalPosition,o=i.noStyles,a=i.positionVal;this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]),this.instances=[];for(var r=0;r<this.els.length;r+=1){var l=this.els[r],c=l.style;if(c[n]="top"!==n||o?"":i.stickyBitStickyOffset+"px",c.position="fixed"!==a?a:"","fixed"===a||i.useStickyClasses){var f=this.addInstance(l,i);this.instances.push(f)}}return this}var s=t.prototype;return s.definePosition=function(){for(var t=["","-o-","-webkit-","-moz-","-ms-"],s=document.head.style,e=0;e<t.length;e+=1)s.position=t[e]+"sticky";var i=s.position?s.position:"fixed";return s.position="",i},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.getOffsetTop=function(t){var s=0;do{s=t.offsetTop+s}while(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,a="bottom"!==e.verticalPosition,r=o?this.getOffsetTop(e.scrollEl):0,l=o?this.getOffsetTop(n)-r:this.getOffsetTop(n),c=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight;return s.offset=r+e.stickyBitStickyOffset,s.stickyStart=a?l-s.offset:0,s.stickyChange=s.stickyStart+c,s.stickyStop=a?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,a=s.stickyChange,r=s.stickyStop,l=e.style,c=i.noStyles,f=i.positionVal,u=i.scrollEl,p=i.stickyClass,h=i.stickyChangeClass,y=i.stuckClass,d=i.verticalPosition,k=function(t){t()},m=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||k,g=this.toggleClasses,v=this.isWin?window.scrollY||window.pageYOffset:u.scrollTop,C=v<=o&&"sticky"===n,S=v>=r&&"sticky"===n;v>o&&v<r&&("default"===n||"stuck"===n)?(s.state="sticky",m(function(){g(e,y,p),l.position=f,c||(l.bottom="",l[d]=i.stickyBitStickyOffset+"px")})):C?(s.state="default",m(function(){g(e,p),"fixed"===f&&(l.position="")})):S&&(s.state="stuck",m(function(){g(e,p,y),"fixed"!==f||c||(l.top="",l.bottom="0",l.position="absolute")}));var w=v>=a&&v<=r;return v<a||v>r?m(function(){g(e,h)}):w&&m(function(){g(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(s,e){return new t(s,e)}});
!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.3.5",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:document.querySelector(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,verticalPosition:e.verticalPosition||"top"};var i=this.props;i.positionVal=this.definePosition()||"fixed";var n=i.verticalPosition,o=i.noStyles,a=i.positionVal;this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]),this.instances=[];for(var r=0;r<this.els.length;r+=1){var l=this.els[r],c=l.style;if(c[n]="top"!==n||o?"":i.stickyBitStickyOffset+"px",c.position="fixed"!==a?a:"","fixed"===a||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.getOffsetTop=function(t){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,a="bottom"!==e.verticalPosition,r=o?this.getOffsetTop(e.scrollEl):0,l=o?this.getOffsetTop(n)-r:this.getOffsetTop(n),c=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight;return s.offset=r+e.stickyBitStickyOffset,s.stickyStart=a?l-s.offset:0,s.stickyChange=s.stickyStart+c,s.stickyStop=a?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,a=s.stickyChange,r=s.stickyStop,l=e.style,c=i.noStyles,f=i.positionVal,u=i.scrollEl,p=i.stickyClass,h=i.stickyChangeClass,y=i.stuckClass,d=i.verticalPosition,k=function(t){t()},m=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||k,g=this.toggleClasses,v=this.isWin?window.scrollY||window.pageYOffset:u.scrollTop,C=v<=o&&"sticky"===n,S=r<=v&&"sticky"===n;o<v&&v<r&&("default"===n||"stuck"===n)?(s.state="sticky",m(function(){g(e,y,p),l.position=f,c||(l.bottom="",l[d]=i.stickyBitStickyOffset+"px")})):C?(s.state="default",m(function(){g(e,p),"fixed"===f&&(l.position="")})):S&&(s.state="stuck",m(function(){g(e,p,y),"fixed"!==f||c||(l.top="",l.bottom="0",l.position="absolute")}));var w=a<=v&&v<=r;return v<a||r<v?m(function(){g(e,h)}):w&&m(function(){g(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.3.2
@version v3.3.5
@link https://github.com/dollarshaveclub/stickybits#readme

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

- useStickyClasses = boolean
- useFixed = boolean
- verticalPosition = 'string'

@@ -73,3 +74,3 @@ --------

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

@@ -86,2 +87,3 @@ this.props = {

useStickyClasses: o.useStickyClasses || false,
useFixed: o.useFixed || false,
verticalPosition: o.verticalPosition || 'top'

@@ -134,11 +136,18 @@ };

_proto.definePosition = function definePosition() {
var prefix = ['', '-o-', '-webkit-', '-moz-', '-ms-'];
var test = document.head.style;
var stickyProp;
for (var i = 0; i < prefix.length; i += 1) {
test.position = prefix[i] + "sticky";
if (this.props.useFixed) {
stickyProp = 'fixed';
} else {
var prefix = ['', '-o-', '-webkit-', '-moz-', '-ms-'];
var test = document.head.style;
for (var i = 0; i < prefix.length; i += 1) {
test.position = prefix[i] + "sticky";
}
stickyProp = test.position ? test.position : 'fixed';
test.position = '';
}
var stickyProp = test.position ? test.position : 'fixed';
test.position = '';
return stickyProp;

@@ -145,0 +154,0 @@ };

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

@@ -58,19 +58,19 @@ "main": "dist/stickybits.js",

"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^22.4.1",
"codecov": "^3.0.0",
"conventional-changelog-cli": "^1.3.15",
"debug": "^3.0.0",
"es-check": "^2.0.0",
"eslint": "^4.18.1",
"eslint-config-dollarshaveclub": "^3.0.5",
"babel-jest": "^23.0.0",
"codecov": "^3.0.2",
"conventional-changelog-cli": "^2.0.0",
"debug": "^3.1.0",
"es-check": "^2.0.4",
"eslint": "^4.19.1",
"eslint-config-dollarshaveclub": "^3.1.0",
"jest": "^22.0.0",
"jquery": "^3.2.1",
"node-qunit-phantomjs": "^2.0.0",
"nyc": "^11.2.1",
"nyc": "^12.0.1",
"pre-commit": "^1.2.2",
"qunit": "^2.4.1",
"rollup": "0.58.2",
"qunit": "^2.6.1",
"rollup": "0.60.7",
"rollup-plugin-babel": "^4.0.0-beta.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^3.0.0"
"rollup-plugin-uglify": "^4.0.0"
},

@@ -77,0 +77,0 @@ "keywords": [

@@ -29,8 +29,8 @@ <p align="center">

**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).
- it loosely mimics [position: sticky](http://caniuse.com/#search=sticky) to consistently stick elements vertically across multiple platforms
- it does not have the _jumpiness_ that plugins that are built around `position: fixed` have because it tries to support `position: sticky` first.
- in its simplest use case, a `scroll` event listener will not be used if `position: sticky` is supported.
- it is super simple & lightweight
- it provides a [wiki](https://github.com/dollarshaveclub/stickybits/wiki) that digs deeply into fundementals of `position: sticky` and `position: fixed` and it works with them.
- 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).
- it loosely mimics [position: sticky](http://caniuse.com/#search=sticky) to consistently stick elements vertically across multiple platforms
- it does not have the _jumpiness_ that plugins that are built around `position: fixed` have because it tries to support `position: sticky` first.
- in its simplest use case, a `scroll` event listener will not be used if `position: sticky` is supported.
- it is super simple & lightweight
- it provides a [wiki](https://github.com/dollarshaveclub/stickybits/wiki) that digs deeply into fundementals of `position: sticky` and `position: fixed` and it works with them.

@@ -55,6 +55,9 @@ <hr />

yarn
```sh
yarn add stickybits
```
npm
```sh

@@ -136,2 +139,3 @@ npm i stickybits

```
\* **Note:** This selector is not selected automatically so the specific element need to be passed in.

@@ -197,3 +201,12 @@

### StickyBits useFixed
To not use `position: sticky` **ever**, add the following key value to a stickybit initalization..
parentClass:
```javascript
stickybits('selector', {useFixed: true});
```
To change all of the CSS classes

@@ -212,8 +225,9 @@ ```javascript

- [Basic Usage](https://codepen.io/yowainwright/pen/QdedaO)
- [Basic usage but with multiple instances of the same selector](https://codepen.io/yowainwright/pen/VPogaX)
- [Custom vertical top offset](https://codepen.io/yowainwright/pen/YQZPqR) ie: `stickybits('selector', {stickyBitStickyOffset: 20})`
- [UseStickyClasses](http://codepen.io/yowainwright/pen/NpzPGR) ie: `stickybits('selector', {useStickyClasses: true})`
- [Clean Stickybits](https://codepen.io/yowainwright/pen/gRgdep) ie: `const stickything = stickybits('selector'); stickything.cleanup();`
- [As a jQuery or Zepto Plugin](http://codepen.io/yowainwright/pen/57b852e88a644e9d919f843dc7b3b5f1) ie: `$('selector').stickybits();`
- [Basic Usage](https://codepen.io/yowainwright/pen/QdedaO)
- [Basic usage but with multiple instances of the same selector](https://codepen.io/yowainwright/pen/VPogaX)
- [Custom vertical top offset](https://codepen.io/yowainwright/pen/YQZPqR) ie: `stickybits('selector', {stickyBitStickyOffset: 20})`
- [UseStickyClasses](http://codepen.io/yowainwright/pen/NpzPGR) ie: `stickybits('selector', {useStickyClasses: true})`
- [Clean Stickybits](https://codepen.io/yowainwright/pen/gRgdep) ie: `const stickything = stickybits('selector'); stickything.cleanup();`
- [Use Fixed](https://codepen.io/yowainwright/pen/mKMzNb/) ie: `const stickything = stickybits('selector', {useFixed: true})`
- [As a jQuery or Zepto Plugin](http://codepen.io/yowainwright/pen/57b852e88a644e9d919f843dc7b3b5f1) ie: `$('selector').stickybits()`

@@ -224,7 +238,7 @@ ----

- [Custom vertical position (at bottom of parent element)](http://codepen.io/yowainwright/pen/e32cc7b82907ed9715a0a482ffa57596)
- [NoStyles Stickybits](https://codepen.io/yowainwright/pen/YrQpQj) ie: `stickybits('selector', {noStyles: true});`
- [With Custom Classes](https://codepen.io/yowainwright/pen/rGwWyW/) ie: `stickybits('selector', {parentClass: 'js-parent-test'})`
- [ScrollEl](https://codepen.io/yowainwright/pen/EXzJeb) ie: `stickybits('selector', {scrollEl: 'a-custom-scroll-el'})`
- If you have Stickybits examples, please submit an [issue](https://github.com/dollarshaveclub/stickybits/issues) with a link to it. πŸ™
- [Custom vertical position (at bottom of parent element)](http://codepen.io/yowainwright/pen/e32cc7b82907ed9715a0a482ffa57596)
- [NoStyles Stickybits](https://codepen.io/yowainwright/pen/YrQpQj) ie: `stickybits('selector', {noStyles: true});`
- [With Custom Classes](https://codepen.io/yowainwright/pen/rGwWyW/) ie: `stickybits('selector', {parentClass: 'js-parent-test'})`
- [ScrollEl](https://codepen.io/yowainwright/pen/EXzJeb) ie: `stickybits('selector', {scrollEl: 'a-custom-scroll-el'})`
- If you have Stickybits examples, please submit an [issue](https://github.com/dollarshaveclub/stickybits/issues) with a link to it. πŸ™

@@ -277,6 +291,6 @@ -----

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

@@ -283,0 +297,0 @@

@@ -24,2 +24,3 @@ /*

- useStickyClasses = boolean
- useFixed = boolean
- verticalPosition = 'string'

@@ -70,2 +71,3 @@ --------

useStickyClasses: o.useStickyClasses || false,
useFixed: o.useFixed || false,
verticalPosition: o.verticalPosition || 'top',

@@ -111,9 +113,14 @@ }

definePosition () {
const prefix = ['', '-o-', '-webkit-', '-moz-', '-ms-']
const test = document.head.style
for (let i = 0; i < prefix.length; i += 1) {
test.position = `${prefix[i]}sticky`
let stickyProp
if (this.props.useFixed) {
stickyProp = 'fixed'
} else {
const prefix = ['', '-o-', '-webkit-', '-moz-', '-ms-']
const test = document.head.style
for (let i = 0; i < prefix.length; i += 1) {
test.position = `${prefix[i]}sticky`
}
stickyProp = test.position ? test.position : 'fixed'
test.position = ''
}
const stickyProp = test.position ? test.position : 'fixed'
test.position = ''
return stickyProp

@@ -120,0 +127,0 @@ }

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