wheel-gestures
Advanced tools
Comparing version 1.5.1 to 2.0.0
@@ -1,3 +0,1 @@ | ||
export interface Props { | ||
} | ||
export declare type EventMapEmpty = Record<string, unknown>; | ||
@@ -4,0 +2,0 @@ export declare type EventListener<D = unknown> = (data: D) => void; |
@@ -0,6 +1,6 @@ | ||
export { WheelGestures as default } from './wheel-gestures/wheel-gestures'; | ||
export * from './wheel-gestures/wheel-gestures'; | ||
export * from './wheel-gestures/wheel-gestures-types'; | ||
export * from './wheel-analyzer/wheel-analyzer'; | ||
export * from './wheel-analyzer/wheel-analyzer-types'; | ||
export * from './wheel-normalizer/wheel-normalizer'; | ||
export * from './events/EventBus'; | ||
export * from './utils'; |
@@ -1,2 +0,2 @@ | ||
import { WheelEventData } from '../../wheel-analyzer/wheel-analyzer-types'; | ||
import { WheelEventData } from '../../wheel-gestures/wheel-gestures-types'; | ||
interface GenerateEventsProps { | ||
@@ -3,0 +3,0 @@ deltaTotal: number[]; |
@@ -1,5 +0,5 @@ | ||
import { PhaseData, SubscribeFn, WheelEventData, WheelTypes } from '../../wheel-analyzer/wheel-analyzer-types'; | ||
import { WheelEventData, WheelEventState } from '../../wheel-gestures/wheel-gestures-types'; | ||
interface SubAndFeedProps { | ||
beforeFeed?: (e: WheelEventData, i: number) => void; | ||
callback?: SubscribeFn; | ||
callback?: (data: WheelEventState) => void; | ||
wheelEvents?: WheelEventData[]; | ||
@@ -9,19 +9,19 @@ } | ||
wheelAnalyzer: Readonly<{ | ||
observe: (target: EventTarget) => import("../../wheel-analyzer/wheel-analyzer-types").Unobserve; | ||
on: <EK extends "wheel">(type: EK, listener: import("../..").EventListener<import("../../wheel-gestures/wheel-gestures-types").WheelGesturesEventMap[EK]>) => import("../..").Off; | ||
off: <EK_1 extends "wheel">(type: EK_1, listener: import("../..").EventListener<import("../../wheel-gestures/wheel-gestures-types").WheelGesturesEventMap[EK_1]>) => void; | ||
observe: (target: EventTarget) => import("../../wheel-gestures/wheel-gestures-types").Unobserve; | ||
unobserve: (target: EventTarget) => void; | ||
disconnect: () => void; | ||
subscribe: (callback: SubscribeFn) => import("../../wheel-analyzer/wheel-analyzer-types").Unsubscribe; | ||
unsubscribe: (callback: SubscribeFn) => void; | ||
feedWheel: (wheelEvents: WheelEventData | WheelEventData[]) => void; | ||
updateOptions: (newOptions?: Partial<import("../../wheel-analyzer/wheel-analyzer").Options>) => import("../../wheel-analyzer/wheel-analyzer").Options; | ||
updateOptions: (newOptions?: Partial<import("../../wheel-gestures/wheel-gestures-types").WheelGesturesConfig>) => import("../../wheel-gestures/wheel-gestures-types").WheelGesturesConfig; | ||
}>; | ||
allPhaseData: PhaseData[]; | ||
allPhaseData: WheelEventState[]; | ||
feedEvents: (eventsToFeed: WheelEventData[]) => void; | ||
}; | ||
export declare type Range = [number, number]; | ||
export interface PhaseRange { | ||
wheelType: WheelTypes; | ||
export declare type RangeWheelType = 'user' | 'momentum'; | ||
export interface PhaseRange extends Omit<WheelEventState, 'previous'> { | ||
wheelType: RangeWheelType; | ||
range: Range; | ||
canceled?: boolean; | ||
lastData?: PhaseData; | ||
hasPrevious: boolean; | ||
} | ||
@@ -28,0 +28,0 @@ export declare function recordPhases(wheelEvents: WheelEventData[]): { |
@@ -102,3 +102,3 @@ 'use strict'; | ||
var reverseAll = [-1, -1, -1]; | ||
function reverseSign(wheel, reverseSign) { | ||
function reverseAxisDeltaSign(wheel, reverseSign) { | ||
if (!reverseSign) { | ||
@@ -121,3 +121,3 @@ return wheel; | ||
var DELTA_MAX_ABS = 700; | ||
var clampDelta = function clampDelta(wheel) { | ||
var clampAxisDelta = function clampAxisDelta(wheel) { | ||
return _extends({}, wheel, { | ||
@@ -151,15 +151,2 @@ axisDelta: wheel.axisDelta.map(function (delta) { | ||
(function (WheelPhase) { | ||
WheelPhase["ANY_WHEEL_START"] = "ANY_WHEEL_START"; | ||
WheelPhase["ANY_WHEEL"] = "ANY_WHEEL"; | ||
WheelPhase["ANY_WHEEL_END"] = "ANY_WHEEL_END"; | ||
WheelPhase["WHEEL_START"] = "WHEEL_START"; | ||
WheelPhase["WHEEL"] = "WHEEL"; | ||
WheelPhase["WHEEL_END"] = "WHEEL_END"; | ||
WheelPhase["MOMENTUM_WHEEL_START"] = "MOMENTUM_WHEEL_START"; | ||
WheelPhase["MOMENTUM_WHEEL"] = "MOMENTUM_WHEEL"; | ||
WheelPhase["MOMENTUM_WHEEL_CANCEL"] = "MOMENTUM_WHEEL_CANCEL"; | ||
WheelPhase["MOMENTUM_WHEEL_END"] = "MOMENTUM_WHEEL_END"; | ||
})(exports.WheelPhase || (exports.WheelPhase = {})); | ||
var ACC_FACTOR_MIN = 0.6; | ||
@@ -170,3 +157,3 @@ var ACC_FACTOR_MAX = 0.96; | ||
var reverseSignDefault = [true, true, false]; | ||
function WheelAnalyzer(optionsParam) { | ||
function WheelGestures(optionsParam) { | ||
if (optionsParam === void 0) { | ||
@@ -176,8 +163,13 @@ optionsParam = {}; | ||
var options; | ||
var _EventBus = EventBus(), | ||
on = _EventBus.on, | ||
off = _EventBus.off, | ||
dispatch = _EventBus.dispatch; | ||
var config; | ||
var state = createWheelAnalyzerState(); | ||
var subscriptions = []; | ||
var targets = []; | ||
var currentEvent; | ||
var negativeZeroFingerUpSpecialEvent = false; | ||
var prevWheelEventState; // TODO: extract observe | ||
@@ -206,23 +198,7 @@ var observe = function observe(target) { | ||
var subscribe = function subscribe(callback) { | ||
subscriptions.push(callback); // return bound unsubscribe | ||
return function () { | ||
return unsubscribe(callback); | ||
}; | ||
}; | ||
var unsubscribe = function unsubscribe(callback) { | ||
if (!callback) { | ||
throw new Error('please pass the callback used to subscribe'); | ||
} | ||
subscriptions = subscriptions.filter(function (s) { | ||
return s !== callback; | ||
}); | ||
}; | ||
var publish = function publish(type, additionalData) { | ||
var data = _extends({ | ||
type: type, | ||
var publishWheel = function publishWheel(additionalData) { | ||
var wheelEventState = _extends({ | ||
isStart: false, | ||
isEnding: false, | ||
isMomentumCancel: false, | ||
isMomentum: state.isMomentum, | ||
@@ -235,5 +211,7 @@ axisMovement: state.axisMovement, | ||
subscriptions.forEach(function (fn) { | ||
return fn(type, data); | ||
}); | ||
dispatch('wheel', _extends({}, wheelEventState, { | ||
previous: prevWheelEventState | ||
})); // keep reference without previous, otherwise we would create a long chain | ||
prevWheelEventState = wheelEventState; | ||
}; | ||
@@ -261,14 +239,15 @@ | ||
reverseSign = _newOptions$reverseSi === void 0 ? reverseSignDefault : _newOptions$reverseSi, | ||
otherOptions = _objectWithoutPropertiesLoose(_newOptions, ["preventWheelAction", "reverseSign"]); | ||
otherOptions = _objectWithoutPropertiesLoose(_newOptions, ["preventWheelAction", "reverseSign"]); // TODO: current config should be preserved! | ||
options = _extends({ | ||
config = _extends({ | ||
preventWheelAction: preventWheelAction, | ||
reverseSign: reverseSign | ||
}, otherOptions); | ||
return options; | ||
return config; | ||
}; | ||
var shouldPreventDefault = function shouldPreventDefault(e) { | ||
var _options = options, | ||
preventWheelAction = _options.preventWheelAction; | ||
var _config = config, | ||
preventWheelAction = _config.preventWheelAction; | ||
var deltaX = e.deltaX, | ||
@@ -292,5 +271,5 @@ deltaY = e.deltaY; | ||
var processWheelEventData = function processWheelEventData(wheelEvent) { | ||
var _clampDelta = clampDelta(reverseSign(normalizeWheel(wheelEvent), options.reverseSign)), | ||
axisDelta = _clampDelta.axisDelta, | ||
timeStamp = _clampDelta.timeStamp; | ||
var _clampAxisDelta = clampAxisDelta(reverseAxisDeltaSign(normalizeWheel(wheelEvent), config.reverseSign)), | ||
axisDelta = _clampAxisDelta.axisDelta, | ||
timeStamp = _clampAxisDelta.timeStamp; | ||
@@ -340,3 +319,4 @@ var deltaMaxAbs = absMax(axisDelta); | ||
})) | ||
}; | ||
}; // TODO: remove scroll points | ||
state.scrollPoints.push(mergedScrollPoint); // only update velocity after a merged scrollpoint was generated | ||
@@ -355,19 +335,13 @@ | ||
updateStartVelocity(); | ||
} // publish start after velocity etc. have been updated | ||
} // only wheel event (move) and not start/end get the delta values | ||
if (!state.isStartPublished) { | ||
publish(exports.WheelPhase.ANY_WHEEL_START); | ||
publish(exports.WheelPhase.WHEEL_START); | ||
state.isStartPublished = true; | ||
} // only wheel event (move) and not start/end get the delta values | ||
publishWheel({ | ||
axisDelta: axisDelta, | ||
isStart: !state.isStartPublished | ||
}); // state.isMomentum ? MOMENTUM_WHEEL : WHEEL, { axisDelta }) | ||
// publish start after velocity etc. have been updated | ||
state.isStartPublished = true; // calc debounced end function, to recognize end of wheel event stream | ||
publish(exports.WheelPhase.ANY_WHEEL, { | ||
axisDelta: axisDelta | ||
}); | ||
publish(state.isMomentum ? exports.WheelPhase.MOMENTUM_WHEEL : exports.WheelPhase.WHEEL, { | ||
axisDelta: axisDelta | ||
}); // calc debounced end function, to recognize end of wheel event stream | ||
willEnd(); | ||
@@ -466,7 +440,3 @@ }; | ||
var recognizedMomentum = function recognizedMomentum() { | ||
if (!state.isMomentum) { | ||
publish(exports.WheelPhase.WHEEL_END); | ||
state.isMomentum = true; | ||
publish(exports.WheelPhase.MOMENTUM_WHEEL_START); | ||
} | ||
state.isMomentum = true; | ||
}; | ||
@@ -478,2 +448,3 @@ | ||
state.startTime = Date.now(); | ||
prevWheelEventState = undefined; | ||
negativeZeroFingerUpSpecialEvent = false; | ||
@@ -497,14 +468,13 @@ }; | ||
if (state.isMomentum) { | ||
if (isMomentumCancel) { | ||
publish(exports.WheelPhase.MOMENTUM_WHEEL_CANCEL); | ||
} else { | ||
publish(exports.WheelPhase.MOMENTUM_WHEEL_END); | ||
} | ||
if (state.isMomentum && isMomentumCancel) { | ||
publishWheel({ | ||
isEnding: true, | ||
isMomentumCancel: true | ||
}); | ||
} else { | ||
// in case of momentum, this event was already triggered when the momentum was detected so we do not trigger it here | ||
publish(exports.WheelPhase.WHEEL_END); | ||
publishWheel({ | ||
isEnding: true | ||
}); | ||
} | ||
publish(exports.WheelPhase.ANY_WHEEL_END); | ||
state.isMomentum = false; | ||
@@ -516,7 +486,7 @@ state.isStarted = false; | ||
return Object.freeze({ | ||
on: on, | ||
off: off, | ||
observe: observe, | ||
unobserve: unobserve, | ||
disconnect: disconnect, | ||
subscribe: subscribe, | ||
unsubscribe: unsubscribe, | ||
feedWheel: feedWheel, | ||
@@ -527,80 +497,2 @@ updateOptions: updateOptions | ||
(function (WheelReason) { | ||
WheelReason["USER"] = "USER"; | ||
WheelReason["ANY"] = "ANY"; | ||
})(exports.WheelReason || (exports.WheelReason = {})); | ||
var _wheelType; | ||
var wheelType = (_wheelType = {}, _wheelType[exports.WheelReason.USER] = { | ||
start: exports.WheelPhase.WHEEL_START, | ||
wheel: exports.WheelPhase.WHEEL, | ||
end: exports.WheelPhase.WHEEL_END | ||
}, _wheelType[exports.WheelReason.ANY] = { | ||
start: exports.WheelPhase.ANY_WHEEL_START, | ||
wheel: exports.WheelPhase.ANY_WHEEL, | ||
end: exports.WheelPhase.ANY_WHEEL_END | ||
}, _wheelType); | ||
function WheelGestures(_temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
_ref$axis = _ref.axis, | ||
axis = _ref$axis === void 0 ? 'all' : _ref$axis, | ||
_ref$wheelReason = _ref.wheelReason, | ||
wheelReason = _ref$wheelReason === void 0 ? exports.WheelReason.USER : _ref$wheelReason; | ||
var wheelAnalyzer = WheelAnalyzer({ | ||
preventWheelAction: axis | ||
}); | ||
var observe = wheelAnalyzer.observe, | ||
unobserve = wheelAnalyzer.unobserve, | ||
disconnect = wheelAnalyzer.disconnect; | ||
var _EventBus = EventBus(), | ||
on = _EventBus.on, | ||
off = _EventBus.off, | ||
dispatch = _EventBus.dispatch; | ||
wheelAnalyzer.subscribe(function (type, data) { | ||
var dragState = _extends({}, data, { | ||
// TODO: move into analyzer | ||
down: true, | ||
start: false | ||
}); | ||
switch (type) { | ||
case wheelType[wheelReason].start: | ||
dragState = _extends({}, dragState, { | ||
down: true, | ||
start: true | ||
}); | ||
dispatch('wheelstart', dragState); | ||
break; | ||
case wheelType[wheelReason].wheel: | ||
dragState = _extends({}, dragState, { | ||
down: true | ||
}); | ||
dispatch('wheelmove', dragState); | ||
break; | ||
case wheelType[wheelReason].end: | ||
dragState = _extends({}, dragState, { | ||
down: false | ||
}); | ||
dispatch('wheelend', dragState); | ||
break; | ||
default: | ||
return; | ||
} | ||
}); | ||
return Object.freeze({ | ||
observe: observe, | ||
unobserve: unobserve, | ||
disconnect: disconnect, | ||
on: on, | ||
off: off | ||
}); | ||
} | ||
exports.WheelAnalyzer = WheelAnalyzer; | ||
exports.WheelGestures = WheelGestures; | ||
@@ -611,6 +503,7 @@ exports.absMax = absMax; | ||
exports.clamp = clamp; | ||
exports.clampDelta = clampDelta; | ||
exports.clampAxisDelta = clampAxisDelta; | ||
exports.default = WheelGestures; | ||
exports.lastOf = lastOf; | ||
exports.normalizeWheel = normalizeWheel; | ||
exports.reverseSign = reverseSign; | ||
exports.reverseAxisDeltaSign = reverseAxisDeltaSign; | ||
//# sourceMappingURL=wheel-gestures.cjs.development.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function t(e){return e[e.length-1]}function n(e){return e.reduce((function(e,t){return e+t}))/e.length}function r(e,t){if(e.length!==t.length)throw new Error("vectors must be same length");return e.map((function(e,n){return e+t[n]}))}function a(e){return Math.max.apply(Math,e.map(Math.abs))}Object.defineProperty(exports,"__esModule",{value:!0});var o=[1,18,"undefined"!=typeof window&&window.innerHeight||800];function i(e){return{timeStamp:e.timeStamp,axisDelta:[e.deltaX*o[e.deltaMode],e.deltaY*o[e.deltaMode],(e.deltaZ||0)*o[e.deltaMode]]}}var s=[-1,-1,-1];function l(t,n){if(!n)return t;var r=!0===n?s:n.map((function(e){return e?-1:1}));return e({},t,{axisDelta:t.axisDelta.map((function(e,t){return e*r[t]}))})}var u,c=function(e,t,n){return Math.min(Math.max(t,e),n)},E=function(t){return e({},t,{axisDelta:t.axisDelta.map((function(e){return c(e,-700,700)}))})};(u=exports.WheelPhase||(exports.WheelPhase={})).ANY_WHEEL_START="ANY_WHEEL_START",u.ANY_WHEEL="ANY_WHEEL",u.ANY_WHEEL_END="ANY_WHEEL_END",u.WHEEL_START="WHEEL_START",u.WHEEL="WHEEL",u.WHEEL_END="WHEEL_END",u.MOMENTUM_WHEEL_START="MOMENTUM_WHEEL_START",u.MOMENTUM_WHEEL="MOMENTUM_WHEEL",u.MOMENTUM_WHEEL_CANCEL="MOMENTUM_WHEEL_CANCEL",u.MOMENTUM_WHEEL_END="MOMENTUM_WHEEL_END";var h,f,p=[!0,!0,!1];function M(o){var s;void 0===o&&(o={});var u,c,h={isStarted:!1,isStartPublished:!1,isMomentum:!1,startTime:0,lastAbsDelta:Infinity,axisMovement:[0,0,0],axisVelocity:[0,0,0],accelerationFactors:[],scrollPoints:[],scrollPointsToMerge:[],willEndTimeout:400},f=[],M=[],m=!1,x=function(e){e.removeEventListener("wheel",v),M=M.filter((function(t){return t!==e}))},d=function(e){e&&(f=f.filter((function(t){return t!==e})))},W=function(t,n){var r=e({type:t,isMomentum:h.isMomentum,axisMovement:h.axisMovement,axisVelocity:h.axisVelocity,axisDelta:[0,0,0],event:u},n);f.forEach((function(e){return e(t,r)}))},v=function(e){Array.isArray(e)?e.forEach((function(e){return T(e)})):T(e)},_=function(t){void 0===t&&(t={});var n=t.preventWheelAction,r=void 0===n?"all":n,a=t.reverseSign,o=void 0===a?p:a,i=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(a[n]=e[n]);return a}(t,["preventWheelAction","reverseSign"]);return s=e({preventWheelAction:r,reverseSign:o},i)},T=function(e){var t=E(l(i(e),s.reverseSign)),o=t.axisDelta,c=t.timeStamp,f=a(o);if(e.preventDefault&&function(e){var t=e.deltaX,n=e.deltaY;switch(s.preventWheelAction){case"all":return!0;case"x":return Math.abs(t)>=Math.abs(n);case"y":return Math.abs(n)>=Math.abs(t)}}(e)&&e.preventDefault(),h.isStarted?h.isMomentum&&f>Math.max(2,2*h.lastAbsDelta)&&(g(!0),P()):P(),0===f&&Object.is&&Object.is(e.deltaX,-0))m=!0;else{if(u=e,h.axisMovement=r(h.axisMovement,o),h.lastAbsDelta=f,h.scrollPointsToMerge.push({deltaMaxAbs:f,axisDelta:o,timeStamp:c}),2===h.scrollPointsToMerge.length){var p=h.scrollPointsToMerge,M={deltaMaxAbsAverage:n(p.map((function(e){return e.deltaMaxAbs}))),axisDeltaSum:p.map((function(e){return e.axisDelta})).reduce(r),timeStamp:n(p.map((function(e){return e.timeStamp})))};h.scrollPoints.push(M),b(),h.scrollPointsToMerge=[],h.isMomentum||S()}h.scrollPoints.length||A(),h.isStartPublished||(W(exports.WheelPhase.ANY_WHEEL_START),W(exports.WheelPhase.WHEEL_START),h.isStartPublished=!0),W(exports.WheelPhase.ANY_WHEEL,{axisDelta:o}),W(h.isMomentum?exports.WheelPhase.MOMENTUM_WHEEL:exports.WheelPhase.WHEEL,{axisDelta:o}),D()}},A=function(){h.axisVelocity=t(h.scrollPointsToMerge).axisDelta.map((function(e){return e/h.willEndTimeout}))},b=function(){var e=h.scrollPoints.slice(-2),t=e[0],n=e[1];if(t&&n){var r=n.timeStamp-t.timeStamp;if(!(r<=0)){var a=n.axisDeltaSum.map((function(e){return e/r})),o=a.map((function(e,t){return e/(h.axisVelocity[t]||1)}));h.axisVelocity=a,h.accelerationFactors.push(o),L(r)}}},L=function(e){var t=10*Math.ceil(e/10)*1.2;h.isMomentum||(t=Math.max(100,2*t)),h.willEndTimeout=Math.min(1e3,Math.round(t))},N=function(e){return 0===e||e<=.96&&e>=.6},S=function(){if(h.accelerationFactors.length>=5){if(m&&(m=!1,a(h.axisVelocity)>=.2))return void H();var e=h.accelerationFactors.slice(-5);e.reduce((function(e,t){if(!e)return!1;var n=!!t.reduce((function(e,t){return e&&e<1&&e===t?1:0})),r=t.filter(N).length===t.length;return n||r}),!0)&&H(),h.accelerationFactors=e}},H=function(){h.isMomentum||(W(exports.WheelPhase.WHEEL_END),h.isMomentum=!0,W(exports.WheelPhase.MOMENTUM_WHEEL_START))},P=function(){(h={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,h.startTime=Date.now(),m=!1},D=function(){clearTimeout(c),c=setTimeout(g,h.willEndTimeout)},g=function(e){void 0===e&&(e=!1),h.isStarted&&(W(h.isMomentum?e?exports.WheelPhase.MOMENTUM_WHEEL_CANCEL:exports.WheelPhase.MOMENTUM_WHEEL_END:exports.WheelPhase.WHEEL_END),W(exports.WheelPhase.ANY_WHEEL_END),h.isMomentum=!1,h.isStarted=!1)};return _(o),Object.freeze({observe:function(e){return e.addEventListener("wheel",v,{passive:!1}),M.push(e),function(){return x(e)}},unobserve:x,disconnect:function(){M.forEach(x)},subscribe:function(e){return f.push(e),function(){return d(e)}},unsubscribe:d,feedWheel:v,updateOptions:_})}(h=exports.WheelReason||(exports.WheelReason={})).USER="USER",h.ANY="ANY";var m=((f={})[exports.WheelReason.USER]={start:exports.WheelPhase.WHEEL_START,wheel:exports.WheelPhase.WHEEL,end:exports.WheelPhase.WHEEL_END},f[exports.WheelReason.ANY]={start:exports.WheelPhase.ANY_WHEEL_START,wheel:exports.WheelPhase.ANY_WHEEL,end:exports.WheelPhase.ANY_WHEEL_END},f);exports.WheelAnalyzer=M,exports.WheelGestures=function(t){var n=void 0===t?{}:t,r=n.axis,a=n.wheelReason,o=void 0===a?exports.WheelReason.USER:a,i=M({preventWheelAction:void 0===r?"all":r}),s=i.observe,l=i.unobserve,u=i.disconnect,c=function(){var e={};function t(t,n){e[t]=(e[t]||[]).filter((function(e){return e!==n}))}return Object.freeze({on:function(n,r){return e[n]=(e[n]||[]).concat(r),function(){return t(n,r)}},off:t,dispatch:function(t,n){t in e&&e[t].forEach((function(e){return e(n)}))}})}(),E=c.on,h=c.off,f=c.dispatch;return i.subscribe((function(t,n){var r=e({},n,{down:!0,start:!1});switch(t){case m[o].start:r=e({},r,{down:!0,start:!0}),f("wheelstart",r);break;case m[o].wheel:r=e({},r,{down:!0}),f("wheelmove",r);break;case m[o].end:r=e({},r,{down:!1}),f("wheelend",r);break;default:return}})),Object.freeze({observe:s,unobserve:l,disconnect:u,on:E,off:h})},exports.absMax=a,exports.addVectors=r,exports.average=n,exports.clamp=c,exports.clampDelta=E,exports.lastOf=t,exports.normalizeWheel=i,exports.reverseSign=l; | ||
"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)}function e(t){return t[t.length-1]}function n(t){return t.reduce((function(t,e){return t+e}))/t.length}function i(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 r(t){return Math.max.apply(Math,t.map(Math.abs))}Object.defineProperty(exports,"__esModule",{value:!0});var a=[1,18,"undefined"!=typeof window&&window.innerHeight||800];function o(t){return{timeStamp:t.timeStamp,axisDelta:[t.deltaX*a[t.deltaMode],t.deltaY*a[t.deltaMode],(t.deltaZ||0)*a[t.deltaMode]]}}var s=[-1,-1,-1];function u(e,n){if(!n)return e;var i=!0===n?s:n.map((function(t){return t?-1:1}));return t({},e,{axisDelta:e.axisDelta.map((function(t,e){return t*i[e]}))})}var l=function(t,e,n){return Math.min(Math.max(e,t),n)},c=function(e){return t({},e,{axisDelta:e.axisDelta.map((function(t){return l(t,-700,700)}))})},f=[!0,!0,!1];function m(a){void 0===a&&(a={});var s,l,m,d,p=function(){var t={};function e(e,n){t[e]=(t[e]||[]).filter((function(t){return t!==n}))}return Object.freeze({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)}))}})}(),v=p.on,h=p.off,x=p.dispatch,M={isStarted:!1,isStartPublished:!1,isMomentum:!1,startTime:0,lastAbsDelta:Infinity,axisMovement:[0,0,0],axisVelocity:[0,0,0],accelerationFactors:[],scrollPoints:[],scrollPointsToMerge:[],willEndTimeout:400},g=[],b=!1,S=function(t){t.removeEventListener("wheel",y),g=g.filter((function(e){return e!==t}))},D=function(e){var n=t({isStart:!1,isEnding:!1,isMomentumCancel:!1,isMomentum:M.isMomentum,axisMovement:M.axisMovement,axisVelocity:M.axisVelocity,axisDelta:[0,0,0],event:l},e);x("wheel",t({},n,{previous:m})),m=n},y=function(t){Array.isArray(t)?t.forEach((function(t){return w(t)})):w(t)},P=function(e){void 0===e&&(e={});var n=e.preventWheelAction,i=void 0===n?"all":n,r=e.reverseSign,a=void 0===r?f:r,o=function(t,e){if(null==t)return{};var n,i,r={},a=Object.keys(t);for(i=0;i<a.length;i++)e.indexOf(n=a[i])>=0||(r[n]=t[n]);return r}(e,["preventWheelAction","reverseSign"]);return s=t({preventWheelAction:i,reverseSign:a},o)},w=function(t){var e=c(u(o(t),s.reverseSign)),a=e.axisDelta,f=e.timeStamp,m=r(a);if(t.preventDefault&&function(t){var e=t.deltaX,n=t.deltaY;switch(s.preventWheelAction){case"all":return!0;case"x":return Math.abs(e)>=Math.abs(n);case"y":return Math.abs(n)>=Math.abs(e)}}(t)&&t.preventDefault(),M.isStarted?M.isMomentum&&m>Math.max(2,2*M.lastAbsDelta)&&(z(!0),W()):W(),0===m&&Object.is&&Object.is(t.deltaX,-0))b=!0;else{if(l=t,M.axisMovement=i(M.axisMovement,a),M.lastAbsDelta=m,M.scrollPointsToMerge.push({deltaMaxAbs:m,axisDelta:a,timeStamp:f}),2===M.scrollPointsToMerge.length){var d=M.scrollPointsToMerge,p={deltaMaxAbsAverage:n(d.map((function(t){return t.deltaMaxAbs}))),axisDeltaSum:d.map((function(t){return t.axisDelta})).reduce(i),timeStamp:n(d.map((function(t){return t.timeStamp})))};M.scrollPoints.push(p),A(),M.scrollPointsToMerge=[],M.isMomentum||V()}M.scrollPoints.length||T(),D({axisDelta:a,isStart:!M.isStartPublished}),M.isStartPublished=!0,F()}},T=function(){M.axisVelocity=e(M.scrollPointsToMerge).axisDelta.map((function(t){return t/M.willEndTimeout}))},A=function(){var t=M.scrollPoints.slice(-2),e=t[0],n=t[1];if(e&&n){var i=n.timeStamp-e.timeStamp;if(!(i<=0)){var r=n.axisDeltaSum.map((function(t){return t/i})),a=r.map((function(t,e){return t/(M.axisVelocity[e]||1)}));M.axisVelocity=r,M.accelerationFactors.push(a),E(i)}}},E=function(t){var e=10*Math.ceil(t/10)*1.2;M.isMomentum||(e=Math.max(100,2*e)),M.willEndTimeout=Math.min(1e3,Math.round(e))},O=function(t){return 0===t||t<=.96&&t>=.6},V=function(){if(M.accelerationFactors.length>=5){if(b&&(b=!1,r(M.axisVelocity)>=.2))return void j();var t=M.accelerationFactors.slice(-5);t.reduce((function(t,e){if(!t)return!1;var n=!!e.reduce((function(t,e){return t&&t<1&&t===e?1:0})),i=e.filter(O).length===e.length;return n||i}),!0)&&j(),M.accelerationFactors=t}},j=function(){M.isMomentum=!0},W=function(){(M={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,M.startTime=Date.now(),m=void 0,b=!1},F=function(){clearTimeout(d),d=setTimeout(z,M.willEndTimeout)},z=function(t){void 0===t&&(t=!1),M.isStarted&&(D(M.isMomentum&&t?{isEnding:!0,isMomentumCancel:!0}:{isEnding:!0}),M.isMomentum=!1,M.isStarted=!1)};return P(a),Object.freeze({on:v,off:h,observe:function(t){return t.addEventListener("wheel",y,{passive:!1}),g.push(t),function(){return S(t)}},unobserve:S,disconnect:function(){g.forEach(S)},feedWheel:y,updateOptions:P})}exports.WheelGestures=m,exports.absMax=r,exports.addVectors=i,exports.average=n,exports.clamp=l,exports.clampAxisDelta=c,exports.default=m,exports.lastOf=e,exports.normalizeWheel=o,exports.reverseAxisDeltaSign=u; | ||
//# sourceMappingURL=wheel-gestures.cjs.production.min.js.map |
@@ -98,3 +98,3 @@ function _extends() { | ||
var reverseAll = [-1, -1, -1]; | ||
function reverseSign(wheel, reverseSign) { | ||
function reverseAxisDeltaSign(wheel, reverseSign) { | ||
if (!reverseSign) { | ||
@@ -117,3 +117,3 @@ return wheel; | ||
var DELTA_MAX_ABS = 700; | ||
var clampDelta = function clampDelta(wheel) { | ||
var clampAxisDelta = function clampAxisDelta(wheel) { | ||
return _extends({}, wheel, { | ||
@@ -147,17 +147,2 @@ axisDelta: wheel.axisDelta.map(function (delta) { | ||
var WheelPhase; | ||
(function (WheelPhase) { | ||
WheelPhase["ANY_WHEEL_START"] = "ANY_WHEEL_START"; | ||
WheelPhase["ANY_WHEEL"] = "ANY_WHEEL"; | ||
WheelPhase["ANY_WHEEL_END"] = "ANY_WHEEL_END"; | ||
WheelPhase["WHEEL_START"] = "WHEEL_START"; | ||
WheelPhase["WHEEL"] = "WHEEL"; | ||
WheelPhase["WHEEL_END"] = "WHEEL_END"; | ||
WheelPhase["MOMENTUM_WHEEL_START"] = "MOMENTUM_WHEEL_START"; | ||
WheelPhase["MOMENTUM_WHEEL"] = "MOMENTUM_WHEEL"; | ||
WheelPhase["MOMENTUM_WHEEL_CANCEL"] = "MOMENTUM_WHEEL_CANCEL"; | ||
WheelPhase["MOMENTUM_WHEEL_END"] = "MOMENTUM_WHEEL_END"; | ||
})(WheelPhase || (WheelPhase = {})); | ||
var isDev = process.env.NODE_ENV !== 'production'; | ||
@@ -169,3 +154,3 @@ var ACC_FACTOR_MIN = 0.6; | ||
var reverseSignDefault = [true, true, false]; | ||
function WheelAnalyzer(optionsParam) { | ||
function WheelGestures(optionsParam) { | ||
if (optionsParam === void 0) { | ||
@@ -175,8 +160,13 @@ optionsParam = {}; | ||
var options; | ||
var _EventBus = EventBus(), | ||
on = _EventBus.on, | ||
off = _EventBus.off, | ||
dispatch = _EventBus.dispatch; | ||
var config; | ||
var state = createWheelAnalyzerState(); | ||
var subscriptions = []; | ||
var targets = []; | ||
var currentEvent; | ||
var negativeZeroFingerUpSpecialEvent = false; | ||
var prevWheelEventState; // TODO: extract observe | ||
@@ -205,24 +195,7 @@ var observe = function observe(target) { | ||
var subscribe = function subscribe(callback) { | ||
subscriptions.push(callback); // return bound unsubscribe | ||
return function () { | ||
return unsubscribe(callback); | ||
}; | ||
}; | ||
var unsubscribe = function unsubscribe(callback) { | ||
if (!callback) { | ||
if (isDev) throw new Error('please pass the callback used to subscribe'); | ||
return; | ||
} | ||
subscriptions = subscriptions.filter(function (s) { | ||
return s !== callback; | ||
}); | ||
}; | ||
var publish = function publish(type, additionalData) { | ||
var data = _extends({ | ||
type: type, | ||
var publishWheel = function publishWheel(additionalData) { | ||
var wheelEventState = _extends({ | ||
isStart: false, | ||
isEnding: false, | ||
isMomentumCancel: false, | ||
isMomentum: state.isMomentum, | ||
@@ -235,5 +208,7 @@ axisMovement: state.axisMovement, | ||
subscriptions.forEach(function (fn) { | ||
return fn(type, data); | ||
}); | ||
dispatch('wheel', _extends({}, wheelEventState, { | ||
previous: prevWheelEventState | ||
})); // keep reference without previous, otherwise we would create a long chain | ||
prevWheelEventState = wheelEventState; | ||
}; | ||
@@ -261,14 +236,15 @@ | ||
reverseSign = _newOptions$reverseSi === void 0 ? reverseSignDefault : _newOptions$reverseSi, | ||
otherOptions = _objectWithoutPropertiesLoose(_newOptions, ["preventWheelAction", "reverseSign"]); | ||
otherOptions = _objectWithoutPropertiesLoose(_newOptions, ["preventWheelAction", "reverseSign"]); // TODO: current config should be preserved! | ||
options = _extends({ | ||
config = _extends({ | ||
preventWheelAction: preventWheelAction, | ||
reverseSign: reverseSign | ||
}, otherOptions); | ||
return options; | ||
return config; | ||
}; | ||
var shouldPreventDefault = function shouldPreventDefault(e) { | ||
var _options = options, | ||
preventWheelAction = _options.preventWheelAction; | ||
var _config = config, | ||
preventWheelAction = _config.preventWheelAction; | ||
var deltaX = e.deltaX, | ||
@@ -292,5 +268,5 @@ deltaY = e.deltaY; | ||
var processWheelEventData = function processWheelEventData(wheelEvent) { | ||
var _clampDelta = clampDelta(reverseSign(normalizeWheel(wheelEvent), options.reverseSign)), | ||
axisDelta = _clampDelta.axisDelta, | ||
timeStamp = _clampDelta.timeStamp; | ||
var _clampAxisDelta = clampAxisDelta(reverseAxisDeltaSign(normalizeWheel(wheelEvent), config.reverseSign)), | ||
axisDelta = _clampAxisDelta.axisDelta, | ||
timeStamp = _clampAxisDelta.timeStamp; | ||
@@ -340,3 +316,4 @@ var deltaMaxAbs = absMax(axisDelta); | ||
})) | ||
}; | ||
}; // TODO: remove scroll points | ||
state.scrollPoints.push(mergedScrollPoint); // only update velocity after a merged scrollpoint was generated | ||
@@ -355,19 +332,13 @@ | ||
updateStartVelocity(); | ||
} // publish start after velocity etc. have been updated | ||
} // only wheel event (move) and not start/end get the delta values | ||
if (!state.isStartPublished) { | ||
publish(WheelPhase.ANY_WHEEL_START); | ||
publish(WheelPhase.WHEEL_START); | ||
state.isStartPublished = true; | ||
} // only wheel event (move) and not start/end get the delta values | ||
publishWheel({ | ||
axisDelta: axisDelta, | ||
isStart: !state.isStartPublished | ||
}); // state.isMomentum ? MOMENTUM_WHEEL : WHEEL, { axisDelta }) | ||
// publish start after velocity etc. have been updated | ||
state.isStartPublished = true; // calc debounced end function, to recognize end of wheel event stream | ||
publish(WheelPhase.ANY_WHEEL, { | ||
axisDelta: axisDelta | ||
}); | ||
publish(state.isMomentum ? WheelPhase.MOMENTUM_WHEEL : WheelPhase.WHEEL, { | ||
axisDelta: axisDelta | ||
}); // calc debounced end function, to recognize end of wheel event stream | ||
willEnd(); | ||
@@ -466,7 +437,3 @@ }; | ||
var recognizedMomentum = function recognizedMomentum() { | ||
if (!state.isMomentum) { | ||
publish(WheelPhase.WHEEL_END); | ||
state.isMomentum = true; | ||
publish(WheelPhase.MOMENTUM_WHEEL_START); | ||
} | ||
state.isMomentum = true; | ||
}; | ||
@@ -478,2 +445,3 @@ | ||
state.startTime = Date.now(); | ||
prevWheelEventState = undefined; | ||
negativeZeroFingerUpSpecialEvent = false; | ||
@@ -497,14 +465,13 @@ }; | ||
if (state.isMomentum) { | ||
if (isMomentumCancel) { | ||
publish(WheelPhase.MOMENTUM_WHEEL_CANCEL); | ||
} else { | ||
publish(WheelPhase.MOMENTUM_WHEEL_END); | ||
} | ||
if (state.isMomentum && isMomentumCancel) { | ||
publishWheel({ | ||
isEnding: true, | ||
isMomentumCancel: true | ||
}); | ||
} else { | ||
// in case of momentum, this event was already triggered when the momentum was detected so we do not trigger it here | ||
publish(WheelPhase.WHEEL_END); | ||
publishWheel({ | ||
isEnding: true | ||
}); | ||
} | ||
publish(WheelPhase.ANY_WHEEL_END); | ||
state.isMomentum = false; | ||
@@ -516,7 +483,7 @@ state.isStarted = false; | ||
return Object.freeze({ | ||
on: on, | ||
off: off, | ||
observe: observe, | ||
unobserve: unobserve, | ||
disconnect: disconnect, | ||
subscribe: subscribe, | ||
unsubscribe: unsubscribe, | ||
feedWheel: feedWheel, | ||
@@ -527,82 +494,4 @@ updateOptions: updateOptions | ||
var WheelReason; | ||
(function (WheelReason) { | ||
WheelReason["USER"] = "USER"; | ||
WheelReason["ANY"] = "ANY"; | ||
})(WheelReason || (WheelReason = {})); | ||
var _wheelType; | ||
var wheelType = (_wheelType = {}, _wheelType[WheelReason.USER] = { | ||
start: WheelPhase.WHEEL_START, | ||
wheel: WheelPhase.WHEEL, | ||
end: WheelPhase.WHEEL_END | ||
}, _wheelType[WheelReason.ANY] = { | ||
start: WheelPhase.ANY_WHEEL_START, | ||
wheel: WheelPhase.ANY_WHEEL, | ||
end: WheelPhase.ANY_WHEEL_END | ||
}, _wheelType); | ||
function WheelGestures(_temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
_ref$axis = _ref.axis, | ||
axis = _ref$axis === void 0 ? 'all' : _ref$axis, | ||
_ref$wheelReason = _ref.wheelReason, | ||
wheelReason = _ref$wheelReason === void 0 ? WheelReason.USER : _ref$wheelReason; | ||
var wheelAnalyzer = WheelAnalyzer({ | ||
preventWheelAction: axis | ||
}); | ||
var observe = wheelAnalyzer.observe, | ||
unobserve = wheelAnalyzer.unobserve, | ||
disconnect = wheelAnalyzer.disconnect; | ||
var _EventBus = EventBus(), | ||
on = _EventBus.on, | ||
off = _EventBus.off, | ||
dispatch = _EventBus.dispatch; | ||
wheelAnalyzer.subscribe(function (type, data) { | ||
var dragState = _extends({}, data, { | ||
// TODO: move into analyzer | ||
down: true, | ||
start: false | ||
}); | ||
switch (type) { | ||
case wheelType[wheelReason].start: | ||
dragState = _extends({}, dragState, { | ||
down: true, | ||
start: true | ||
}); | ||
dispatch('wheelstart', dragState); | ||
break; | ||
case wheelType[wheelReason].wheel: | ||
dragState = _extends({}, dragState, { | ||
down: true | ||
}); | ||
dispatch('wheelmove', dragState); | ||
break; | ||
case wheelType[wheelReason].end: | ||
dragState = _extends({}, dragState, { | ||
down: false | ||
}); | ||
dispatch('wheelend', dragState); | ||
break; | ||
default: | ||
return; | ||
} | ||
}); | ||
return Object.freeze({ | ||
observe: observe, | ||
unobserve: unobserve, | ||
disconnect: disconnect, | ||
on: on, | ||
off: off | ||
}); | ||
} | ||
export { WheelAnalyzer, WheelGestures, WheelPhase, WheelReason, absMax, addVectors, average, clamp, clampDelta, lastOf, normalizeWheel, reverseSign }; | ||
export default WheelGestures; | ||
export { WheelGestures, absMax, addVectors, average, clamp, clampAxisDelta, lastOf, normalizeWheel, reverseAxisDeltaSign }; | ||
//# sourceMappingURL=wheel-gestures.esm.js.map |
@@ -1,14 +0,50 @@ | ||
import { PhaseData } from '..'; | ||
export interface WheelDragState extends PhaseData { | ||
down: boolean; | ||
start: boolean; | ||
export declare type VectorXYZ = [number, number, number]; | ||
export declare type BooleanXYZ = [boolean, boolean, boolean]; | ||
export interface WheelGesturesInternalState { | ||
isStarted: boolean; | ||
isStartPublished: boolean; | ||
isMomentum: boolean; | ||
startTime: number; | ||
lastAbsDelta: number; | ||
axisMovement: VectorXYZ; | ||
axisVelocity: VectorXYZ; | ||
accelerationFactors: number[][]; | ||
scrollPoints: MergedScrollPoint[]; | ||
scrollPointsToMerge: ScrollPoint[]; | ||
willEndTimeout: number; | ||
} | ||
export declare enum WheelReason { | ||
USER = "USER", | ||
ANY = "ANY" | ||
export interface WheelGesturesConfig { | ||
preventWheelAction: PreventWheelActionType; | ||
reverseSign: ReverseSign; | ||
} | ||
export declare type WheelGesturesOptions = Partial<WheelGesturesConfig>; | ||
export interface ScrollPoint { | ||
deltaMaxAbs: number; | ||
axisDelta: VectorXYZ; | ||
timeStamp: number; | ||
} | ||
export interface MergedScrollPoint { | ||
deltaMaxAbsAverage: number; | ||
axisDeltaSum: VectorXYZ; | ||
timeStamp: number; | ||
} | ||
export declare type WheelEventDataRequiredFields = 'deltaMode' | 'deltaX' | 'deltaY' | 'timeStamp'; | ||
export interface WheelEventData extends Pick<WheelEvent, WheelEventDataRequiredFields>, Partial<Omit<WheelEvent, WheelEventDataRequiredFields>> { | ||
} | ||
export interface WheelEventState { | ||
isStart: boolean; | ||
isMomentum: boolean; | ||
isEnding: boolean; | ||
isMomentumCancel: boolean; | ||
axisMovement: VectorXYZ; | ||
axisVelocity: VectorXYZ; | ||
axisDelta: VectorXYZ; | ||
event: WheelEvent | WheelEventData; | ||
previous?: WheelEventState; | ||
} | ||
export declare type WheelGesturesEventMap = { | ||
wheelstart: WheelDragState; | ||
wheelmove: WheelDragState; | ||
wheelend: WheelDragState; | ||
wheel: WheelEventState; | ||
}; | ||
export declare type Unobserve = () => void; | ||
export declare type PreventWheelActionType = 'all' | 'x' | 'y'; | ||
export declare type ReverseSign = BooleanXYZ | boolean; |
@@ -1,12 +0,10 @@ | ||
import { WheelGesturesEventMap, WheelReason } from './wheel-gestures-types'; | ||
export interface Props { | ||
axis?: 'x' | 'y' | 'all'; | ||
wheelReason?: WheelReason; | ||
} | ||
export declare function WheelGestures({ axis, wheelReason }?: Props): Readonly<{ | ||
observe: (target: EventTarget) => import("../wheel-analyzer/wheel-analyzer-types").Unobserve; | ||
import { Unobserve, WheelEventData, WheelGesturesConfig, WheelGesturesEventMap, WheelGesturesOptions } from './wheel-gestures-types'; | ||
export declare function WheelGestures(optionsParam?: WheelGesturesOptions): Readonly<{ | ||
on: <EK extends "wheel">(type: EK, listener: import("../events/EventBus").EventListener<WheelGesturesEventMap[EK]>) => import("../events/EventBus").Off; | ||
off: <EK_1 extends "wheel">(type: EK_1, listener: import("../events/EventBus").EventListener<WheelGesturesEventMap[EK_1]>) => void; | ||
observe: (target: EventTarget) => Unobserve; | ||
unobserve: (target: EventTarget) => void; | ||
disconnect: () => void; | ||
on: <EK extends "wheelstart" | "wheelmove" | "wheelend">(type: EK, listener: import("../events/EventBus").EventListener<WheelGesturesEventMap[EK]>) => import("../events/EventBus").Off; | ||
off: <EK_1 extends "wheelstart" | "wheelmove" | "wheelend">(type: EK_1, listener: import("../events/EventBus").EventListener<WheelGesturesEventMap[EK_1]>) => void; | ||
feedWheel: (wheelEvents: WheelEventData | WheelEventData[]) => void; | ||
updateOptions: (newOptions?: Partial<WheelGesturesConfig>) => WheelGesturesConfig; | ||
}>; |
@@ -1,2 +0,2 @@ | ||
import { ReverseSign, VectorXYZ, WheelEventData } from '../wheel-analyzer/wheel-analyzer-types'; | ||
import { ReverseSign, VectorXYZ, WheelEventData } from '../wheel-gestures/wheel-gestures-types'; | ||
export interface NormalizedWheel { | ||
@@ -7,6 +7,6 @@ axisDelta: VectorXYZ; | ||
export declare function normalizeWheel(e: WheelEventData): NormalizedWheel; | ||
export declare function reverseSign<T extends Pick<NormalizedWheel, 'axisDelta'>>(wheel: T, reverseSign: ReverseSign): T; | ||
export declare function reverseAxisDeltaSign<T extends Pick<NormalizedWheel, 'axisDelta'>>(wheel: T, reverseSign: ReverseSign): T; | ||
export declare const clamp: (value: number, min: number, max: number) => number; | ||
export declare const clampDelta: <T extends Pick<NormalizedWheel, "axisDelta">>(wheel: T) => T & { | ||
export declare const clampAxisDelta: <T extends Pick<NormalizedWheel, "axisDelta">>(wheel: T) => T & { | ||
axisDelta: number[]; | ||
}; |
{ | ||
"name": "wheel-gestures", | ||
"version": "1.5.1", | ||
"version": "2.0.0", | ||
"description": "wheel gestures and momentum detection", | ||
@@ -56,2 +56,4 @@ "main": "dist/index.js", | ||
"eslint-plugin-simple-import-sort": "^5.0.0", | ||
"eslint-plugin-react": "^7.14.3", | ||
"eslint-plugin-react-app": "^6.2.2", | ||
"husky": "^4.2.5", | ||
@@ -58,0 +60,0 @@ "lint-staged": "^10.1.6", |
@@ -15,4 +15,11 @@ # ![wheel gestures](./WheelGestures.svg) | ||
- Mac OS (Chrome, Firefox, Safari, Brave, Edge, IE10+) | ||
- Windows (testing needed & help appreciated) | ||
- Linux (testing needed & help appreciated) | ||
- Mac OS (Chrome, Firefox, Safari, Edge), Magic Mouse, Magic Trackpad | ||
- Windows (Chrome, Firefox, Edge), Microsoft Precision Touchpads | ||
- Linux (to be tested) | ||
#### Prior Art | ||
Other people also thought that it might be helpful for some interactions to be able to distinguish between user initiated wheel events and the ones that are triggered by inertia scroll, but none of the other known libraries delivered results in the precision I needed, so I developed my own solution. Honourable mentions: | ||
- https://github.com/promo/wheel-indicator | ||
- https://github.com/d4nyll/lethargy |
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
25
117954
13
19
959