headroom.js
Advanced tools
Comparing version 0.10.0 to 0.10.2
/*! | ||
* headroom.js v0.10.0 - Give your page some headroom. Hide your header until you need it | ||
* headroom.js v0.10.2 - Give your page some headroom. Hide your header until you need it | ||
* Copyright (c) 2019 Nick Williams - http://wicky.nillia.ms/headroom.js | ||
@@ -204,3 +204,3 @@ * License: MIT | ||
Object.assign(this, Headroom.options, options); | ||
Object.assign(this.classes, Headroom.options.classes, options.classes); | ||
this.classes = Object.assign({}, Headroom.options.classes, options.classes); | ||
@@ -207,0 +207,0 @@ this.elem = elem; |
/*! | ||
* headroom.js v0.10.0 - Give your page some headroom. Hide your header until you need it | ||
* headroom.js v0.10.2 - Give your page some headroom. Hide your header until you need it | ||
* Copyright (c) 2019 Nick Williams - http://wicky.nillia.ms/headroom.js | ||
@@ -7,2 +7,2 @@ * License: MIT | ||
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(t=t||self).Headroom=s()}(this,function(){"use strict";function t(){return"undefined"!=typeof window}function u(t){return function(t){return t&&t.document&&function(t){return 9===t.nodeType}(t.document)}(t)?function(t){var s=t.document,n=s.body,o=s.documentElement;return{scrollHeight:function(){return Math.max(n.scrollHeight,o.scrollHeight,n.offsetHeight,o.offsetHeight,n.clientHeight,o.clientHeight)},height:function(){return t.innerHeight||o.clientHeight||n.clientHeight},scrollY:function(){return void 0!==t.pageYOffset?t.pageYOffset:(o||n.parentNode||n).scrollTop}}}(t):function(t){return{scrollHeight:function(){return Math.max(t.scrollHeight,t.offsetHeight,t.clientHeight)},height:function(){return Math.max(t.offsetHeight,t.clientHeight)},scrollY:function(){return t.scrollTop}}}(t)}function s(t,o){var s,n=function(){var s=!1;try{var t={get passive(){s=!0}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){s=!1}return s}(),i=!1,e=u(t),r=e.scrollY(),l={};function a(){var t=e.scrollY(),s=e.height(),n=e.scrollHeight();l.scrollY=t,l.lastScrollY=r,l.direction=r<t?"down":"up",l.distance=Math.abs(t-r),l.isOutOfBounds=t<0||n<t+s,l.top=t<=0,l.bottom=n<=t+s,o(l),r=t,i=!1}function h(){i||(i=!0,s=requestAnimationFrame(a))}var c=!!n&&{passive:!0,capture:!1};return t.addEventListener("scroll",h,c),{destroy:function(){cancelAnimationFrame(s),t.removeEventListener("scroll",h,c)}}}function n(t,s){s=s||{},Object.assign(this,n.options,s),Object.assign(this.classes,n.options.classes,s.classes),this.elem=t,this.tolerance=function(t){return t===Object(t)?t:{down:t,up:t}}(this.tolerance),this.initialised=!1,this.frozen=!1}return n.prototype={constructor:n,init:function(){return n.cutsTheMustard&&!this.initialised&&(this.addClass("initial"),this.initialised=!0,setTimeout(function(t){t.scrollTracker=s(t.scroller,t.update.bind(t))},100,this)),this},destroy:function(){this.initialised=!1,Object.keys(this.classes).forEach(this.removeClass,this),this.scrollTracker.destroy()},unpin:function(){!this.hasClass("pinned")&&this.hasClass("unpinned")||(this.addClass("unpinned"),this.removeClass("pinned"),this.onUnpin&&this.onUnpin.call(this))},pin:function(){this.hasClass("unpinned")&&(this.addClass("pinned"),this.removeClass("unpinned"),this.onPin&&this.onPin.call(this))},freeze:function(){this.frozen=!0,this.addClass("frozen")},unfreeze:function(){this.frozen=!1,this.removeClass("frozen")},top:function(){this.hasClass("top")||(this.addClass("top"),this.removeClass("notTop"),this.onTop&&this.onTop.call(this))},notTop:function(){this.hasClass("notTop")||(this.addClass("notTop"),this.removeClass("top"),this.onNotTop&&this.onNotTop.call(this))},bottom:function(){this.hasClass("bottom")||(this.addClass("bottom"),this.removeClass("notBottom"),this.onBottom&&this.onBottom.call(this))},notBottom:function(){this.hasClass("notBottom")||(this.addClass("notBottom"),this.removeClass("bottom"),this.onNotBottom&&this.onNotBottom.call(this))},shouldUnpin:function(t,s,n){var o=s<t,i=t>=this.offset;return o&&i&&n},shouldPin:function(t,s,n){var o=t<s,i=t<=this.offset;return o&&n||i},addClass:function(t){this.elem.classList.add(this.classes[t])},removeClass:function(t){this.elem.classList.remove(this.classes[t])},hasClass:function(t){return this.elem.classList.contains(this.classes[t])},update:function(t){var s=t.distance>this.tolerance[t.direction];t.isOutOfBounds||!0!==this.frozen&&(t.top?this.top():this.notTop(),t.bottom?this.bottom():this.notBottom(),this.shouldUnpin(t.scrollY,t.lastScrollY,s)?this.unpin():this.shouldPin(t.scrollY,t.lastScrollY,s)&&this.pin())}},n.options={tolerance:{up:0,down:0},offset:0,scroller:t()?window:null,classes:{frozen:"headroom--frozen",pinned:"headroom--pinned",unpinned:"headroom--unpinned",top:"headroom--top",notTop:"headroom--not-top",bottom:"headroom--bottom",notBottom:"headroom--not-bottom",initial:"headroom"}},n.cutsTheMustard=!!(t()&&function(){}.bind&&"classList"in document.documentElement&&Object.assign&&Object.keys&&requestAnimationFrame),n}); | ||
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(t=t||self).Headroom=s()}(this,function(){"use strict";function t(){return"undefined"!=typeof window}function u(t){return function(t){return t&&t.document&&function(t){return 9===t.nodeType}(t.document)}(t)?function(t){var s=t.document,n=s.body,o=s.documentElement;return{scrollHeight:function(){return Math.max(n.scrollHeight,o.scrollHeight,n.offsetHeight,o.offsetHeight,n.clientHeight,o.clientHeight)},height:function(){return t.innerHeight||o.clientHeight||n.clientHeight},scrollY:function(){return void 0!==t.pageYOffset?t.pageYOffset:(o||n.parentNode||n).scrollTop}}}(t):function(t){return{scrollHeight:function(){return Math.max(t.scrollHeight,t.offsetHeight,t.clientHeight)},height:function(){return Math.max(t.offsetHeight,t.clientHeight)},scrollY:function(){return t.scrollTop}}}(t)}function s(t,o){var s,n=function(){var s=!1;try{var t={get passive(){s=!0}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){s=!1}return s}(),i=!1,e=u(t),r=e.scrollY(),l={};function a(){var t=e.scrollY(),s=e.height(),n=e.scrollHeight();l.scrollY=t,l.lastScrollY=r,l.direction=r<t?"down":"up",l.distance=Math.abs(t-r),l.isOutOfBounds=t<0||n<t+s,l.top=t<=0,l.bottom=n<=t+s,o(l),r=t,i=!1}function h(){i||(i=!0,s=requestAnimationFrame(a))}var c=!!n&&{passive:!0,capture:!1};return t.addEventListener("scroll",h,c),{destroy:function(){cancelAnimationFrame(s),t.removeEventListener("scroll",h,c)}}}function n(t,s){s=s||{},Object.assign(this,n.options,s),this.classes=Object.assign({},n.options.classes,s.classes),this.elem=t,this.tolerance=function(t){return t===Object(t)?t:{down:t,up:t}}(this.tolerance),this.initialised=!1,this.frozen=!1}return n.prototype={constructor:n,init:function(){return n.cutsTheMustard&&!this.initialised&&(this.addClass("initial"),this.initialised=!0,setTimeout(function(t){t.scrollTracker=s(t.scroller,t.update.bind(t))},100,this)),this},destroy:function(){this.initialised=!1,Object.keys(this.classes).forEach(this.removeClass,this),this.scrollTracker.destroy()},unpin:function(){!this.hasClass("pinned")&&this.hasClass("unpinned")||(this.addClass("unpinned"),this.removeClass("pinned"),this.onUnpin&&this.onUnpin.call(this))},pin:function(){this.hasClass("unpinned")&&(this.addClass("pinned"),this.removeClass("unpinned"),this.onPin&&this.onPin.call(this))},freeze:function(){this.frozen=!0,this.addClass("frozen")},unfreeze:function(){this.frozen=!1,this.removeClass("frozen")},top:function(){this.hasClass("top")||(this.addClass("top"),this.removeClass("notTop"),this.onTop&&this.onTop.call(this))},notTop:function(){this.hasClass("notTop")||(this.addClass("notTop"),this.removeClass("top"),this.onNotTop&&this.onNotTop.call(this))},bottom:function(){this.hasClass("bottom")||(this.addClass("bottom"),this.removeClass("notBottom"),this.onBottom&&this.onBottom.call(this))},notBottom:function(){this.hasClass("notBottom")||(this.addClass("notBottom"),this.removeClass("bottom"),this.onNotBottom&&this.onNotBottom.call(this))},shouldUnpin:function(t,s,n){var o=s<t,i=t>=this.offset;return o&&i&&n},shouldPin:function(t,s,n){var o=t<s,i=t<=this.offset;return o&&n||i},addClass:function(t){this.elem.classList.add(this.classes[t])},removeClass:function(t){this.elem.classList.remove(this.classes[t])},hasClass:function(t){return this.elem.classList.contains(this.classes[t])},update:function(t){var s=t.distance>this.tolerance[t.direction];t.isOutOfBounds||!0!==this.frozen&&(t.top?this.top():this.notTop(),t.bottom?this.bottom():this.notBottom(),this.shouldUnpin(t.scrollY,t.lastScrollY,s)?this.unpin():this.shouldPin(t.scrollY,t.lastScrollY,s)&&this.pin())}},n.options={tolerance:{up:0,down:0},offset:0,scroller:t()?window:null,classes:{frozen:"headroom--frozen",pinned:"headroom--pinned",unpinned:"headroom--unpinned",top:"headroom--top",notTop:"headroom--not-top",bottom:"headroom--bottom",notBottom:"headroom--not-bottom",initial:"headroom"}},n.cutsTheMustard=!!(t()&&function(){}.bind&&"classList"in document.documentElement&&Object.assign&&Object.keys&&requestAnimationFrame),n}); |
{ | ||
"name": "headroom.js", | ||
"version": "0.10.0", | ||
"version": "0.10.2", | ||
"description": "Give your page some headroom. Hide your header until you need it", | ||
@@ -5,0 +5,0 @@ "main": "dist/headroom.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22958
0