wheel-gestures
Advanced tools
Comparing version 2.2.2 to 2.2.3
@@ -235,3 +235,3 @@ 'use strict'; | ||
return config = deepFreeze(_extends({}, configDefaults, {}, config, {}, newOptions)); | ||
return config = deepFreeze(_extends({}, configDefaults, config, newOptions)); | ||
}; | ||
@@ -238,0 +238,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0});var e=function(t,e){return void 0===e&&(e=.996),t*e/(1-e)};function n(t){return t[t.length-1]}function i(t){return t.reduce((function(t,e){return t+e}))/t.length}var r=function(t,e,n){return Math.min(Math.max(e,t),n)};function o(t,e){if(t.length!==e.length)throw new Error("vectors must be same length");return t.map((function(t,n){return t+e[n]}))}function a(t){return Math.max.apply(Math,t.map(Math.abs))}function s(t){return Object.freeze(t),Object.values(t).forEach((function(t){null===t||"object"!=typeof t||Object.isFrozen(t)||s(t)})),t}var u=[1,18,"undefined"!=typeof window&&window.innerHeight||800],c=[-1,-1,-1],l=s({preventWheelAction:!0,reverseSign:[!0,!0,!1]});function f(f){void 0===f&&(f={});var m,d,p,v=function(){var t={};function e(e,n){t[e]=(t[e]||[]).filter((function(t){return t!==n}))}return s({on:function(n,i){return t[n]=(t[n]||[]).concat(i),function(){return e(n,i)}},off:e,dispatch:function(e,n){e in t&&t[e].forEach((function(t){return t(n)}))}})}(),h=v.on,x=v.off,M=v.dispatch,b=l,g={isStarted:!1,isStartPublished:!1,isMomentum:!1,startTime:0,lastAbsDelta:Infinity,axisMovement:[0,0,0],axisVelocity:[0,0,0],accelerationFactors:[],scrollPoints:[],scrollPointsToMerge:[],willEndTimeout:400},S=!1,y=function(t){Array.isArray(t)?t.forEach((function(t){return T(t)})):T(t)},D=function(e){return void 0===e&&(e={}),Object.values(e).some((function(t){return null==t}))?b:b=s(t({},l,{},b,{},e))},P=function(n){var i=t({event:m,isStart:!1,isEnding:!1,isMomentumCancel:!1,isMomentum:g.isMomentum,axisDelta:[0,0,0],axisVelocity:g.axisVelocity,axisMovement:g.axisMovement,get axisMovementProjection(){return o(i.axisMovement,i.axisVelocity.map((function(t){return e(t)})))}},n);M("wheel",t({},i,{previous:d})),d=i},T=function(e){var n,i=function(e){return t({},e,{axisDelta:e.axisDelta.map((function(t){return r(t,-700,700)}))})}(function(e,n){if(!n)return e;var i=!0===n?c:n.map((function(t){return t?-1:1}));return t({},e,{axisDelta:e.axisDelta.map((function(t,e){return t*i[e]}))})}({timeStamp:(n=e).timeStamp,axisDelta:[n.deltaX*u[n.deltaMode],n.deltaY*u[n.deltaMode],(n.deltaZ||0)*u[n.deltaMode]]},b.reverseSign)),s=i.axisDelta,l=i.timeStamp,f=a(s);e.preventDefault&&function(t,e){var n=b.preventWheelAction,i=e[0],r=e[1],o=e[2];if("boolean"==typeof n)return n;switch(n){case"x":return Math.abs(i)>=t;case"y":return Math.abs(r)>=t;case"z":return Math.abs(o)>=t;default:return!1}}(f,s)&&e.preventDefault(),g.isStarted?g.isMomentum&&f>Math.max(2,2*g.lastAbsDelta)&&(C(!0),z()):z(),0===f&&Object.is&&Object.is(e.deltaX,-0)?S=!0:(m=e,g.axisMovement=o(g.axisMovement,s),g.lastAbsDelta=f,g.scrollPointsToMerge.push({axisDelta:s,timeStamp:l}),w(),P({axisDelta:s,isStart:!g.isStartPublished}),g.isStartPublished=!0,W())},w=function(){2===g.scrollPointsToMerge.length?(g.scrollPoints.unshift({axisDeltaSum:g.scrollPointsToMerge.map((function(t){return t.axisDelta})).reduce(o),timeStamp:i(g.scrollPointsToMerge.map((function(t){return t.timeStamp})))}),j(),g.scrollPointsToMerge.length=0,g.scrollPoints.length=1,g.isMomentum||A()):g.isStartPublished||E()},E=function(){g.axisVelocity=n(g.scrollPointsToMerge).axisDelta.map((function(t){return t/g.willEndTimeout}))},j=function(){var t=g.scrollPoints,e=t[0],n=t[1];if(n&&e){var i=e.timeStamp-n.timeStamp;if(!(i<=0)){var r=e.axisDeltaSum.map((function(t){return t/i})),o=r.map((function(t,e){return t/(g.axisVelocity[e]||1)}));g.axisVelocity=r,g.accelerationFactors.push(o),O(i)}}},O=function(t){var e=10*Math.ceil(t/10)*1.2;g.isMomentum||(e=Math.max(100,2*e)),g.willEndTimeout=Math.min(1e3,Math.round(e))},V=function(t){return 0===t||t<=.96&&t>=.6},A=function(){if(g.accelerationFactors.length>=5){if(S&&(S=!1,a(g.axisVelocity)>=.2))return void F();var t=g.accelerationFactors.slice(-5);t.every((function(t){var e=!!t.reduce((function(t,e){return t&&t<1&&t===e?1:0})),n=t.filter(V).length===t.length;return e||n}))&&F(),g.accelerationFactors=t}},F=function(){g.isMomentum=!0},z=function(){(g={isStarted:!1,isStartPublished:!1,isMomentum:!1,startTime:0,lastAbsDelta:Infinity,axisMovement:[0,0,0],axisVelocity:[0,0,0],accelerationFactors:[],scrollPoints:[],scrollPointsToMerge:[],willEndTimeout:400}).isStarted=!0,g.startTime=Date.now(),d=void 0,S=!1},W=function(){clearTimeout(p),p=setTimeout(C,g.willEndTimeout)},C=function(t){void 0===t&&(t=!1),g.isStarted&&(P(g.isMomentum&&t?{isEnding:!0,isMomentumCancel:!0}:{isEnding:!0}),g.isMomentum=!1,g.isStarted=!1)},I=function(t){var e=[],n=function(n){n.removeEventListener("wheel",t),e=e.filter((function(t){return t!==n}))};return s({observe:function(i){return i.addEventListener("wheel",t,{passive:!1}),e.push(i),function(){return n(i)}},unobserve:n,disconnect:function(){e.forEach(n)}})}(y),L=I.observe,X=I.unobserve,_=I.disconnect;return D(f),s({on:h,off:x,observe:L,unobserve:X,disconnect:_,feedWheel:y,updateOptions:D})}exports.WheelGestures=f,exports.absMax=a,exports.addVectors=o,exports.average=i,exports.clamp=r,exports.configDefaults=l,exports.deepFreeze=s,exports.default=f,exports.lastOf=n,exports.projection=e; | ||
"use strict";function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0});var e=function(t,e){return void 0===e&&(e=.996),t*e/(1-e)};function n(t){return t[t.length-1]}function i(t){return t.reduce((function(t,e){return t+e}))/t.length}var r=function(t,e,n){return Math.min(Math.max(e,t),n)};function o(t,e){if(t.length!==e.length)throw new Error("vectors must be same length");return t.map((function(t,n){return t+e[n]}))}function a(t){return Math.max.apply(Math,t.map(Math.abs))}function s(t){return Object.freeze(t),Object.values(t).forEach((function(t){null===t||"object"!=typeof t||Object.isFrozen(t)||s(t)})),t}var u=[1,18,"undefined"!=typeof window&&window.innerHeight||800],c=[-1,-1,-1],l=s({preventWheelAction:!0,reverseSign:[!0,!0,!1]});function f(f){void 0===f&&(f={});var m,d,p,v=function(){var t={};function e(e,n){t[e]=(t[e]||[]).filter((function(t){return t!==n}))}return s({on:function(n,i){return t[n]=(t[n]||[]).concat(i),function(){return e(n,i)}},off:e,dispatch:function(e,n){e in t&&t[e].forEach((function(t){return t(n)}))}})}(),h=v.on,x=v.off,M=v.dispatch,b=l,g={isStarted:!1,isStartPublished:!1,isMomentum:!1,startTime:0,lastAbsDelta:Infinity,axisMovement:[0,0,0],axisVelocity:[0,0,0],accelerationFactors:[],scrollPoints:[],scrollPointsToMerge:[],willEndTimeout:400},S=!1,y=function(t){Array.isArray(t)?t.forEach((function(t){return T(t)})):T(t)},D=function(e){return void 0===e&&(e={}),Object.values(e).some((function(t){return null==t}))?b:b=s(t({},l,b,e))},P=function(n){var i=t({event:m,isStart:!1,isEnding:!1,isMomentumCancel:!1,isMomentum:g.isMomentum,axisDelta:[0,0,0],axisVelocity:g.axisVelocity,axisMovement:g.axisMovement,get axisMovementProjection(){return o(i.axisMovement,i.axisVelocity.map((function(t){return e(t)})))}},n);M("wheel",t({},i,{previous:d})),d=i},T=function(e){var n,i=function(e){return t({},e,{axisDelta:e.axisDelta.map((function(t){return r(t,-700,700)}))})}(function(e,n){if(!n)return e;var i=!0===n?c:n.map((function(t){return t?-1:1}));return t({},e,{axisDelta:e.axisDelta.map((function(t,e){return t*i[e]}))})}({timeStamp:(n=e).timeStamp,axisDelta:[n.deltaX*u[n.deltaMode],n.deltaY*u[n.deltaMode],(n.deltaZ||0)*u[n.deltaMode]]},b.reverseSign)),s=i.axisDelta,l=i.timeStamp,f=a(s);e.preventDefault&&function(t,e){var n=b.preventWheelAction,i=e[0],r=e[1],o=e[2];if("boolean"==typeof n)return n;switch(n){case"x":return Math.abs(i)>=t;case"y":return Math.abs(r)>=t;case"z":return Math.abs(o)>=t;default:return!1}}(f,s)&&e.preventDefault(),g.isStarted?g.isMomentum&&f>Math.max(2,2*g.lastAbsDelta)&&(C(!0),z()):z(),0===f&&Object.is&&Object.is(e.deltaX,-0)?S=!0:(m=e,g.axisMovement=o(g.axisMovement,s),g.lastAbsDelta=f,g.scrollPointsToMerge.push({axisDelta:s,timeStamp:l}),w(),P({axisDelta:s,isStart:!g.isStartPublished}),g.isStartPublished=!0,W())},w=function(){2===g.scrollPointsToMerge.length?(g.scrollPoints.unshift({axisDeltaSum:g.scrollPointsToMerge.map((function(t){return t.axisDelta})).reduce(o),timeStamp:i(g.scrollPointsToMerge.map((function(t){return t.timeStamp})))}),j(),g.scrollPointsToMerge.length=0,g.scrollPoints.length=1,g.isMomentum||A()):g.isStartPublished||E()},E=function(){g.axisVelocity=n(g.scrollPointsToMerge).axisDelta.map((function(t){return t/g.willEndTimeout}))},j=function(){var t=g.scrollPoints,e=t[0],n=t[1];if(n&&e){var i=e.timeStamp-n.timeStamp;if(!(i<=0)){var r=e.axisDeltaSum.map((function(t){return t/i})),o=r.map((function(t,e){return t/(g.axisVelocity[e]||1)}));g.axisVelocity=r,g.accelerationFactors.push(o),O(i)}}},O=function(t){var e=10*Math.ceil(t/10)*1.2;g.isMomentum||(e=Math.max(100,2*e)),g.willEndTimeout=Math.min(1e3,Math.round(e))},V=function(t){return 0===t||t<=.96&&t>=.6},A=function(){if(g.accelerationFactors.length>=5){if(S&&(S=!1,a(g.axisVelocity)>=.2))return void F();var t=g.accelerationFactors.slice(-5);t.every((function(t){var e=!!t.reduce((function(t,e){return t&&t<1&&t===e?1:0})),n=t.filter(V).length===t.length;return e||n}))&&F(),g.accelerationFactors=t}},F=function(){g.isMomentum=!0},z=function(){(g={isStarted:!1,isStartPublished:!1,isMomentum:!1,startTime:0,lastAbsDelta:Infinity,axisMovement:[0,0,0],axisVelocity:[0,0,0],accelerationFactors:[],scrollPoints:[],scrollPointsToMerge:[],willEndTimeout:400}).isStarted=!0,g.startTime=Date.now(),d=void 0,S=!1},W=function(){clearTimeout(p),p=setTimeout(C,g.willEndTimeout)},C=function(t){void 0===t&&(t=!1),g.isStarted&&(P(g.isMomentum&&t?{isEnding:!0,isMomentumCancel:!0}:{isEnding:!0}),g.isMomentum=!1,g.isStarted=!1)},I=function(t){var e=[],n=function(n){n.removeEventListener("wheel",t),e=e.filter((function(t){return t!==n}))};return s({observe:function(i){return i.addEventListener("wheel",t,{passive:!1}),e.push(i),function(){return n(i)}},unobserve:n,disconnect:function(){e.forEach(n)}})}(y),L=I.observe,X=I.unobserve,_=I.disconnect;return D(f),s({on:h,off:x,observe:L,unobserve:X,disconnect:_,feedWheel:y,updateOptions:D})}exports.WheelGestures=f,exports.absMax=a,exports.addVectors=o,exports.average=i,exports.clamp=r,exports.configDefaults=l,exports.deepFreeze=s,exports.default=f,exports.lastOf=n,exports.projection=e; | ||
//# sourceMappingURL=wheel-gestures.cjs.production.min.js.map |
@@ -232,3 +232,3 @@ function _extends() { | ||
return config = deepFreeze(_extends({}, configDefaults, {}, config, {}, newOptions)); | ||
return config = deepFreeze(_extends({}, configDefaults, config, newOptions)); | ||
}; | ||
@@ -235,0 +235,0 @@ |
{ | ||
"name": "wheel-gestures", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "wheel gestures and momentum detection", | ||
@@ -62,3 +62,3 @@ "main": "dist/index.js", | ||
"semantic-release": "^17.0.4", | ||
"tsdx": "^0.13.2", | ||
"tsdx": "^0.14.1", | ||
"tslib": "^2.0.0", | ||
@@ -65,0 +65,0 @@ "typescript": "^3.9.1-rc" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
356183