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

scrollfeatures

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scrollfeatures - npm Package Compare versions

Comparing version 1.4.2 to 1.5.0

lib/has-overflow.js

2

dist/scrollfeatures.min.js

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

!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.ScrollFeatures=t()}}(function(){return function t(e,i,n){function r(s,l){if(!i[s]){if(!e[s]){var c="function"==typeof require&&require;if(!l&&c)return c(s,!0);if(o)return o(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var h=i[s]={exports:{}};e[s][0].call(h.exports,function(t){var i=e[s][1][t];return r(i?i:t)},h,h.exports,t,e,i,n)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)r(n[s]);return r}({1:[function(t,e,i){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],i=e.target,r=e.currentTarget;n(this,t),this._eventMap={},this._destroyed=!1,this._target=i||this,this._currentTarget=r||this,this.on=this.bind=this.addEventListener=this.addListener,this.off=this.unbind=this.removeEventListener=this.removeListener,this.once=this.one=this.addListenerOnce,this.emit=this.trigger=this.dispatchEvent=this.dispatch}return t.prototype.addListener=function(t,e){var i=this.getListener(t);return i?-1===i.indexOf(e)&&i.push(e):this._eventMap[t]=[e],this},t.prototype.addListenerOnce=function(t,e){var i=this,n=function(r){e(r),i.off(t,n),e=null,n=null};return this.on(t,n)},t.prototype.removeListener=function(t,e){if(!e)return this.removeAllListener(t);var i=this.getListener(t);if(i){var n=i.indexOf(e);n>-1&&(i=i.splice(n,1),i.length||delete this._eventMap[t])}return this},t.prototype.removeAllListener=function(t){var e=this.getListener(t);return e&&(this._eventMap[t].length=0,delete this._eventMap[t]),this},t.prototype.hasListener=function(t){return null!==this.getListener(t)},t.prototype.hasListeners=function(){return null!==this._eventMap&&void 0!==this._eventMap&&!r(this._eventMap)},t.prototype.dispatch=function(t,e){var i=this.getListener(t);if(i){e=e||{},e.type=t,e.target=e.target||this._target,e.currentTarget=e.currentTarget||this._currentTarget;for(var n=-1;++n<i.length;)i[n](e)}return this},t.prototype.getListener=function(t){var e=this._eventMap?this._eventMap[t]:null;return e||null},t.prototype.destroy=function(){if(this._eventMap){for(var t in this._eventMap)this.removeAllListener(t);this._eventMap=null}return this._destroyed=!0,this},t}();i["default"]=o,e.exports=i["default"]},{}],2:[function(t,e){"use strict";e.exports=t("./dist/eventdispatcher")},{"./dist/eventdispatcher":1}],3:[function(t,e){"use strict";var i=/(auto|scroll)/,n=function(t){var e=window.getComputedStyle(t,null);return i.test(e.getPropertyValue("overflow")+e.getPropertyValue("overflow-y")+e.getPropertyValue("overflow-x"))};e.exports=n},{}],4:[function(t,e){"use strict";var i=t("./has-overflow"),n=function(t){if(!(t instanceof HTMLElement))return window;for(;t.parentNode;){if(t.parentNode===document.body)return window;if(i(t.parentNode))return t.parentNode;t=t.parentNode}return window};e.exports=n},{"./has-overflow":3}],5:[function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var l=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),c=t("eventdispatcher"),a=n(c),h=t("./scroll-parent"),u=n(h),d=function(){window.requestAnimationFrame||(window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,window.cancelAnimationFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame)},f=function(t){function e(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(r(this,e),e.hasInstance(i)){var s;return s=e.getInstance(i),o(l,s)}var l=o(this,t.call(this,{target:i}));return l._scrollTarget=null,l._destroyed=!1,l._y=0,l._x=0,l._speedY=0,l._speedX=0,l._lastSpeed=0,l._lastDirectionY=e.direction.none,l._lastDirectionX=e.direction.none,l._stopFrames=3,l._currentStopFrames=0,l._firstRender=!0,l._directionY=e.direction.none,l._directionX=e.direction.none,l._scrolling=!1,l._canScrollY=!1,l._canScrollX=!1,i.scrollFeatures=l,l._scrollTarget=i,l.options=n,p.animationFrame&&d(),l.init(),l}return s(e,t),e.getInstance=function(t,i){return t.scrollFeatures?t.scrollFeatures:new e(t,i)},e.hasInstance=function(t){return"undefined"!=typeof t.scrollFeatures},e.getScrollParent=function(t){return u["default"](t)},l(e,null,[{key:"windowY",get:function(){return window.pageYOffset||window.y||0}},{key:"windowX",get:function(){return window.pageXOffset||window.scrollX||0}},{key:"documentHeight",get:function(){return Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)}},{key:"documentWidth",get:function(){return Math.max(document.body.scrollWidth,document.body.offsetWidth,document.documentElement.clientWidth,document.documentElement.scrollWidth,document.documentElement.offsetWidth)}}]),e.prototype.init=function(){var t=this;if(this.getScrollPosition=this._scrollTarget===window?function(){return{y:e.windowY,x:e.windowX}}.bind(this):function(){return{y:this._scrollTarget.scrollTop,x:this._scrollTarget.scrollLeft}}.bind(this),this.onResize=function(){t.trigger(e.events.SCROLL_RESIZE)},this.onScroll=this.onScroll.bind(this),this.onNextFrame=this.onNextFrame.bind(this),this.updateScrollPosition(),this._scrollTarget!==window){var i=/(auto|scroll)/,n=window.getComputedStyle(this._scrollTarget,null);this._canScrollY=i.test(n.getPropertyValue("overflow-y")),this._canScrollX=i.test(n.getPropertyValue("overflow-x"))}else this._canScrollY=this.clientHeight<this.scrollHeight,this._canScrollX=this.clientWidth<this.scrollWidth;this._scrollTarget.addEventListener?(this._scrollTarget.addEventListener("scroll",this.onScroll,!1),this._scrollTarget.addEventListener("resize",this.onResize,!1)):this._scrollTarget.attachEvent&&(this._scrollTarget.attachEvent("scroll",this.onScroll),this._scrollTarget.attachEvent("resize",this.onResize))},e.prototype.destroy=function(){this._destroyed||(this._cancelNextFrame(),t.prototype.destroy.call(this),this._scrollTarget.addEventListener?(this._scrollTarget.removeEventListener("scroll",this.onScroll),this._scrollTarget.removeEventListener("resize",this.onResize)):this._scrollTarget.attachEvent&&(this._scrollTarget.detachEvent("scroll",this.onScroll),this._scrollTarget.detachEvent("resize",this.onResize)),this.onResize=null,this.onScroll=null,this.getScrollPosition=null,this.onNextFrame=null,delete this._scrollTarget.scrollFeatures,this._scrollTarget=null,this._destroyed=!0)},e.prototype.updateScrollPosition=function(){this._y=this.y,this._x=this.x},e.prototype.onScroll=function(){return this._currentStopFrames=0,this._firstRender&&(this._firstRender=!1,this.y>1||this.x>1)?(this.updateScrollPosition(),void this.trigger(e.events.SCROLL_PROGRESS)):void(this._scrolling||(this._scrolling=!0,this._lastDirectionY=e.direction.none,this._lastDirectionX=e.direction.none,this.trigger(e.events.SCROLL_START),p.animationFrame?this.nextFrameID=window.requestAnimationFrame(this.onNextFrame):this.onNextFrame()))},e.prototype.onNextFrame=function(){var t=this;this._speedY=this._y-this.y,this._speedX=this._x-this.x;var i=+this.speedY+ +this.speedX;return this._scrolling&&0===i&&this._currentStopFrames++>this._stopFrames?void this.onScrollStop():(this.updateScrollPosition(),this._lastDirectionY!==this.directionY&&this.trigger("scroll:"+(this.directionY===e.direction.down?"down":"up")),this._lastDirectionX!==this.directionX&&this.trigger("scroll:"+(this.directionX===e.direction.right?"right":"left")),this._lastDirectionY=this.directionY,this._lastDirectionX=this.directionX,this.trigger(e.events.SCROLL_PROGRESS),void(p.animationFrame?this.nextFrameID=window.requestAnimationFrame(this.onNextFrame):this._nextTimeout=setTimeout(function(){t.onNextFrame()},1e3/60)))},e.prototype.onScrollStop=function(){this._scrolling=!1,this.updateScrollPosition(),this.trigger(e.events.SCROLL_STOP),this._canScrollY&&(this.y<=0?this.trigger(e.events.SCROLL_MIN):this.y+this.clientHeight>=this.scrollHeight&&this.trigger(e.events.SCROLL_MAX)),this._canScrollX&&(this.x<=0?this.trigger(e.events.SCROLL_MIN):this.x+this.clientWidth>=this.scrollWidth&&this.trigger(e.events.SCROLL_MAX)),this._cancelNextFrame()},e.prototype._cancelNextFrame=function(){this._currentStopFrames=0,p.animationFrame?(window.cancelAnimationFrame(this.nextFrameID),this.nextFrameID=-1):clearTimeout(this._nextTimeout)},l(e,[{key:"destroyed",get:function(){return this._destroyed}},{key:"scrollPosition",get:function(){return this.getScrollPosition()}},{key:"directionY",get:function(){return!this._canScrollY||0===this.speedY&&!this._scrolling?this._directionY=e.direction.none:this.speedY>0?this._directionY=e.direction.up:this.speedY<0&&(this._directionY=e.direction.down),this._directionY}},{key:"directionX",get:function(){return!this._canScrollX||0===this.speedX&&!this._scrolling?this._directionX=e.direction.none:this.speedX>0?this._directionX=e.direction.left:this.speedX<0&&(this._directionX=e.direction.right),this._directionX}},{key:"scrollTarget",get:function(){return this._scrollTarget}},{key:"scrolling",get:function(){return this._scrolling}},{key:"speedY",get:function(){return this._speedY}},{key:"speedX",get:function(){return this._speedX}},{key:"canScrollY",get:function(){return this._canScrollY}},{key:"canScrollX",get:function(){return this._canScrollX}},{key:"y",get:function(){return this.scrollPosition.y}},{key:"x",get:function(){return this.scrollPosition.x}},{key:"clientHeight",get:function(){return this._scrollTarget===window?window.innerHeight:this._scrollTarget.clientHeight}},{key:"clientWidth",get:function(){return this._scrollTarget===window?window.innerWidth:this._scrollTarget.clientWidth}},{key:"scrollHeight",get:function(){return this._scrollTarget===window?e.documentHeight:this._scrollTarget.scrollHeight}},{key:"scrollWidth",get:function(){return this._scrollTarget===window?e.documentWidth:this._scrollTarget.scrollWidth}}]),e}(a["default"]);f.direction={up:-1,down:1,none:0,right:2,left:-2},f.events={SCROLL_PROGRESS:"scroll:progress",SCROLL_START:"scroll:start",SCROLL_STOP:"scroll:stop",SCROLL_DOWN:"scroll:down",SCROLL_UP:"scroll:up",SCROLL_MIN:"scroll:min",SCROLL_MAX:"scroll:max",SCROLL_RESIZE:"scroll:resize"},i["default"]=f;var g=null,p=function(){function t(){r(this,t)}return l(t,null,[{key:"animationFrame",get:function(){return null===g&&(g=!!(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)),g}}]),t}();e.exports=i["default"]},{"./scroll-parent":4,eventdispatcher:2}]},{},[5])(5)});
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.ScrollFeatures=t()}}(function(){return function t(e,i,n){function r(s,l){if(!i[s]){if(!e[s]){var c="function"==typeof require&&require;if(!l&&c)return c(s,!0);if(o)return o(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var h=i[s]={exports:{}};e[s][0].call(h.exports,function(t){var i=e[s][1][t];return r(i?i:t)},h,h.exports,t,e,i,n)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)r(n[s]);return r}({1:[function(t,e,i){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t){return t?0===Object.keys(t).length:!0}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e.target,r=e.currentTarget;n(this,t),this.target=i||this,this.currentTarget=r||this,this.eventMap={},this.destroyed=!1,this.on=this.bind=this.addEventListener=this.addListener,this.off=this.unbind=this.removeEventListener=this.removeListener,this.once=this.one=this.addListenerOnce,this.emit=this.trigger=this.dispatchEvent=this.dispatch}return t.prototype.addListener=function(t,e){var i=this.getListener(t);return i?-1===i.indexOf(e)&&i.push(e):this.eventMap[t]=[e],this},t.prototype.addListenerOnce=function(t,e){var i=this,n=function r(n){e(n),i.off(t,r)};return this.on(t,n)},t.prototype.removeListener=function(t,e){if(!e)return this.removeAllListener(t);var i=this.getListener(t);if(i){var n=i.indexOf(e);n>-1&&(i.splice(n,1),i.length||delete this.eventMap[t])}return this},t.prototype.removeAllListener=function(t){var e=this.getListener(t);return e&&(this.eventMap[t].length=0,delete this.eventMap[t]),this},t.prototype.hasListener=function(t){return null!==this.getListener(t)},t.prototype.hasListeners=function(){return null!==this.eventMap&&void 0!==this.eventMap&&!r(this.eventMap)},t.prototype.dispatch=function(t,e){var i=this.getListener(t);if(i){var n=e||{};n.type=t,n.target=n.target||this.target,n.currentTarget=n.currentTarget||this.currentTarget;for(var r=-1;++r<i.length;)i[r](n)}return this},t.prototype.getListener=function(t){var e=this.eventMap?this.eventMap[t]:null;return e||null},t.prototype.destroy=function(){if(this.eventMap)for(var t=Object.keys(this.eventMap),e=0;e<t.length;e++)this.removeAllListener(t[e]);return this.eventMap=null,this.destroyed=!0,this},t}();i["default"]=o,e.exports=i["default"]},{}],2:[function(t,e){"use strict";var i=/(auto|scroll)/,n=function(t){var e=window.getComputedStyle(t,null);return i.test(e.getPropertyValue("overflow")+e.getPropertyValue("overflow-y")+e.getPropertyValue("overflow-x"))};e.exports=n},{}],3:[function(t,e){"use strict";var i=t("./has-overflow"),n=function(t){if(!(t instanceof HTMLElement))return window;for(;t.parentNode;){if(t.parentNode===document.body)return window;if(i(t.parentNode))return t.parentNode;t=t.parentNode}return window};e.exports=n},{"./has-overflow":2}],4:[function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(i,"__esModule",{value:!0});var l=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),c=t("eventdispatcher"),a=n(c),h=t("./scroll-parent"),u=n(h),d=function(){window.requestAnimationFrame||(window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,window.cancelAnimationFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame)},f=function(t){function e(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(r(this,e),e.hasInstance(i)){var s;return s=e.getInstance(i),o(l,s)}var l=o(this,t.call(this,{target:i}));return l._scrollTarget=null,l._y=0,l._x=0,l._speedY=0,l._speedX=0,l._lastSpeed=0,l._lastDirectionY=e.direction.none,l._lastDirectionX=e.direction.none,l._stopFrames=3,l._currentStopFrames=0,l._firstRender=!0,l._directionY=e.direction.none,l._directionX=e.direction.none,l._scrolling=!1,l._canScrollY=!1,l._canScrollX=!1,i.scrollFeatures=l,l._scrollTarget=i,l.options=n,p.animationFrame&&d(),l.init(),l}return s(e,t),e.getInstance=function(t,i){return t.scrollFeatures?t.scrollFeatures:new e(t,i)},e.hasInstance=function(t){return"undefined"!=typeof t.scrollFeatures},e.getScrollParent=function(t){return u["default"](t)},l(e,null,[{key:"windowY",get:function(){return window.pageYOffset||window.scrollY||0}},{key:"windowX",get:function(){return window.pageXOffset||window.scrollX||0}},{key:"documentHeight",get:function(){return Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)}},{key:"documentWidth",get:function(){return Math.max(document.body.scrollWidth,document.body.offsetWidth,document.documentElement.clientWidth,document.documentElement.scrollWidth,document.documentElement.offsetWidth)}}]),e.prototype.init=function(){var t=this;if(this.getScrollPosition=this._scrollTarget===window?function(){return{y:e.windowY,x:e.windowX}}.bind(this):function(){return{y:this._scrollTarget.scrollTop,x:this._scrollTarget.scrollLeft}}.bind(this),this.onResize=function(){t.trigger(e.events.SCROLL_RESIZE)},this.onScroll=this.onScroll.bind(this),this.onNextFrame=this.onNextFrame.bind(this),this.updateScrollPosition(),this._scrollTarget!==window){var i=/(auto|scroll)/,n=window.getComputedStyle(this._scrollTarget,null);this._canScrollY=i.test(n.getPropertyValue("overflow-y")),this._canScrollX=i.test(n.getPropertyValue("overflow-x"))}else this._canScrollY=this.clientHeight<this.scrollHeight,this._canScrollX=this.clientWidth<this.scrollWidth;this._scrollTarget.addEventListener?(this._scrollTarget.addEventListener("scroll",this.onScroll,!1),this._scrollTarget.addEventListener("resize",this.onResize,!1)):this._scrollTarget.attachEvent&&(this._scrollTarget.attachEvent("scroll",this.onScroll),this._scrollTarget.attachEvent("resize",this.onResize))},e.prototype.destroy=function(){this._cancelNextFrame(),t.prototype.destroy.call(this),this._scrollTarget&&(this._scrollTarget.addEventListener?(this._scrollTarget.removeEventListener("scroll",this.onScroll),this._scrollTarget.removeEventListener("resize",this.onResize)):this._scrollTarget.attachEvent&&(this._scrollTarget.detachEvent("scroll",this.onScroll),this._scrollTarget.detachEvent("resize",this.onResize))),this.onResize=null,this.onScroll=null,this.getScrollPosition=null,this.onNextFrame=null,delete this._scrollTarget.scrollFeatures,this._scrollTarget=null},e.prototype.updateScrollPosition=function(){this._y=this.y,this._x=this.x},e.prototype.onScroll=function(){return this._currentStopFrames=0,this._firstRender&&(this._firstRender=!1,this.y>1||this.x>1)?(this.updateScrollPosition(),void this.trigger(e.events.SCROLL_PROGRESS)):void(this._scrolling||(this._scrolling=!0,this._lastDirectionY=e.direction.none,this._lastDirectionX=e.direction.none,this.trigger(e.events.SCROLL_START),p.animationFrame?this.nextFrameID=window.requestAnimationFrame(this.onNextFrame):this.onNextFrame()))},e.prototype.onNextFrame=function(){var t=this;this._speedY=this._y-this.y,this._speedX=this._x-this.x;var i=+this.speedY+ +this.speedX;return this._scrolling&&0===i&&this._currentStopFrames++>this._stopFrames?void this.onScrollStop():(this.updateScrollPosition(),this._lastDirectionY!==this.directionY&&this.trigger("scroll:"+(this.directionY===e.direction.down?"down":"up")),this._lastDirectionX!==this.directionX&&this.trigger("scroll:"+(this.directionX===e.direction.right?"right":"left")),this._lastDirectionY=this.directionY,this._lastDirectionX=this.directionX,this.trigger(e.events.SCROLL_PROGRESS),void(p.animationFrame?this.nextFrameID=window.requestAnimationFrame(this.onNextFrame):this._nextTimeout=setTimeout(function(){t.onNextFrame()},1e3/60)))},e.prototype.onScrollStop=function(){this._scrolling=!1,this.updateScrollPosition(),this.trigger(e.events.SCROLL_STOP),this._canScrollY&&(this.y<=0?this.trigger(e.events.SCROLL_MIN):this.y+this.clientHeight>=this.scrollHeight&&this.trigger(e.events.SCROLL_MAX)),this._canScrollX&&(this.x<=0?this.trigger(e.events.SCROLL_MIN):this.x+this.clientWidth>=this.scrollWidth&&this.trigger(e.events.SCROLL_MAX)),this._cancelNextFrame()},e.prototype._cancelNextFrame=function(){this._currentStopFrames=0,p.animationFrame?(window.cancelAnimationFrame(this.nextFrameID),this.nextFrameID=-1):clearTimeout(this._nextTimeout)},l(e,[{key:"scrollPosition",get:function(){return this.getScrollPosition()}},{key:"directionY",get:function(){return!this._canScrollY||0===this.speedY&&!this._scrolling?this._directionY=e.direction.none:this.speedY>0?this._directionY=e.direction.up:this.speedY<0&&(this._directionY=e.direction.down),this._directionY}},{key:"directionX",get:function(){return!this._canScrollX||0===this.speedX&&!this._scrolling?this._directionX=e.direction.none:this.speedX>0?this._directionX=e.direction.left:this.speedX<0&&(this._directionX=e.direction.right),this._directionX}},{key:"scrollTarget",get:function(){return this._scrollTarget}},{key:"scrolling",get:function(){return this._scrolling}},{key:"speedY",get:function(){return this._speedY}},{key:"speedX",get:function(){return this._speedX}},{key:"canScrollY",get:function(){return this._canScrollY}},{key:"canScrollX",get:function(){return this._canScrollX}},{key:"y",get:function(){return this.scrollPosition.y}},{key:"x",get:function(){return this.scrollPosition.x}},{key:"clientHeight",get:function(){return this._scrollTarget===window?window.innerHeight:this._scrollTarget.clientHeight}},{key:"clientWidth",get:function(){return this._scrollTarget===window?window.innerWidth:this._scrollTarget.clientWidth}},{key:"scrollHeight",get:function(){return this._scrollTarget===window?e.documentHeight:this._scrollTarget.scrollHeight}},{key:"scrollWidth",get:function(){return this._scrollTarget===window?e.documentWidth:this._scrollTarget.scrollWidth}}]),e}(a["default"]);f.direction={up:-1,down:1,none:0,right:2,left:-2},f.events={SCROLL_PROGRESS:"scroll:progress",SCROLL_START:"scroll:start",SCROLL_STOP:"scroll:stop",SCROLL_DOWN:"scroll:down",SCROLL_UP:"scroll:up",SCROLL_MIN:"scroll:min",SCROLL_MAX:"scroll:max",SCROLL_RESIZE:"scroll:resize"},i["default"]=f;var g=null,p=function(){function t(){r(this,t)}return l(t,null,[{key:"animationFrame",get:function(){return null===g&&(g=!!(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)),g}}]),t}();e.exports=i["default"]},{"./scroll-parent":3,eventdispatcher:1}]},{},[4])(4)});
{
"name": "scrollfeatures",
"version": "1.4.2",
"version": "1.5.0",
"description": "Performant Custom Scroll Features and Events",
"main": "lib/scrollfeatures.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build-js": "browserify --fast -e src/scrollfeatures.js -d --standalone ScrollFeatures -t babelify | derequire | exorcist dist/scrollfeatures.min.js.map > dist/scrollfeatures.min.js",
"build-js": "browserify --fast -e src/scrollfeatures.js -d --standalone ScrollFeatures -t babelify | exorcist dist/scrollfeatures.min.js.map > dist/scrollfeatures.min.js",
"dist-js": "BABEL_ENV=production NODE_ENV=production browserify -e src/scrollfeatures.js --standalone ScrollFeatures -t babelify | derequire > dist/scrollfeatures.min.js",
"dist-js-min": "uglifyjs -cmv dist/scrollfeatures.min.js -o dist/scrollfeatures.min.js",
"dist": "cp src/scrollfeatures.css dist/ && npm run dist-js && npm run dist-js-min && npm run build-lib",
"start": "run-p watch-js server",
"build-lib": "BABEL_ENV=production babel src -d dist",
"start": "cp src/scrollfeatures.css dist/ && run-s build-js && run-p watch-js server",
"build-lib": "BABEL_ENV=production babel src -d lib",
"watch-js": "watchify -d --poll=100 --fast --standalone ScrollFeatures -e src/scrollfeatures.js -t babelify -o 'exorcist dist/scrollfeatures.min.js.map > dist/scrollfeatures.min.js' -v",

@@ -50,25 +51,18 @@ "server": "browser-sync start --no-ghost-mode --server --directory --files 'demo/**/**, dist/*.js' --startPath demo/index.html"

"dependencies": {
"eventdispatcher": "2.1.0"
"eventdispatcher": "2.1.2"
},
"devDependencies": {
"babel-cli": "6.16.0",
"babel-core": "6.17.0",
"babel-cli": "6.18.0",
"babel-core": "6.18.2",
"babel-plugin-add-module-exports": "0.2.1",
"babel-plugin-transform-class-constructor-call": "6.8.0",
"babel-plugin-transform-class-properties": "6.16.0",
"babel-plugin-transform-decorators-legacy": "1.3.4",
"babel-plugin-transform-es2015-classes": "6.14.0",
"babel-plugin-transform-es2015-modules-commonjs": "6.16.0",
"babel-plugin-transform-es5-property-mutators": "6.8.0",
"babel-plugin-transform-proto-to-assign": "6.9.0",
"babel-plugin-transform-remove-console": "6.8.0",
"babel-preset-es2015": "6.16.0",
"babel-preset-es2015-allow-top-level-this": "0.0.1",
"babel-preset-stage-0": "6.16.0",
"babel-plugin-transform-class-constructor-call": "6.18.0",
"babel-plugin-transform-class-properties": "6.19.0",
"babel-plugin-transform-es2015-classes": "6.18.0",
"babel-preset-es2015": "6.18.0",
"babelify": "7.3.0",
"browser-sync": "2.17.0",
"browserify": "13.1.0",
"browser-sync": "2.18.2",
"browserify": "13.1.1",
"derequire": "2.0.3",
"exorcist": "0.4.0",
"npm-run-all": "3.1.0",
"npm-run-all": "3.1.1",
"uglifyjs": "2.4.10",

@@ -75,0 +69,0 @@ "watchify": "3.7.0"

@@ -13,5 +13,3 @@ import EventDispatcher from 'eventdispatcher';

_scrollTarget = null;
_destroyed = false;
_y = 0;

@@ -49,3 +47,3 @@ _x = 0;

static get windowY() {
return (window.pageYOffset || window.y || 0);
return (window.pageYOffset || window.scrollY || 0);
}

@@ -106,5 +104,8 @@

this.getScrollPosition = (this._scrollTarget === window ? (function(){return { y: ScrollFeatures.windowY, x: ScrollFeatures.windowX }}.bind(this)) : (function() {return { y: this._scrollTarget.scrollTop, x: this._scrollTarget.scrollLeft}}.bind(this)));
this.getScrollPosition = (this._scrollTarget === window ? (function() {
return { y: ScrollFeatures.windowY, x: ScrollFeatures.windowX } }.bind(this)) : (function() {
return { y: this._scrollTarget.scrollTop, x: this._scrollTarget.scrollLeft }
}.bind(this)));
this.onResize = ()=>{
this.onResize = () => {
this.trigger(ScrollFeatures.events.SCROLL_RESIZE);

@@ -136,12 +137,10 @@ }

get destroyed() {
return this._destroyed;
}
destroy() {
if (!this._destroyed) {
this._cancelNextFrame();
super.destroy();
this._cancelNextFrame();
super.destroy();
if(this._scrollTarget){
if (this._scrollTarget.addEventListener) {

@@ -154,11 +153,10 @@ this._scrollTarget.removeEventListener('scroll', this.onScroll);

}
}
this.onResize = null;
this.onScroll = null;
this.getScrollPosition = null;
this.onNextFrame = null;
delete this._scrollTarget.scrollFeatures;
this._scrollTarget = null;
this._destroyed = true;
}
this.onResize = null;
this.onScroll = null;
this.getScrollPosition = null;
this.onNextFrame = null;
delete this._scrollTarget.scrollFeatures;
this._scrollTarget = null;
}

@@ -165,0 +163,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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