Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

stickybits

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stickybits - npm Package Compare versions

Comparing version 3.7.1 to 3.7.2

5

CHANGELOG.md

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

## [3.7.1](https://github.com/dollarshaveclub/stickybits/compare/3.7.0...3.7.1) (2019-12-05)
# [3.7.0](https://github.com/dollarshaveclub/stickybits/compare/3.6.8...3.7.0) (2019-11-08)

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

48

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

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

function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
/*

@@ -76,3 +94,3 @@ STICKYBITS πŸ’‰

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

@@ -312,2 +330,4 @@ this.props = {

_proto.manageState = function manageState(item) {
var _this3 = this;
// cache object

@@ -383,3 +403,3 @@ var it = item;

rAF(function () {
var _styles2, _classes, _styles3, _styles4, _classes2, _style$classes;
var _styles2, _classes, _styles3, _extends2, _classes2, _style$classes;

@@ -400,7 +420,7 @@ var stateStyles = {

stuck: {
styles: (_styles4 = {
styles: _extends((_extends2 = {}, _extends2[vp] = '', _extends2), pv === 'fixed' || !_this3.isWin ? {
position: 'absolute',
top: '',
bottom: '0'
}, _styles4[vp] = '', _styles4),
} : {}),
classes: (_classes2 = {}, _classes2[stuck] = true, _classes2)

@@ -451,10 +471,6 @@ }

e.className = cArray.join(' '); // eslint-disable-next-line no-unused-vars
e.className = cArray.join(' ');
if (ns) return; // eslint-disable-next-line no-unused-vars
for (var key in styles) {
if (ns && key === 'position') {
stl[key] = styles[key];
return;
}
stl[key] = styles[key];

@@ -465,3 +481,3 @@ }

_proto.update = function update(updatedProps) {
var _this3 = this;
var _this4 = this;

@@ -473,3 +489,3 @@ if (updatedProps === void 0) {

this.instances.forEach(function (instance) {
_this3.computeScrollOffsets(instance);
_this4.computeScrollOffsets(instance);

@@ -493,3 +509,3 @@ if (updatedProps) {

_proto.removeInstance = function removeInstance(instance) {
var _styles5, _classes3;
var _styles4, _classes3;

@@ -499,5 +515,5 @@ var e = instance.el;

this.applyStyle({
styles: (_styles5 = {
styles: (_styles4 = {
position: ''
}, _styles5[p.verticalPosition] = '', _styles5),
}, _styles4[p.verticalPosition] = '', _styles4),
classes: (_classes3 = {}, _classes3[p.stickyClass] = '', _classes3[p.stuckClass] = '', _classes3)

@@ -504,0 +520,0 @@ }, instance);

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

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

**/
!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";var s=function(){function t(t,s){var e=this,i=void 0!==s?s:{};this.version="3.7.1",this.userAgent=window.navigator.userAgent||"no `userAgent` provided by the browser",this.props={customStickyChangeNumber:i.customStickyChangeNumber||null,noStyles:i.noStyles||!1,stickyBitStickyOffset:i.stickyBitStickyOffset||0,parentClass:i.parentClass||"js-stickybit-parent",scrollEl:"string"==typeof i.scrollEl?document.querySelector(i.scrollEl):i.scrollEl||window,stickyClass:i.stickyClass||"js-is-sticky",stuckClass:i.stuckClass||"js-is-stuck",stickyChangeClass:i.stickyChangeClass||"js-is-sticky--change",useStickyClasses:i.useStickyClasses||!1,useFixed:i.useFixed||!1,useGetBoundingClientRect:i.useGetBoundingClientRect||!1,verticalPosition:i.verticalPosition||"top",applyStyle:i.applyStyle||function(t,s){return e.applyStyle(t,s)}},this.props.positionVal=this.definePosition()||"fixed",this.instances=[];var n=this.props,o=n.positionVal,a=n.verticalPosition,l=n.noStyles,r=n.stickyBitStickyOffset,c="top"!==a||l?"":r+"px",p="fixed"!==o?o:"";this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]);for(var f=0;f<this.els.length;f++){var u,y=this.els[f],h=this.addInstance(y,this.props);this.props.applyStyle({styles:(u={},u[a]=c,u.position=p,u),classes:{}},h),this.instances.push(h)}}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};if("fixed"===s.positionVal||s.useStickyClasses){this.isWin=this.props.scrollEl===window;var n=this.isWin?window:this.getClosestParent(i.el,i.props.scrollEl);this.computeScrollOffsets(i),this.toggleClasses(i.parent,"",s.parentClass),i.state="default",i.stateChange="default",i.stateContainer=function(){return e.manageState(i)},n.addEventListener("scroll",i.stateContainer)}return 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,a="bottom"!==e.verticalPosition,l=o?this.getTopPosition(e.scrollEl):0,r=o?this.getTopPosition(n)-l:this.getTopPosition(n),c=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight,p=r+n.offsetHeight;s.offset=o?0:l+e.stickyBitStickyOffset,s.stickyStart=a?r-s.offset:0,s.stickyChange=s.stickyStart+c,s.stickyStop=a?p-(i.offsetHeight+s.offset):p-window.innerHeight},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(r){var c=r,p=c.props,t=c.state,s=c.stateChange,e=c.stickyStart,i=c.stickyChange,n=c.stickyStop,f=p.positionVal,o=p.scrollEl,u=p.stickyClass,y=p.stickyChangeClass,h=p.stuckClass,d=p.verticalPosition,a="bottom"!==d,k=p.applyStyle,l=function(t){t()},g=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||l,m=this.isWin?window.scrollY||window.pageYOffset:o.scrollTop,v=a&&m<=e&&("sticky"===t||"stuck"===t),C=n<=m&&"sticky"===t;e<m&&m<n&&("default"===t||"stuck"===t)?c.state="sticky":v?c.state="default":C&&(c.state="stuck");var S=i<=m&&m<=n;m<i/2||n<m?c.stateChange="default":S&&(c.stateChange="sticky"),t===c.state&&s===c.stateChange||g(function(){var t,s,e,i,n,o,a={sticky:{styles:(t={position:f,top:"",bottom:""},t[d]=p.stickyBitStickyOffset+"px",t),classes:(s={},s[u]=!0,s)},default:{styles:(e={},e[d]="",e),classes:{}},stuck:{styles:(i={position:"absolute",top:"",bottom:"0"},i[d]="",i),classes:(n={},n[h]=!0,n)}};"fixed"===f&&(a.default.styles.position="");var l=a[c.state];l.classes=((o={})[h]=!!l.classes[h],o[u]=!!l.classes[u],o[y]=S,o),k(l,r)})},s.applyStyle=function(t,s){var e=t.styles,i=t.classes,n=s,o=n.el,a=n.props,l=o.style,r=a.noStyles,c=o.className.split(" ");for(var p in i){if(i[p])-1===c.indexOf(p)&&c.push(p);else{var f=c.indexOf(p);-1!==f&&c.splice(f,1)}}for(var u in o.className=c.join(" "),e){if(r&&"position"===u)return void(l[u]=e[u]);l[u]=e[u]}},s.update=function(e){var i=this;return void 0===e&&(e=null),this.instances.forEach(function(t){if(i.computeScrollOffsets(t),e)for(var s in e)t.props[s]=e[s]}),this},s.removeInstance=function(t){var s,e,i=t.el,n=t.props;this.applyStyle({styles:(s={position:""},s[n.verticalPosition]="",s),classes:(e={},e[n.stickyClass]="",e[n.stuckClass]="",e)},t),this.toggleClasses(i.parentNode,n.parentClass)},s.cleanup=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];s.stateContainer&&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){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";function b(){return(b=Object.assign||function(t){for(var s=1;s<arguments.length;s++){var e=arguments[s];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t}).apply(this,arguments)}var s=function(){function t(t,s){var e=this,i=void 0!==s?s:{};this.version="3.7.2",this.userAgent=window.navigator.userAgent||"no `userAgent` provided by the browser",this.props={customStickyChangeNumber:i.customStickyChangeNumber||null,noStyles:i.noStyles||!1,stickyBitStickyOffset:i.stickyBitStickyOffset||0,parentClass:i.parentClass||"js-stickybit-parent",scrollEl:"string"==typeof i.scrollEl?document.querySelector(i.scrollEl):i.scrollEl||window,stickyClass:i.stickyClass||"js-is-sticky",stuckClass:i.stuckClass||"js-is-stuck",stickyChangeClass:i.stickyChangeClass||"js-is-sticky--change",useStickyClasses:i.useStickyClasses||!1,useFixed:i.useFixed||!1,useGetBoundingClientRect:i.useGetBoundingClientRect||!1,verticalPosition:i.verticalPosition||"top",applyStyle:i.applyStyle||function(t,s){return e.applyStyle(t,s)}},this.props.positionVal=this.definePosition()||"fixed",this.instances=[];var n=this.props,o=n.positionVal,a=n.verticalPosition,l=n.noStyles,r=n.stickyBitStickyOffset,c="top"!==a||l?"":r+"px",p="fixed"!==o?o:"";this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]);for(var f=0;f<this.els.length;f++){var u,y=this.els[f],h=this.addInstance(y,this.props);this.props.applyStyle({styles:(u={},u[a]=c,u.position=p,u),classes:{}},h),this.instances.push(h)}}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};if("fixed"===s.positionVal||s.useStickyClasses){this.isWin=this.props.scrollEl===window;var n=this.isWin?window:this.getClosestParent(i.el,i.props.scrollEl);this.computeScrollOffsets(i),this.toggleClasses(i.parent,"",s.parentClass),i.state="default",i.stateChange="default",i.stateContainer=function(){return e.manageState(i)},n.addEventListener("scroll",i.stateContainer)}return 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,a="bottom"!==e.verticalPosition,l=o?this.getTopPosition(e.scrollEl):0,r=o?this.getTopPosition(n)-l:this.getTopPosition(n),c=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight,p=r+n.offsetHeight;s.offset=o?0:l+e.stickyBitStickyOffset,s.stickyStart=a?r-s.offset:0,s.stickyChange=s.stickyStart+c,s.stickyStop=a?p-(i.offsetHeight+s.offset):p-window.innerHeight},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(r){var c=this,p=r,f=p.props,t=p.state,s=p.stateChange,e=p.stickyStart,i=p.stickyChange,n=p.stickyStop,u=f.positionVal,o=f.scrollEl,y=f.stickyClass,h=f.stickyChangeClass,d=f.stuckClass,g=f.verticalPosition,a="bottom"!==g,k=f.applyStyle,l=function(t){t()},v=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||l,m=this.isWin?window.scrollY||window.pageYOffset:o.scrollTop,C=a&&m<=e&&("sticky"===t||"stuck"===t),S=n<=m&&"sticky"===t;e<m&&m<n&&("default"===t||"stuck"===t)?p.state="sticky":C?p.state="default":S&&(p.state="stuck");var w=i<=m&&m<=n;m<i/2||n<m?p.stateChange="default":w&&(p.stateChange="sticky"),t===p.state&&s===p.stateChange||v(function(){var t,s,e,i,n,o,a={sticky:{styles:(t={position:u,top:"",bottom:""},t[g]=f.stickyBitStickyOffset+"px",t),classes:(s={},s[y]=!0,s)},default:{styles:(e={},e[g]="",e),classes:{}},stuck:{styles:b((i={},i[g]="",i),"fixed"!==u&&c.isWin?{}:{position:"absolute",top:"",bottom:"0"}),classes:(n={},n[d]=!0,n)}};"fixed"===u&&(a.default.styles.position="");var l=a[p.state];l.classes=((o={})[d]=!!l.classes[d],o[y]=!!l.classes[y],o[h]=w,o),k(l,r)})},s.applyStyle=function(t,s){var e=t.styles,i=t.classes,n=s,o=n.el,a=n.props,l=o.style,r=a.noStyles,c=o.className.split(" ");for(var p in i){if(i[p])-1===c.indexOf(p)&&c.push(p);else{var f=c.indexOf(p);-1!==f&&c.splice(f,1)}}if(o.className=c.join(" "),!r)for(var u in e)l[u]=e[u]},s.update=function(e){var i=this;return void 0===e&&(e=null),this.instances.forEach(function(t){if(i.computeScrollOffsets(t),e)for(var s in e)t.props[s]=e[s]}),this},s.removeInstance=function(t){var s,e,i=t.el,n=t.props;this.applyStyle({styles:(s={position:""},s[n.verticalPosition]="",s),classes:(e={},e[n.stickyClass]="",e[n.stuckClass]="",e)},t),this.toggleClasses(i.parentNode,n.parentClass)},s.cleanup=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];s.stateContainer&&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.7.1
@version v3.7.2
@link https://github.com/dollarshaveclub/stickybits#readme

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

**/
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
/*

@@ -71,3 +89,3 @@ STICKYBITS πŸ’‰

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

@@ -307,2 +325,4 @@ this.props = {

_proto.manageState = function manageState(item) {
var _this3 = this;
// cache object

@@ -378,3 +398,3 @@ var it = item;

rAF(function () {
var _styles2, _classes, _styles3, _styles4, _classes2, _style$classes;
var _styles2, _classes, _styles3, _extends2, _classes2, _style$classes;

@@ -395,7 +415,7 @@ var stateStyles = {

stuck: {
styles: (_styles4 = {
styles: _extends((_extends2 = {}, _extends2[vp] = '', _extends2), pv === 'fixed' || !_this3.isWin ? {
position: 'absolute',
top: '',
bottom: '0'
}, _styles4[vp] = '', _styles4),
} : {}),
classes: (_classes2 = {}, _classes2[stuck] = true, _classes2)

@@ -446,10 +466,6 @@ }

e.className = cArray.join(' '); // eslint-disable-next-line no-unused-vars
e.className = cArray.join(' ');
if (ns) return; // eslint-disable-next-line no-unused-vars
for (var key in styles) {
if (ns && key === 'position') {
stl[key] = styles[key];
return;
}
stl[key] = styles[key];

@@ -460,3 +476,3 @@ }

_proto.update = function update(updatedProps) {
var _this3 = this;
var _this4 = this;

@@ -468,3 +484,3 @@ if (updatedProps === void 0) {

this.instances.forEach(function (instance) {
_this3.computeScrollOffsets(instance);
_this4.computeScrollOffsets(instance);

@@ -488,3 +504,3 @@ if (updatedProps) {

_proto.removeInstance = function removeInstance(instance) {
var _styles5, _classes3;
var _styles4, _classes3;

@@ -494,5 +510,5 @@ var e = instance.el;

this.applyStyle({
styles: (_styles5 = {
styles: (_styles4 = {
position: ''
}, _styles5[p.verticalPosition] = '', _styles5),
}, _styles4[p.verticalPosition] = '', _styles4),
classes: (_classes3 = {}, _classes3[p.stickyClass] = '', _classes3[p.stuckClass] = '', _classes3)

@@ -499,0 +515,0 @@ }, instance);

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

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

function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
/*

@@ -77,3 +95,3 @@ STICKYBITS πŸ’‰

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

@@ -313,2 +331,4 @@ this.props = {

_proto.manageState = function manageState(item) {
var _this3 = this;
// cache object

@@ -384,3 +404,3 @@ var it = item;

rAF(function () {
var _styles2, _classes, _styles3, _styles4, _classes2, _style$classes;
var _styles2, _classes, _styles3, _extends2, _classes2, _style$classes;

@@ -401,7 +421,7 @@ var stateStyles = {

stuck: {
styles: (_styles4 = {
styles: _extends((_extends2 = {}, _extends2[vp] = '', _extends2), pv === 'fixed' || !_this3.isWin ? {
position: 'absolute',
top: '',
bottom: '0'
}, _styles4[vp] = '', _styles4),
} : {}),
classes: (_classes2 = {}, _classes2[stuck] = true, _classes2)

@@ -452,10 +472,6 @@ }

e.className = cArray.join(' '); // eslint-disable-next-line no-unused-vars
e.className = cArray.join(' ');
if (ns) return; // eslint-disable-next-line no-unused-vars
for (var key in styles) {
if (ns && key === 'position') {
stl[key] = styles[key];
return;
}
stl[key] = styles[key];

@@ -466,3 +482,3 @@ }

_proto.update = function update(updatedProps) {
var _this3 = this;
var _this4 = this;

@@ -474,3 +490,3 @@ if (updatedProps === void 0) {

this.instances.forEach(function (instance) {
_this3.computeScrollOffsets(instance);
_this4.computeScrollOffsets(instance);

@@ -494,3 +510,3 @@ if (updatedProps) {

_proto.removeInstance = function removeInstance(instance) {
var _styles5, _classes3;
var _styles4, _classes3;

@@ -500,5 +516,5 @@ var e = instance.el;

this.applyStyle({
styles: (_styles5 = {
styles: (_styles4 = {
position: ''
}, _styles5[p.verticalPosition] = '', _styles5),
}, _styles4[p.verticalPosition] = '', _styles4),
classes: (_classes3 = {}, _classes3[p.stickyClass] = '', _classes3[p.stuckClass] = '', _classes3)

@@ -505,0 +521,0 @@ }, instance);

/**
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills
@version v3.7.1
@version v3.7.2
@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=t||self).stickybits=s()}(this,function(){"use strict";var e=function(){function t(t,s){var e=this,i=void 0!==s?s:{};this.version="3.7.1",this.userAgent=window.navigator.userAgent||"no `userAgent` provided by the browser",this.props={customStickyChangeNumber:i.customStickyChangeNumber||null,noStyles:i.noStyles||!1,stickyBitStickyOffset:i.stickyBitStickyOffset||0,parentClass:i.parentClass||"js-stickybit-parent",scrollEl:"string"==typeof i.scrollEl?document.querySelector(i.scrollEl):i.scrollEl||window,stickyClass:i.stickyClass||"js-is-sticky",stuckClass:i.stuckClass||"js-is-stuck",stickyChangeClass:i.stickyChangeClass||"js-is-sticky--change",useStickyClasses:i.useStickyClasses||!1,useFixed:i.useFixed||!1,useGetBoundingClientRect:i.useGetBoundingClientRect||!1,verticalPosition:i.verticalPosition||"top",applyStyle:i.applyStyle||function(t,s){return e.applyStyle(t,s)}},this.props.positionVal=this.definePosition()||"fixed",this.instances=[];var n=this.props,o=n.positionVal,a=n.verticalPosition,l=n.noStyles,r=n.stickyBitStickyOffset,c="top"!==a||l?"":r+"px",p="fixed"!==o?o:"";this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]);for(var f=0;f<this.els.length;f++){var u,y=this.els[f],h=this.addInstance(y,this.props);this.props.applyStyle({styles:(u={},u[a]=c,u.position=p,u),classes:{}},h),this.instances.push(h)}}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};if("fixed"===s.positionVal||s.useStickyClasses){this.isWin=this.props.scrollEl===window;var n=this.isWin?window:this.getClosestParent(i.el,i.props.scrollEl);this.computeScrollOffsets(i),this.toggleClasses(i.parent,"",s.parentClass),i.state="default",i.stateChange="default",i.stateContainer=function(){return e.manageState(i)},n.addEventListener("scroll",i.stateContainer)}return 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,a="bottom"!==e.verticalPosition,l=o?this.getTopPosition(e.scrollEl):0,r=o?this.getTopPosition(n)-l:this.getTopPosition(n),c=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight,p=r+n.offsetHeight;s.offset=o?0:l+e.stickyBitStickyOffset,s.stickyStart=a?r-s.offset:0,s.stickyChange=s.stickyStart+c,s.stickyStop=a?p-(i.offsetHeight+s.offset):p-window.innerHeight},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(r){var c=r,p=c.props,t=c.state,s=c.stateChange,e=c.stickyStart,i=c.stickyChange,n=c.stickyStop,f=p.positionVal,o=p.scrollEl,u=p.stickyClass,y=p.stickyChangeClass,h=p.stuckClass,d=p.verticalPosition,a="bottom"!==d,k=p.applyStyle,l=function(t){t()},g=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||l,m=this.isWin?window.scrollY||window.pageYOffset:o.scrollTop,v=a&&m<=e&&("sticky"===t||"stuck"===t),C=n<=m&&"sticky"===t;e<m&&m<n&&("default"===t||"stuck"===t)?c.state="sticky":v?c.state="default":C&&(c.state="stuck");var S=i<=m&&m<=n;m<i/2||n<m?c.stateChange="default":S&&(c.stateChange="sticky"),t===c.state&&s===c.stateChange||g(function(){var t,s,e,i,n,o,a={sticky:{styles:(t={position:f,top:"",bottom:""},t[d]=p.stickyBitStickyOffset+"px",t),classes:(s={},s[u]=!0,s)},default:{styles:(e={},e[d]="",e),classes:{}},stuck:{styles:(i={position:"absolute",top:"",bottom:"0"},i[d]="",i),classes:(n={},n[h]=!0,n)}};"fixed"===f&&(a.default.styles.position="");var l=a[c.state];l.classes=((o={})[h]=!!l.classes[h],o[u]=!!l.classes[u],o[y]=S,o),k(l,r)})},s.applyStyle=function(t,s){var e=t.styles,i=t.classes,n=s,o=n.el,a=n.props,l=o.style,r=a.noStyles,c=o.className.split(" ");for(var p in i){if(i[p])-1===c.indexOf(p)&&c.push(p);else{var f=c.indexOf(p);-1!==f&&c.splice(f,1)}}for(var u in o.className=c.join(" "),e){if(r&&"position"===u)return void(l[u]=e[u]);l[u]=e[u]}},s.update=function(e){var i=this;return void 0===e&&(e=null),this.instances.forEach(function(t){if(i.computeScrollOffsets(t),e)for(var s in e)t.props[s]=e[s]}),this},s.removeInstance=function(t){var s,e,i=t.el,n=t.props;this.applyStyle({styles:(s={position:""},s[n.verticalPosition]="",s),classes:(e={},e[n.stickyClass]="",e[n.stuckClass]="",e)},t),this.toggleClasses(i.parentNode,n.parentClass)},s.cleanup=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];s.stateContainer&&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=t||self).stickybits=s()}(this,function(){"use strict";function x(){return(x=Object.assign||function(t){for(var s=1;s<arguments.length;s++){var e=arguments[s];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t}).apply(this,arguments)}var e=function(){function t(t,s){var e=this,i=void 0!==s?s:{};this.version="3.7.2",this.userAgent=window.navigator.userAgent||"no `userAgent` provided by the browser",this.props={customStickyChangeNumber:i.customStickyChangeNumber||null,noStyles:i.noStyles||!1,stickyBitStickyOffset:i.stickyBitStickyOffset||0,parentClass:i.parentClass||"js-stickybit-parent",scrollEl:"string"==typeof i.scrollEl?document.querySelector(i.scrollEl):i.scrollEl||window,stickyClass:i.stickyClass||"js-is-sticky",stuckClass:i.stuckClass||"js-is-stuck",stickyChangeClass:i.stickyChangeClass||"js-is-sticky--change",useStickyClasses:i.useStickyClasses||!1,useFixed:i.useFixed||!1,useGetBoundingClientRect:i.useGetBoundingClientRect||!1,verticalPosition:i.verticalPosition||"top",applyStyle:i.applyStyle||function(t,s){return e.applyStyle(t,s)}},this.props.positionVal=this.definePosition()||"fixed",this.instances=[];var n=this.props,o=n.positionVal,a=n.verticalPosition,l=n.noStyles,r=n.stickyBitStickyOffset,c="top"!==a||l?"":r+"px",p="fixed"!==o?o:"";this.els="string"==typeof t?document.querySelectorAll(t):t,"length"in this.els||(this.els=[this.els]);for(var f=0;f<this.els.length;f++){var u,y=this.els[f],h=this.addInstance(y,this.props);this.props.applyStyle({styles:(u={},u[a]=c,u.position=p,u),classes:{}},h),this.instances.push(h)}}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};if("fixed"===s.positionVal||s.useStickyClasses){this.isWin=this.props.scrollEl===window;var n=this.isWin?window:this.getClosestParent(i.el,i.props.scrollEl);this.computeScrollOffsets(i),this.toggleClasses(i.parent,"",s.parentClass),i.state="default",i.stateChange="default",i.stateContainer=function(){return e.manageState(i)},n.addEventListener("scroll",i.stateContainer)}return 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,a="bottom"!==e.verticalPosition,l=o?this.getTopPosition(e.scrollEl):0,r=o?this.getTopPosition(n)-l:this.getTopPosition(n),c=null!==e.customStickyChangeNumber?e.customStickyChangeNumber:i.offsetHeight,p=r+n.offsetHeight;s.offset=o?0:l+e.stickyBitStickyOffset,s.stickyStart=a?r-s.offset:0,s.stickyChange=s.stickyStart+c,s.stickyStop=a?p-(i.offsetHeight+s.offset):p-window.innerHeight},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(r){var c=this,p=r,f=p.props,t=p.state,s=p.stateChange,e=p.stickyStart,i=p.stickyChange,n=p.stickyStop,u=f.positionVal,o=f.scrollEl,y=f.stickyClass,h=f.stickyChangeClass,d=f.stuckClass,g=f.verticalPosition,a="bottom"!==g,k=f.applyStyle,l=function(t){t()},m=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||l,v=this.isWin?window.scrollY||window.pageYOffset:o.scrollTop,C=a&&v<=e&&("sticky"===t||"stuck"===t),S=n<=v&&"sticky"===t;e<v&&v<n&&("default"===t||"stuck"===t)?p.state="sticky":C?p.state="default":S&&(p.state="stuck");var w=i<=v&&v<=n;v<i/2||n<v?p.stateChange="default":w&&(p.stateChange="sticky"),t===p.state&&s===p.stateChange||m(function(){var t,s,e,i,n,o,a={sticky:{styles:(t={position:u,top:"",bottom:""},t[g]=f.stickyBitStickyOffset+"px",t),classes:(s={},s[y]=!0,s)},default:{styles:(e={},e[g]="",e),classes:{}},stuck:{styles:x((i={},i[g]="",i),"fixed"!==u&&c.isWin?{}:{position:"absolute",top:"",bottom:"0"}),classes:(n={},n[d]=!0,n)}};"fixed"===u&&(a.default.styles.position="");var l=a[p.state];l.classes=((o={})[d]=!!l.classes[d],o[y]=!!l.classes[y],o[h]=w,o),k(l,r)})},s.applyStyle=function(t,s){var e=t.styles,i=t.classes,n=s,o=n.el,a=n.props,l=o.style,r=a.noStyles,c=o.className.split(" ");for(var p in i){if(i[p])-1===c.indexOf(p)&&c.push(p);else{var f=c.indexOf(p);-1!==f&&c.splice(f,1)}}if(o.className=c.join(" "),!r)for(var u in e)l[u]=e[u]},s.update=function(e){var i=this;return void 0===e&&(e=null),this.instances.forEach(function(t){if(i.computeScrollOffsets(t),e)for(var s in e)t.props[s]=e[s]}),this},s.removeInstance=function(t){var s,e,i=t.el,n=t.props;this.applyStyle({styles:(s={position:""},s[n.verticalPosition]="",s),classes:(e={},e[n.stickyClass]="",e[n.stuckClass]="",e)},t),this.toggleClasses(i.parentNode,n.parentClass)},s.cleanup=function(){for(var t=0;t<this.instances.length;t+=1){var s=this.instances[t];s.stateContainer&&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.7.1
@version v3.7.2
@link https://github.com/dollarshaveclub/stickybits#readme

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

function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
/*

@@ -76,3 +94,3 @@ STICKYBITS πŸ’‰

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

@@ -312,2 +330,4 @@ this.props = {

_proto.manageState = function manageState(item) {
var _this3 = this;
// cache object

@@ -383,3 +403,3 @@ var it = item;

rAF(function () {
var _styles2, _classes, _styles3, _styles4, _classes2, _style$classes;
var _styles2, _classes, _styles3, _extends2, _classes2, _style$classes;

@@ -400,7 +420,7 @@ var stateStyles = {

stuck: {
styles: (_styles4 = {
styles: _extends((_extends2 = {}, _extends2[vp] = '', _extends2), pv === 'fixed' || !_this3.isWin ? {
position: 'absolute',
top: '',
bottom: '0'
}, _styles4[vp] = '', _styles4),
} : {}),
classes: (_classes2 = {}, _classes2[stuck] = true, _classes2)

@@ -451,10 +471,6 @@ }

e.className = cArray.join(' '); // eslint-disable-next-line no-unused-vars
e.className = cArray.join(' ');
if (ns) return; // eslint-disable-next-line no-unused-vars
for (var key in styles) {
if (ns && key === 'position') {
stl[key] = styles[key];
return;
}
stl[key] = styles[key];

@@ -465,3 +481,3 @@ }

_proto.update = function update(updatedProps) {
var _this3 = this;
var _this4 = this;

@@ -473,3 +489,3 @@ if (updatedProps === void 0) {

this.instances.forEach(function (instance) {
_this3.computeScrollOffsets(instance);
_this4.computeScrollOffsets(instance);

@@ -493,3 +509,3 @@ if (updatedProps) {

_proto.removeInstance = function removeInstance(instance) {
var _styles5, _classes3;
var _styles4, _classes3;

@@ -499,5 +515,5 @@ var e = instance.el;

this.applyStyle({
styles: (_styles5 = {
styles: (_styles4 = {
position: ''
}, _styles5[p.verticalPosition] = '', _styles5),
}, _styles4[p.verticalPosition] = '', _styles4),
classes: (_classes3 = {}, _classes3[p.stickyClass] = '', _classes3[p.stuckClass] = '', _classes3)

@@ -504,0 +520,0 @@ }, instance);

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

@@ -66,3 +66,3 @@ "main": "dist/stickybits.js",

"eslint-config-dollarshaveclub": "^3.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-node": "^10.0.0",

@@ -74,7 +74,7 @@ "eslint-plugin-standard": "^4.0.0",

"markdown-spellcheck": "^1.3.1",
"markdownlint-cli": "^0.19.0",
"markdownlint-cli": "^0.20.0",
"node-qunit-phantomjs": "^2.0.0",
"nyc": "^14.0.0",
"qunit": "^2.6.1",
"rollup": "1.27.8",
"rollup": "1.27.13",
"rollup-plugin-babel": "^4.1.0",

@@ -81,0 +81,0 @@ "rollup-plugin-replace": "^2.0.0",

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

const isStuck = scroll >= stop && state === 'sticky'
/*

@@ -352,3 +351,2 @@ Unnamed arrow functions within this block

if (state === it.state && stateChange === it.stateChange) return
rAF(() => {

@@ -373,6 +371,8 @@ const stateStyles = {

styles: {
position: 'absolute',
top: '',
bottom: '0',
[vp]: '',
...(pv === 'fixed' || !this.isWin ? {
position: 'absolute',
top: '',
bottom: '0',
} : {}),
},

@@ -428,8 +428,6 @@ classes: { [stuck]: true },

if (ns) return
// eslint-disable-next-line no-unused-vars
for (const key in styles) {
if (ns && key === 'position') {
stl[key] = styles[key]
return
}
stl[key] = styles[key]

@@ -436,0 +434,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc