stickybits
Advanced tools
Comparing version 3.7.9 to 3.7.10
/** | ||
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills | ||
@version v3.7.9 | ||
@version v3.7.10 | ||
@link https://github.com/yowainwright/stickybits#readme | ||
@@ -14,3 +14,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
@@ -28,3 +28,2 @@ var source = arguments[i]; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -93,3 +92,3 @@ } | ||
var o = typeof obj !== 'undefined' ? obj : {}; | ||
this.version = '3.7.9'; | ||
this.version = '3.7.10'; | ||
this.userAgent = window.navigator.userAgent || 'no `userAgent` provided by the browser'; | ||
@@ -96,0 +95,0 @@ this.props = { |
/** | ||
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills | ||
@version v3.7.9 | ||
@version v3.7.10 | ||
@link https://github.com/yowainwright/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";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 s=function(){function t(t,s){var e=this,i=void 0!==s?s:{};this.version="3.7.9",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={})[a]=c,u.position=p,u),classes:{}},h),this.manageState(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){function t(t){t()}var c=this,p=r,f=p.props,s=p.state,e=p.stateChange,i=p.stickyStart,n=p.stickyChange,o=p.stickyStop,u=f.positionVal,a=f.scrollEl,y=f.stickyClass,h=f.stickyChangeClass,d=f.stuckClass,g=f.verticalPosition,l="bottom"!==g,k=f.applyStyle,m=f.noStyles,v=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||t,C=this.isWin?window.scrollY||window.pageYOffset:a.scrollTop,S=l&&C<=i&&("sticky"===s||"stuck"===s),w=o<=C&&"sticky"===s;i<C&&C<o&&("default"===s||"stuck"===s)?p.state="sticky":S?p.state="default":w&&(p.state="stuck");var b=n<=C&&C<=o;C<n/2||o<C?p.stateChange="default":b&&(p.stateChange="sticky"),s===p.state&&e===p.stateChange||v(function(){var t,s,e,i,n,o,a={sticky:{styles:((t={position:u,top:"",bottom:""})[g]=f.stickyBitStickyOffset+"px",t),classes:((s={})[y]=!0,s)},default:{styles:((e={})[g]="",e),classes:{}},stuck:{styles:x(((i={})[g]="",i),"fixed"===u&&!m||!c.isWin?{position:"absolute",top:"",bottom:"0"}:{}),classes:((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]=b,o),k(l,r)})},s.applyStyle=function(t,s){var e=t.styles,i=t.classes,n=s.el,o=s.props,a=n.style,l=o.noStyles,r=n.className.split(" ");for(var c in i){if(i[c])-1===r.indexOf(c)&&r.push(c);else{var p=r.indexOf(c);-1!==p&&r.splice(p,1)}}if(n.className=r.join(" "),e.position&&(a.position=e.position),!l)for(var f in e)a[f]=e[f]},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:""})[n.verticalPosition]="",s),classes:((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 O(){return(O=Object.assign?Object.assign.bind():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.10",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={})[a]=c,u.position=p,u),classes:{}},h),this.manageState(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){function t(t){t()}var c=this,p=r,f=p.props,s=p.state,e=p.stateChange,i=p.stickyStart,n=p.stickyChange,o=p.stickyStop,u=f.positionVal,a=f.scrollEl,y=f.stickyClass,h=f.stickyChangeClass,d=f.stuckClass,g=f.verticalPosition,l="bottom"!==g,k=f.applyStyle,m=f.noStyles,v=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||t,C=this.isWin?window.scrollY||window.pageYOffset:a.scrollTop,S=l&&C<=i&&("sticky"===s||"stuck"===s),w=o<=C&&"sticky"===s;i<C&&C<o&&("default"===s||"stuck"===s)?p.state="sticky":S?p.state="default":w&&(p.state="stuck");var b=n<=C&&C<=o;C<n/2||o<C?p.stateChange="default":b&&(p.stateChange="sticky"),s===p.state&&e===p.stateChange||v(function(){var t,s,e,i,n,o,a={sticky:{styles:((t={position:u,top:"",bottom:""})[g]=f.stickyBitStickyOffset+"px",t),classes:((s={})[y]=!0,s)},default:{styles:((e={})[g]="",e),classes:{}},stuck:{styles:O(((i={})[g]="",i),"fixed"===u&&!m||!c.isWin?{position:"absolute",top:"",bottom:"0"}:{}),classes:((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]=b,o),k(l,r)})},s.applyStyle=function(t,s){var e=t.styles,i=t.classes,n=s.el,o=s.props,a=n.style,l=o.noStyles,r=n.className.split(" ");for(var c in i){if(i[c])-1===r.indexOf(c)&&r.push(c);else{var p=r.indexOf(c);-1!==p&&r.splice(p,1)}}if(n.className=r.join(" "),e.position&&(a.position=e.position),!l)for(var f in e)a[f]=e[f]},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:""})[n.verticalPosition]="",s),classes:((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.9 | ||
@version v3.7.10 | ||
@link https://github.com/yowainwright/stickybits#readme | ||
@@ -9,3 +9,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
@@ -23,3 +23,2 @@ var source = arguments[i]; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -88,3 +87,3 @@ } | ||
var o = typeof obj !== 'undefined' ? obj : {}; | ||
this.version = '3.7.9'; | ||
this.version = '3.7.10'; | ||
this.userAgent = window.navigator.userAgent || 'no `userAgent` provided by the browser'; | ||
@@ -91,0 +90,0 @@ this.props = { |
/** | ||
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills | ||
@version v3.7.9 | ||
@version v3.7.10 | ||
@link https://github.com/yowainwright/stickybits#readme | ||
@@ -15,3 +15,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
@@ -29,3 +29,2 @@ var source = arguments[i]; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -94,3 +93,3 @@ } | ||
var o = typeof obj !== 'undefined' ? obj : {}; | ||
this.version = '3.7.9'; | ||
this.version = '3.7.10'; | ||
this.userAgent = window.navigator.userAgent || 'no `userAgent` provided by the browser'; | ||
@@ -97,0 +96,0 @@ this.props = { |
/** | ||
stickybits - Stickybits is a lightweight alternative to `position: sticky` polyfills | ||
@version v3.7.9 | ||
@version v3.7.10 | ||
@link https://github.com/yowainwright/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";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 e=function(){function t(t,s){var e=this,i=void 0!==s?s:{};this.version="3.7.9",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={})[a]=c,u.position=p,u),classes:{}},h),this.manageState(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){function t(t){t()}var c=this,p=r,f=p.props,s=p.state,e=p.stateChange,i=p.stickyStart,n=p.stickyChange,o=p.stickyStop,u=f.positionVal,a=f.scrollEl,y=f.stickyClass,h=f.stickyChangeClass,d=f.stuckClass,g=f.verticalPosition,l="bottom"!==g,k=f.applyStyle,m=f.noStyles,v=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||t,C=this.isWin?window.scrollY||window.pageYOffset:a.scrollTop,S=l&&C<=i&&("sticky"===s||"stuck"===s),w=o<=C&&"sticky"===s;i<C&&C<o&&("default"===s||"stuck"===s)?p.state="sticky":S?p.state="default":w&&(p.state="stuck");var x=n<=C&&C<=o;C<n/2||o<C?p.stateChange="default":x&&(p.stateChange="sticky"),s===p.state&&e===p.stateChange||v(function(){var t,s,e,i,n,o,a={sticky:{styles:((t={position:u,top:"",bottom:""})[g]=f.stickyBitStickyOffset+"px",t),classes:((s={})[y]=!0,s)},default:{styles:((e={})[g]="",e),classes:{}},stuck:{styles:b(((i={})[g]="",i),"fixed"===u&&!m||!c.isWin?{position:"absolute",top:"",bottom:"0"}:{}),classes:((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]=x,o),k(l,r)})},s.applyStyle=function(t,s){var e=t.styles,i=t.classes,n=s.el,o=s.props,a=n.style,l=o.noStyles,r=n.className.split(" ");for(var c in i){if(i[c])-1===r.indexOf(c)&&r.push(c);else{var p=r.indexOf(c);-1!==p&&r.splice(p,1)}}if(n.className=r.join(" "),e.position&&(a.position=e.position),!l)for(var f in e)a[f]=e[f]},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:""})[n.verticalPosition]="",s),classes:((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?Object.assign.bind():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.10",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={})[a]=c,u.position=p,u),classes:{}},h),this.manageState(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){function t(t){t()}var c=this,p=r,f=p.props,s=p.state,e=p.stateChange,i=p.stickyStart,n=p.stickyChange,o=p.stickyStop,u=f.positionVal,a=f.scrollEl,y=f.stickyClass,h=f.stickyChangeClass,d=f.stuckClass,g=f.verticalPosition,l="bottom"!==g,k=f.applyStyle,m=f.noStyles,v=this.isWin&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)||t,C=this.isWin?window.scrollY||window.pageYOffset:a.scrollTop,S=l&&C<=i&&("sticky"===s||"stuck"===s),w=o<=C&&"sticky"===s;i<C&&C<o&&("default"===s||"stuck"===s)?p.state="sticky":S?p.state="default":w&&(p.state="stuck");var b=n<=C&&C<=o;C<n/2||o<C?p.stateChange="default":b&&(p.stateChange="sticky"),s===p.state&&e===p.stateChange||v(function(){var t,s,e,i,n,o,a={sticky:{styles:((t={position:u,top:"",bottom:""})[g]=f.stickyBitStickyOffset+"px",t),classes:((s={})[y]=!0,s)},default:{styles:((e={})[g]="",e),classes:{}},stuck:{styles:x(((i={})[g]="",i),"fixed"===u&&!m||!c.isWin?{position:"absolute",top:"",bottom:"0"}:{}),classes:((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]=b,o),k(l,r)})},s.applyStyle=function(t,s){var e=t.styles,i=t.classes,n=s.el,o=s.props,a=n.style,l=o.noStyles,r=n.className.split(" ");for(var c in i){if(i[c])-1===r.indexOf(c)&&r.push(c);else{var p=r.indexOf(c);-1!==p&&r.splice(p,1)}}if(n.className=r.join(" "),e.position&&(a.position=e.position),!l)for(var f in e)a[f]=e[f]},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:""})[n.verticalPosition]="",s),classes:((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.9 | ||
@version v3.7.10 | ||
@link https://github.com/yowainwright/stickybits#readme | ||
@@ -14,3 +14,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (https://jeffry.in) | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
@@ -28,3 +28,2 @@ var source = arguments[i]; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -93,3 +92,3 @@ } | ||
var o = typeof obj !== 'undefined' ? obj : {}; | ||
this.version = '3.7.9'; | ||
this.version = '3.7.10'; | ||
this.userAgent = window.navigator.userAgent || 'no `userAgent` provided by the browser'; | ||
@@ -96,0 +95,0 @@ this.props = { |
{ | ||
"name": "stickybits", | ||
"version": "3.7.9", | ||
"version": "3.7.10", | ||
"description": "Stickybits is a lightweight alternative to `position: sticky` polyfills", | ||
@@ -60,7 +60,7 @@ "main": "dist/stickybits.js", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-jest": "^26.1.0", | ||
"babel-jest": "^28.0.0", | ||
"codecov": "^3.0.2", | ||
"conventional-changelog-cli": "^2.0.11", | ||
"es-check": "^5.0.0", | ||
"eslint": "^7.2.0", | ||
"es-check": "^6.0.0", | ||
"eslint": "^8.0.1", | ||
"eslint-config-dollarshaveclub": "^3.1.0", | ||
@@ -70,7 +70,7 @@ "eslint-plugin-import": "^2.19.1", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"husky": "4.3.8", | ||
"husky": "8.0.1", | ||
"jest": "^26.0.1", | ||
"jquery": "^3.2.1", | ||
"markdown-spellcheck": "^1.3.1", | ||
"markdownlint-cli": "^0.26.0", | ||
"markdownlint-cli": "^0.31.0", | ||
"node-qunit-puppeteer": "^2.0.3", | ||
@@ -77,0 +77,0 @@ "nyc": "^15.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2531
117344
13