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

@better-scroll/mouse-wheel

Package Overview
Dependencies
Maintainers
3
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@better-scroll/mouse-wheel - npm Package Compare versions

Comparing version 2.4.1 to 2.4.2

4

dist/mouse-wheel.esm.js

@@ -345,3 +345,5 @@ /*!

if (!this.scroll.hasVerticalScroll) {
wheelDeltaX = wheelDeltaY;
if (Math.abs(wheelDeltaY) > Math.abs(wheelDeltaX)) {
wheelDeltaX = wheelDeltaY;
}
wheelDeltaY = 0;

@@ -348,0 +350,0 @@ }

@@ -351,3 +351,5 @@ /*!

if (!this.scroll.hasVerticalScroll) {
wheelDeltaX = wheelDeltaY;
if (Math.abs(wheelDeltaY) > Math.abs(wheelDeltaX)) {
wheelDeltaX = wheelDeltaY;
}
wheelDeltaY = 0;

@@ -354,0 +356,0 @@ }

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).MouseWheel=t()}(this,function(){"use strict";var i="undefined"!=typeof window,t=i&&navigator.userAgent.toLowerCase();t&&/wechatdevtools/.test(t),t&&t.indexOf("android"),function(){if("string"==typeof t){var e=/os (\d\d?_\d(_\d)?)/.exec(t);if(!e)return;e=e[1].split("_").map(function(e){return parseInt(e,10)});13===e[0]&&e[1]}}();var r=!1;if(i)try{var e={};Object.defineProperty(e,"passive",{get:function(){r=!0}}),window.addEventListener("test-passive",function(){},e)}catch(e){}var n=i&&document.createElement("div").style,o=function(){if(!i)return!1;for(var e=0,t=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}];e<t.length;e++){var o=t[e];if(void 0!==n[o.value])return o.key}return!1}();function s(e){return!1===o?e:"standard"===o?"transitionEnd"===e?"transitionend":e:o+e.charAt(0).toUpperCase()+e.substr(1)}function l(e,t,o,i){i=r?{passive:!1,capture:!!i}:!!i;e.addEventListener(t,o,i)}function a(e,t,o,i){e.removeEventListener(t,o,{capture:!!i})}o&&"standard"!==o&&o.toLowerCase();s("transform"),s("transition");i&&s("perspective")in n,s("transitionTimingFunction"),s("transitionDuration"),s("transitionDelay"),s("transformOrigin"),s("transitionEnd"),s("transitionProperty");var h=(c.prototype.destroy=function(){this.removeDOMEvents(),this.events=[]},c.prototype.addDOMEvents=function(){this.handleDOMEvents(l)},c.prototype.removeDOMEvents=function(){this.handleDOMEvents(a)},c.prototype.handleDOMEvents=function(t){var o=this,i=this.wrapper;this.events.forEach(function(e){t(i,e.name,o,!!e.capture)})},c.prototype.handleEvent=function(t){var o=t.type;this.events.some(function(e){return e.name===o&&(e.handler(t),!0)})},c);function c(e,t){this.wrapper=e,this.events=t,this.addDOMEvents()}function d(e){this.scroll=e,this.wheelEndTimer=0,this.wheelMoveTimer=0,this.wheelStart=!1,this.init()}return d.prototype.init=function(){this.handleBScroll(),this.handleOptions(),this.handleHooks(),this.registerEvent()},d.prototype.handleBScroll=function(){this.scroll.registerType(["alterOptions","mousewheelStart","mousewheelMove","mousewheelEnd"])},d.prototype.handleOptions=function(){var e=!0===this.scroll.options.mouseWheel?{}:this.scroll.options.mouseWheel;this.mouseWheelOpt=function(e,t){for(var o in t)e[o]=t[o];return e}({speed:20,invert:!1,easeTime:300,discreteTime:400,throttleTime:0,dampingFactor:.1},e)},d.prototype.handleHooks=function(){this.hooksFn=[],this.registerHooks(this.scroll.hooks,"destroy",this.destroy)},d.prototype.registerEvent=function(){this.eventRegister=new h(this.scroll.scroller.wrapper,[{name:"wheel",handler:this.wheelHandler.bind(this)},{name:"mousewheel",handler:this.wheelHandler.bind(this)},{name:"DOMMouseScroll",handler:this.wheelHandler.bind(this)}])},d.prototype.registerHooks=function(e,t,o){e.on(t,o,this),this.hooksFn.push([e,t,o])},d.prototype.wheelHandler=function(e){this.scroll.enabled&&(this.beforeHandler(e),this.wheelStart||(this.wheelStartHandler(e),this.wheelStart=!0),e=this.getWheelDelta(e),this.wheelMoveHandler(e),this.wheelEndDetector(e))},d.prototype.wheelStartHandler=function(e){this.cleanCache();var t=this.scroll.scroller,o=t.scrollBehaviorX,t=t.scrollBehaviorY;o.setMovingDirection(0),t.setMovingDirection(0),o.setDirection(0),t.setDirection(0),this.scroll.trigger(this.scroll.eventTypes.alterOptions,this.mouseWheelOpt),this.scroll.trigger(this.scroll.eventTypes.mousewheelStart)},d.prototype.cleanCache=function(){this.deltaCache=[]},d.prototype.wheelMoveHandler=function(e){var t,o,i=this,r=this.mouseWheelOpt,n=r.throttleTime,s=r.dampingFactor;n&&this.wheelMoveTimer?this.deltaCache.push(e):(o=this.deltaCache.reduce(function(e,t){return{x:e.x+t.x,y:e.y+t.y}},{x:0,y:0}),this.cleanCache(),r=(t=this.scroll.scroller).scrollBehaviorX,t=t.scrollBehaviorY,r.setMovingDirection(-e.directionX),t.setMovingDirection(-e.directionY),r.setDirection(e.x),t.setDirection(e.y),r=r.performDampingAlgorithm(Math.round(e.x)+o.x,s),o=t.performDampingAlgorithm(Math.round(e.y)+o.x,s),this.scroll.trigger(this.scroll.eventTypes.mousewheelMove,{x:r,y:o})||(s=this.getEaseTime(),r===this.scroll.x&&o===this.scroll.y||this.scroll.scrollTo(r,o,s)),n&&(this.wheelMoveTimer=window.setTimeout(function(){i.wheelMoveTimer=0},n)))},d.prototype.wheelEndDetector=function(e){var t=this;window.clearTimeout(this.wheelEndTimer),this.wheelEndTimer=window.setTimeout(function(){t.wheelStart=!1,window.clearTimeout(t.wheelMoveTimer),t.wheelMoveTimer=0,t.scroll.trigger(t.scroll.eventTypes.mousewheelEnd,e)},this.mouseWheelOpt.discreteTime)},d.prototype.getWheelDelta=function(e){var t=this.mouseWheelOpt,o=t.speed,i=0,r=0,t=t.invert?-1:1;switch(!0){case"deltaX"in e:r=1===e.deltaMode?(i=-e.deltaX*o,-e.deltaY*o):(i=-e.deltaX,-e.deltaY);break;case"wheelDeltaX"in e:i=e.wheelDeltaX/120*o,r=e.wheelDeltaY/120*o;break;case"wheelDelta"in e:i=r=e.wheelDelta/120*o;break;case"detail"in e:i=r=-e.detail/3*o}return i*=t,r*=t,this.scroll.hasVerticalScroll||(i=r,r=0),{x:i=!this.scroll.hasHorizontalScroll?0:i,y:r,directionX:0<i?-1:i<0?1:0,directionY:0<r?-1:r<0?1:0}},d.prototype.beforeHandler=function(e){var t=this.scroll.options,o=t.preventDefault,i=t.stopPropagation,t=t.preventDefaultException;o&&!function(e,t){for(var o in t)if(t[o].test(e[o]))return 1}(e.target,t)&&e.preventDefault(),i&&e.stopPropagation()},d.prototype.getEaseTime=function(){var e=this.mouseWheelOpt.easeTime;return e<100&&console.error("[BScroll warn]: easeTime should be greater than 100.If mouseWheel easeTime is too small,scrollEnd will be triggered many times."),Math.max(e,100)},d.prototype.destroy=function(){this.eventRegister.destroy(),window.clearTimeout(this.wheelEndTimer),window.clearTimeout(this.wheelMoveTimer),this.hooksFn.forEach(function(e){var t=e[0],o=e[1],e=e[2];t.off(o,e)})},d.pluginName="mouseWheel",d.applyOrder="pre",d});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).MouseWheel=t()}(this,function(){"use strict";var i="undefined"!=typeof window,t=i&&navigator.userAgent.toLowerCase();t&&/wechatdevtools/.test(t),t&&t.indexOf("android"),function(){if("string"==typeof t){var e=/os (\d\d?_\d(_\d)?)/.exec(t);if(!e)return;e=e[1].split("_").map(function(e){return parseInt(e,10)});13===e[0]&&e[1]}}();var r=!1;if(i)try{var e={};Object.defineProperty(e,"passive",{get:function(){r=!0}}),window.addEventListener("test-passive",function(){},e)}catch(e){}var n=i&&document.createElement("div").style,o=function(){if(!i)return!1;for(var e=0,t=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}];e<t.length;e++){var o=t[e];if(void 0!==n[o.value])return o.key}return!1}();function s(e){return!1===o?e:"standard"===o?"transitionEnd"===e?"transitionend":e:o+e.charAt(0).toUpperCase()+e.substr(1)}function l(e,t,o,i){i=r?{passive:!1,capture:!!i}:!!i;e.addEventListener(t,o,i)}function a(e,t,o,i){e.removeEventListener(t,o,{capture:!!i})}o&&"standard"!==o&&o.toLowerCase();s("transform"),s("transition");i&&s("perspective")in n,s("transitionTimingFunction"),s("transitionDuration"),s("transitionDelay"),s("transformOrigin"),s("transitionEnd"),s("transitionProperty");var h=(c.prototype.destroy=function(){this.removeDOMEvents(),this.events=[]},c.prototype.addDOMEvents=function(){this.handleDOMEvents(l)},c.prototype.removeDOMEvents=function(){this.handleDOMEvents(a)},c.prototype.handleDOMEvents=function(t){var o=this,i=this.wrapper;this.events.forEach(function(e){t(i,e.name,o,!!e.capture)})},c.prototype.handleEvent=function(t){var o=t.type;this.events.some(function(e){return e.name===o&&(e.handler(t),!0)})},c);function c(e,t){this.wrapper=e,this.events=t,this.addDOMEvents()}function d(e){this.scroll=e,this.wheelEndTimer=0,this.wheelMoveTimer=0,this.wheelStart=!1,this.init()}return d.prototype.init=function(){this.handleBScroll(),this.handleOptions(),this.handleHooks(),this.registerEvent()},d.prototype.handleBScroll=function(){this.scroll.registerType(["alterOptions","mousewheelStart","mousewheelMove","mousewheelEnd"])},d.prototype.handleOptions=function(){var e=!0===this.scroll.options.mouseWheel?{}:this.scroll.options.mouseWheel;this.mouseWheelOpt=function(e,t){for(var o in t)e[o]=t[o];return e}({speed:20,invert:!1,easeTime:300,discreteTime:400,throttleTime:0,dampingFactor:.1},e)},d.prototype.handleHooks=function(){this.hooksFn=[],this.registerHooks(this.scroll.hooks,"destroy",this.destroy)},d.prototype.registerEvent=function(){this.eventRegister=new h(this.scroll.scroller.wrapper,[{name:"wheel",handler:this.wheelHandler.bind(this)},{name:"mousewheel",handler:this.wheelHandler.bind(this)},{name:"DOMMouseScroll",handler:this.wheelHandler.bind(this)}])},d.prototype.registerHooks=function(e,t,o){e.on(t,o,this),this.hooksFn.push([e,t,o])},d.prototype.wheelHandler=function(e){this.scroll.enabled&&(this.beforeHandler(e),this.wheelStart||(this.wheelStartHandler(e),this.wheelStart=!0),e=this.getWheelDelta(e),this.wheelMoveHandler(e),this.wheelEndDetector(e))},d.prototype.wheelStartHandler=function(e){this.cleanCache();var t=this.scroll.scroller,o=t.scrollBehaviorX,t=t.scrollBehaviorY;o.setMovingDirection(0),t.setMovingDirection(0),o.setDirection(0),t.setDirection(0),this.scroll.trigger(this.scroll.eventTypes.alterOptions,this.mouseWheelOpt),this.scroll.trigger(this.scroll.eventTypes.mousewheelStart)},d.prototype.cleanCache=function(){this.deltaCache=[]},d.prototype.wheelMoveHandler=function(e){var t,o,i=this,r=this.mouseWheelOpt,n=r.throttleTime,s=r.dampingFactor;n&&this.wheelMoveTimer?this.deltaCache.push(e):(o=this.deltaCache.reduce(function(e,t){return{x:e.x+t.x,y:e.y+t.y}},{x:0,y:0}),this.cleanCache(),r=(t=this.scroll.scroller).scrollBehaviorX,t=t.scrollBehaviorY,r.setMovingDirection(-e.directionX),t.setMovingDirection(-e.directionY),r.setDirection(e.x),t.setDirection(e.y),r=r.performDampingAlgorithm(Math.round(e.x)+o.x,s),o=t.performDampingAlgorithm(Math.round(e.y)+o.x,s),this.scroll.trigger(this.scroll.eventTypes.mousewheelMove,{x:r,y:o})||(s=this.getEaseTime(),r===this.scroll.x&&o===this.scroll.y||this.scroll.scrollTo(r,o,s)),n&&(this.wheelMoveTimer=window.setTimeout(function(){i.wheelMoveTimer=0},n)))},d.prototype.wheelEndDetector=function(e){var t=this;window.clearTimeout(this.wheelEndTimer),this.wheelEndTimer=window.setTimeout(function(){t.wheelStart=!1,window.clearTimeout(t.wheelMoveTimer),t.wheelMoveTimer=0,t.scroll.trigger(t.scroll.eventTypes.mousewheelEnd,e)},this.mouseWheelOpt.discreteTime)},d.prototype.getWheelDelta=function(e){var t=this.mouseWheelOpt,o=t.speed,i=0,r=0,t=t.invert?-1:1;switch(!0){case"deltaX"in e:r=1===e.deltaMode?(i=-e.deltaX*o,-e.deltaY*o):(i=-e.deltaX,-e.deltaY);break;case"wheelDeltaX"in e:i=e.wheelDeltaX/120*o,r=e.wheelDeltaY/120*o;break;case"wheelDelta"in e:i=r=e.wheelDelta/120*o;break;case"detail"in e:i=r=-e.detail/3*o}return i*=t,r*=t,this.scroll.hasVerticalScroll||(Math.abs(r)>Math.abs(i)&&(i=r),r=0),{x:i=!this.scroll.hasHorizontalScroll?0:i,y:r,directionX:0<i?-1:i<0?1:0,directionY:0<r?-1:r<0?1:0}},d.prototype.beforeHandler=function(e){var t=this.scroll.options,o=t.preventDefault,i=t.stopPropagation,t=t.preventDefaultException;o&&!function(e,t){for(var o in t)if(t[o].test(e[o]))return 1}(e.target,t)&&e.preventDefault(),i&&e.stopPropagation()},d.prototype.getEaseTime=function(){var e=this.mouseWheelOpt.easeTime;return e<100&&console.error("[BScroll warn]: easeTime should be greater than 100.If mouseWheel easeTime is too small,scrollEnd will be triggered many times."),Math.max(e,100)},d.prototype.destroy=function(){this.eventRegister.destroy(),window.clearTimeout(this.wheelEndTimer),window.clearTimeout(this.wheelMoveTimer),this.hooksFn.forEach(function(e){var t=e[0],o=e[1],e=e[2];t.off(o,e)})},d.pluginName="mouseWheel",d.applyOrder="pre",d});
{
"name": "@better-scroll/mouse-wheel",
"version": "2.4.1",
"version": "2.4.2",
"description": "support for MouseWheel in PC",

@@ -33,5 +33,5 @@ "author": {

"dependencies": {
"@better-scroll/core": "^2.4.1"
"@better-scroll/core": "^2.4.2"
},
"gitHead": "60637c0ad50b0810156f9bfb8a2c7306493e5026"
"gitHead": "c97e67ecf15e616d998e67aa4ce15a7c429691c3"
}

@@ -253,3 +253,5 @@ import BScroll from '@better-scroll/core'

if (!this.scroll.hasVerticalScroll) {
wheelDeltaX = wheelDeltaY
if(Math.abs(wheelDeltaY) > Math.abs(wheelDeltaX)){
wheelDeltaX = wheelDeltaY
}
wheelDeltaY = 0

@@ -256,0 +258,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