1 | 'use strict';
|
---|
2 |
|
---|
3 | var maths = require('./maths-267f0992.cjs.dev.js');
|
---|
4 |
|
---|
5 | function _toPrimitive(input, hint) {
|
---|
6 | if (typeof input !== "object" || input === null) return input;
|
---|
7 | var prim = input[Symbol.toPrimitive];
|
---|
8 | if (prim !== undefined) {
|
---|
9 | var res = prim.call(input, hint || "default");
|
---|
10 | if (typeof res !== "object") return res;
|
---|
11 | throw new TypeError("@@toPrimitive must return a primitive value.");
|
---|
12 | }
|
---|
13 | return (hint === "string" ? String : Number)(input);
|
---|
14 | }
|
---|
15 |
|
---|
16 | function _toPropertyKey(arg) {
|
---|
17 | var key = _toPrimitive(arg, "string");
|
---|
18 | return typeof key === "symbol" ? key : String(key);
|
---|
19 | }
|
---|
20 |
|
---|
21 | function _defineProperty(obj, key, value) {
|
---|
22 | key = _toPropertyKey(key);
|
---|
23 | if (key in obj) {
|
---|
24 | Object.defineProperty(obj, key, {
|
---|
25 | value: value,
|
---|
26 | enumerable: true,
|
---|
27 | configurable: true,
|
---|
28 | writable: true
|
---|
29 | });
|
---|
30 | } else {
|
---|
31 | obj[key] = value;
|
---|
32 | }
|
---|
33 | return obj;
|
---|
34 | }
|
---|
35 |
|
---|
36 | function ownKeys(e, r) {
|
---|
37 | var t = Object.keys(e);
|
---|
38 | if (Object.getOwnPropertySymbols) {
|
---|
39 | var o = Object.getOwnPropertySymbols(e);
|
---|
40 | r && (o = o.filter(function (r) {
|
---|
41 | return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
---|
42 | })), t.push.apply(t, o);
|
---|
43 | }
|
---|
44 | return t;
|
---|
45 | }
|
---|
46 | function _objectSpread2(e) {
|
---|
47 | for (var r = 1; r < arguments.length; r++) {
|
---|
48 | var t = null != arguments[r] ? arguments[r] : {};
|
---|
49 | r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
---|
50 | _defineProperty(e, r, t[r]);
|
---|
51 | }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
---|
52 | Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
---|
53 | });
|
---|
54 | }
|
---|
55 | return e;
|
---|
56 | }
|
---|
57 |
|
---|
58 | const EVENT_TYPE_MAP = {
|
---|
59 | pointer: {
|
---|
60 | start: 'down',
|
---|
61 | change: 'move',
|
---|
62 | end: 'up'
|
---|
63 | },
|
---|
64 | mouse: {
|
---|
65 | start: 'down',
|
---|
66 | change: 'move',
|
---|
67 | end: 'up'
|
---|
68 | },
|
---|
69 | touch: {
|
---|
70 | start: 'start',
|
---|
71 | change: 'move',
|
---|
72 | end: 'end'
|
---|
73 | },
|
---|
74 | gesture: {
|
---|
75 | start: 'start',
|
---|
76 | change: 'change',
|
---|
77 | end: 'end'
|
---|
78 | }
|
---|
79 | };
|
---|
80 | function capitalize(string) {
|
---|
81 | if (!string) return '';
|
---|
82 | return string[0].toUpperCase() + string.slice(1);
|
---|
83 | }
|
---|
84 | const actionsWithoutCaptureSupported = ['enter', 'leave'];
|
---|
85 | function hasCapture(capture = false, actionKey) {
|
---|
86 | return capture && !actionsWithoutCaptureSupported.includes(actionKey);
|
---|
87 | }
|
---|
88 | function toHandlerProp(device, action = '', capture = false) {
|
---|
89 | const deviceProps = EVENT_TYPE_MAP[device];
|
---|
90 | const actionKey = deviceProps ? deviceProps[action] || action : action;
|
---|
91 | return 'on' + capitalize(device) + capitalize(actionKey) + (hasCapture(capture, actionKey) ? 'Capture' : '');
|
---|
92 | }
|
---|
93 | const pointerCaptureEvents = ['gotpointercapture', 'lostpointercapture'];
|
---|
94 | function parseProp(prop) {
|
---|
95 | let eventKey = prop.substring(2).toLowerCase();
|
---|
96 | const passive = !!~eventKey.indexOf('passive');
|
---|
97 | if (passive) eventKey = eventKey.replace('passive', '');
|
---|
98 | const captureKey = pointerCaptureEvents.includes(eventKey) ? 'capturecapture' : 'capture';
|
---|
99 | const capture = !!~eventKey.indexOf(captureKey);
|
---|
100 | if (capture) eventKey = eventKey.replace('capture', '');
|
---|
101 | return {
|
---|
102 | device: eventKey,
|
---|
103 | capture,
|
---|
104 | passive
|
---|
105 | };
|
---|
106 | }
|
---|
107 | function toDomEventType(device, action = '') {
|
---|
108 | const deviceProps = EVENT_TYPE_MAP[device];
|
---|
109 | const actionKey = deviceProps ? deviceProps[action] || action : action;
|
---|
110 | return device + actionKey;
|
---|
111 | }
|
---|
112 | function isTouch(event) {
|
---|
113 | return 'touches' in event;
|
---|
114 | }
|
---|
115 | function getPointerType(event) {
|
---|
116 | if (isTouch(event)) return 'touch';
|
---|
117 | if ('pointerType' in event) return event.pointerType;
|
---|
118 | return 'mouse';
|
---|
119 | }
|
---|
120 | function getCurrentTargetTouchList(event) {
|
---|
121 | return Array.from(event.touches).filter(e => {
|
---|
122 | var _event$currentTarget, _event$currentTarget$;
|
---|
123 | return e.target === event.currentTarget || ((_event$currentTarget = event.currentTarget) === null || _event$currentTarget === void 0 || (_event$currentTarget$ = _event$currentTarget.contains) === null || _event$currentTarget$ === void 0 ? void 0 : _event$currentTarget$.call(_event$currentTarget, e.target));
|
---|
124 | });
|
---|
125 | }
|
---|
126 | function getTouchList(event) {
|
---|
127 | return event.type === 'touchend' || event.type === 'touchcancel' ? event.changedTouches : event.targetTouches;
|
---|
128 | }
|
---|
129 | function getValueEvent(event) {
|
---|
130 | return isTouch(event) ? getTouchList(event)[0] : event;
|
---|
131 | }
|
---|
132 | function distanceAngle(P1, P2) {
|
---|
133 | try {
|
---|
134 | const dx = P2.clientX - P1.clientX;
|
---|
135 | const dy = P2.clientY - P1.clientY;
|
---|
136 | const cx = (P2.clientX + P1.clientX) / 2;
|
---|
137 | const cy = (P2.clientY + P1.clientY) / 2;
|
---|
138 | const distance = Math.hypot(dx, dy);
|
---|
139 | const angle = -(Math.atan2(dx, dy) * 180) / Math.PI;
|
---|
140 | const origin = [cx, cy];
|
---|
141 | return {
|
---|
142 | angle,
|
---|
143 | distance,
|
---|
144 | origin
|
---|
145 | };
|
---|
146 | } catch (_unused) {}
|
---|
147 | return null;
|
---|
148 | }
|
---|
149 | function touchIds(event) {
|
---|
150 | return getCurrentTargetTouchList(event).map(touch => touch.identifier);
|
---|
151 | }
|
---|
152 | function touchDistanceAngle(event, ids) {
|
---|
153 | const [P1, P2] = Array.from(event.touches).filter(touch => ids.includes(touch.identifier));
|
---|
154 | return distanceAngle(P1, P2);
|
---|
155 | }
|
---|
156 | function pointerId(event) {
|
---|
157 | const valueEvent = getValueEvent(event);
|
---|
158 | return isTouch(event) ? valueEvent.identifier : valueEvent.pointerId;
|
---|
159 | }
|
---|
160 | function pointerValues(event) {
|
---|
161 | const valueEvent = getValueEvent(event);
|
---|
162 | return [valueEvent.clientX, valueEvent.clientY];
|
---|
163 | }
|
---|
164 | const LINE_HEIGHT = 40;
|
---|
165 | const PAGE_HEIGHT = 800;
|
---|
166 | function wheelValues(event) {
|
---|
167 | let {
|
---|
168 | deltaX,
|
---|
169 | deltaY,
|
---|
170 | deltaMode
|
---|
171 | } = event;
|
---|
172 | if (deltaMode === 1) {
|
---|
173 | deltaX *= LINE_HEIGHT;
|
---|
174 | deltaY *= LINE_HEIGHT;
|
---|
175 | } else if (deltaMode === 2) {
|
---|
176 | deltaX *= PAGE_HEIGHT;
|
---|
177 | deltaY *= PAGE_HEIGHT;
|
---|
178 | }
|
---|
179 | return [deltaX, deltaY];
|
---|
180 | }
|
---|
181 | function scrollValues(event) {
|
---|
182 | var _ref, _ref2;
|
---|
183 | const {
|
---|
184 | scrollX,
|
---|
185 | scrollY,
|
---|
186 | scrollLeft,
|
---|
187 | scrollTop
|
---|
188 | } = event.currentTarget;
|
---|
189 | return [(_ref = scrollX !== null && scrollX !== void 0 ? scrollX : scrollLeft) !== null && _ref !== void 0 ? _ref : 0, (_ref2 = scrollY !== null && scrollY !== void 0 ? scrollY : scrollTop) !== null && _ref2 !== void 0 ? _ref2 : 0];
|
---|
190 | }
|
---|
191 | function getEventDetails(event) {
|
---|
192 | const payload = {};
|
---|
193 | if ('buttons' in event) payload.buttons = event.buttons;
|
---|
194 | if ('shiftKey' in event) {
|
---|
195 | const {
|
---|
196 | shiftKey,
|
---|
197 | altKey,
|
---|
198 | metaKey,
|
---|
199 | ctrlKey
|
---|
200 | } = event;
|
---|
201 | Object.assign(payload, {
|
---|
202 | shiftKey,
|
---|
203 | altKey,
|
---|
204 | metaKey,
|
---|
205 | ctrlKey
|
---|
206 | });
|
---|
207 | }
|
---|
208 | return payload;
|
---|
209 | }
|
---|
210 |
|
---|
211 | function call(v, ...args) {
|
---|
212 | if (typeof v === 'function') {
|
---|
213 | return v(...args);
|
---|
214 | } else {
|
---|
215 | return v;
|
---|
216 | }
|
---|
217 | }
|
---|
218 | function noop() {}
|
---|
219 | function chain(...fns) {
|
---|
220 | if (fns.length === 0) return noop;
|
---|
221 | if (fns.length === 1) return fns[0];
|
---|
222 | return function () {
|
---|
223 | let result;
|
---|
224 | for (const fn of fns) {
|
---|
225 | result = fn.apply(this, arguments) || result;
|
---|
226 | }
|
---|
227 | return result;
|
---|
228 | };
|
---|
229 | }
|
---|
230 | function assignDefault(value, fallback) {
|
---|
231 | return Object.assign({}, fallback, value || {});
|
---|
232 | }
|
---|
233 |
|
---|
234 | const BEFORE_LAST_KINEMATICS_DELAY = 32;
|
---|
235 | class Engine {
|
---|
236 | constructor(ctrl, args, key) {
|
---|
237 | this.ctrl = ctrl;
|
---|
238 | this.args = args;
|
---|
239 | this.key = key;
|
---|
240 | if (!this.state) {
|
---|
241 | this.state = {};
|
---|
242 | this.computeValues([0, 0]);
|
---|
243 | this.computeInitial();
|
---|
244 | if (this.init) this.init();
|
---|
245 | this.reset();
|
---|
246 | }
|
---|
247 | }
|
---|
248 | get state() {
|
---|
249 | return this.ctrl.state[this.key];
|
---|
250 | }
|
---|
251 | set state(state) {
|
---|
252 | this.ctrl.state[this.key] = state;
|
---|
253 | }
|
---|
254 | get shared() {
|
---|
255 | return this.ctrl.state.shared;
|
---|
256 | }
|
---|
257 | get eventStore() {
|
---|
258 | return this.ctrl.gestureEventStores[this.key];
|
---|
259 | }
|
---|
260 | get timeoutStore() {
|
---|
261 | return this.ctrl.gestureTimeoutStores[this.key];
|
---|
262 | }
|
---|
263 | get config() {
|
---|
264 | return this.ctrl.config[this.key];
|
---|
265 | }
|
---|
266 | get sharedConfig() {
|
---|
267 | return this.ctrl.config.shared;
|
---|
268 | }
|
---|
269 | get handler() {
|
---|
270 | return this.ctrl.handlers[this.key];
|
---|
271 | }
|
---|
272 | reset() {
|
---|
273 | const {
|
---|
274 | state,
|
---|
275 | shared,
|
---|
276 | ingKey,
|
---|
277 | args
|
---|
278 | } = this;
|
---|
279 | shared[ingKey] = state._active = state.active = state._blocked = state._force = false;
|
---|
280 | state._step = [false, false];
|
---|
281 | state.intentional = false;
|
---|
282 | state._movement = [0, 0];
|
---|
283 | state._distance = [0, 0];
|
---|
284 | state._direction = [0, 0];
|
---|
285 | state._delta = [0, 0];
|
---|
286 | state._bounds = [[-Infinity, Infinity], [-Infinity, Infinity]];
|
---|
287 | state.args = args;
|
---|
288 | state.axis = undefined;
|
---|
289 | state.memo = undefined;
|
---|
290 | state.elapsedTime = state.timeDelta = 0;
|
---|
291 | state.direction = [0, 0];
|
---|
292 | state.distance = [0, 0];
|
---|
293 | state.overflow = [0, 0];
|
---|
294 | state._movementBound = [false, false];
|
---|
295 | state.velocity = [0, 0];
|
---|
296 | state.movement = [0, 0];
|
---|
297 | state.delta = [0, 0];
|
---|
298 | state.timeStamp = 0;
|
---|
299 | }
|
---|
300 | start(event) {
|
---|
301 | const state = this.state;
|
---|
302 | const config = this.config;
|
---|
303 | if (!state._active) {
|
---|
304 | this.reset();
|
---|
305 | this.computeInitial();
|
---|
306 | state._active = true;
|
---|
307 | state.target = event.target;
|
---|
308 | state.currentTarget = event.currentTarget;
|
---|
309 | state.lastOffset = config.from ? call(config.from, state) : state.offset;
|
---|
310 | state.offset = state.lastOffset;
|
---|
311 | state.startTime = state.timeStamp = event.timeStamp;
|
---|
312 | }
|
---|
313 | }
|
---|
314 | computeValues(values) {
|
---|
315 | const state = this.state;
|
---|
316 | state._values = values;
|
---|
317 | state.values = this.config.transform(values);
|
---|
318 | }
|
---|
319 | computeInitial() {
|
---|
320 | const state = this.state;
|
---|
321 | state._initial = state._values;
|
---|
322 | state.initial = state.values;
|
---|
323 | }
|
---|
324 | compute(event) {
|
---|
325 | const {
|
---|
326 | state,
|
---|
327 | config,
|
---|
328 | shared
|
---|
329 | } = this;
|
---|
330 | state.args = this.args;
|
---|
331 | let dt = 0;
|
---|
332 | if (event) {
|
---|
333 | state.event = event;
|
---|
334 | if (config.preventDefault && event.cancelable) state.event.preventDefault();
|
---|
335 | state.type = event.type;
|
---|
336 | shared.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size;
|
---|
337 | shared.locked = !!document.pointerLockElement;
|
---|
338 | Object.assign(shared, getEventDetails(event));
|
---|
339 | shared.down = shared.pressed = shared.buttons % 2 === 1 || shared.touches > 0;
|
---|
340 | dt = event.timeStamp - state.timeStamp;
|
---|
341 | state.timeStamp = event.timeStamp;
|
---|
342 | state.elapsedTime = state.timeStamp - state.startTime;
|
---|
343 | }
|
---|
344 | if (state._active) {
|
---|
345 | const _absoluteDelta = state._delta.map(Math.abs);
|
---|
346 | maths.V.addTo(state._distance, _absoluteDelta);
|
---|
347 | }
|
---|
348 | if (this.axisIntent) this.axisIntent(event);
|
---|
349 | const [_m0, _m1] = state._movement;
|
---|
350 | const [t0, t1] = config.threshold;
|
---|
351 | const {
|
---|
352 | _step,
|
---|
353 | values
|
---|
354 | } = state;
|
---|
355 | if (config.hasCustomTransform) {
|
---|
356 | if (_step[0] === false) _step[0] = Math.abs(_m0) >= t0 && values[0];
|
---|
357 | if (_step[1] === false) _step[1] = Math.abs(_m1) >= t1 && values[1];
|
---|
358 | } else {
|
---|
359 | if (_step[0] === false) _step[0] = Math.abs(_m0) >= t0 && Math.sign(_m0) * t0;
|
---|
360 | if (_step[1] === false) _step[1] = Math.abs(_m1) >= t1 && Math.sign(_m1) * t1;
|
---|
361 | }
|
---|
362 | state.intentional = _step[0] !== false || _step[1] !== false;
|
---|
363 | if (!state.intentional) return;
|
---|
364 | const movement = [0, 0];
|
---|
365 | if (config.hasCustomTransform) {
|
---|
366 | const [v0, v1] = values;
|
---|
367 | movement[0] = _step[0] !== false ? v0 - _step[0] : 0;
|
---|
368 | movement[1] = _step[1] !== false ? v1 - _step[1] : 0;
|
---|
369 | } else {
|
---|
370 | movement[0] = _step[0] !== false ? _m0 - _step[0] : 0;
|
---|
371 | movement[1] = _step[1] !== false ? _m1 - _step[1] : 0;
|
---|
372 | }
|
---|
373 | if (this.restrictToAxis && !state._blocked) this.restrictToAxis(movement);
|
---|
374 | const previousOffset = state.offset;
|
---|
375 | const gestureIsActive = state._active && !state._blocked || state.active;
|
---|
376 | if (gestureIsActive) {
|
---|
377 | state.first = state._active && !state.active;
|
---|
378 | state.last = !state._active && state.active;
|
---|
379 | state.active = shared[this.ingKey] = state._active;
|
---|
380 | if (event) {
|
---|
381 | if (state.first) {
|
---|
382 | if ('bounds' in config) state._bounds = call(config.bounds, state);
|
---|
383 | if (this.setup) this.setup();
|
---|
384 | }
|
---|
385 | state.movement = movement;
|
---|
386 | this.computeOffset();
|
---|
387 | }
|
---|
388 | }
|
---|
389 | const [ox, oy] = state.offset;
|
---|
390 | const [[x0, x1], [y0, y1]] = state._bounds;
|
---|
391 | state.overflow = [ox < x0 ? -1 : ox > x1 ? 1 : 0, oy < y0 ? -1 : oy > y1 ? 1 : 0];
|
---|
392 | state._movementBound[0] = state.overflow[0] ? state._movementBound[0] === false ? state._movement[0] : state._movementBound[0] : false;
|
---|
393 | state._movementBound[1] = state.overflow[1] ? state._movementBound[1] === false ? state._movement[1] : state._movementBound[1] : false;
|
---|
394 | const rubberband = state._active ? config.rubberband || [0, 0] : [0, 0];
|
---|
395 | state.offset = maths.computeRubberband(state._bounds, state.offset, rubberband);
|
---|
396 | state.delta = maths.V.sub(state.offset, previousOffset);
|
---|
397 | this.computeMovement();
|
---|
398 | if (gestureIsActive && (!state.last || dt > BEFORE_LAST_KINEMATICS_DELAY)) {
|
---|
399 | state.delta = maths.V.sub(state.offset, previousOffset);
|
---|
400 | const absoluteDelta = state.delta.map(Math.abs);
|
---|
401 | maths.V.addTo(state.distance, absoluteDelta);
|
---|
402 | state.direction = state.delta.map(Math.sign);
|
---|
403 | state._direction = state._delta.map(Math.sign);
|
---|
404 | if (!state.first && dt > 0) {
|
---|
405 | state.velocity = [absoluteDelta[0] / dt, absoluteDelta[1] / dt];
|
---|
406 | state.timeDelta = dt;
|
---|
407 | }
|
---|
408 | }
|
---|
409 | }
|
---|
410 | emit() {
|
---|
411 | const state = this.state;
|
---|
412 | const shared = this.shared;
|
---|
413 | const config = this.config;
|
---|
414 | if (!state._active) this.clean();
|
---|
415 | if ((state._blocked || !state.intentional) && !state._force && !config.triggerAllEvents) return;
|
---|
416 | const memo = this.handler(_objectSpread2(_objectSpread2(_objectSpread2({}, shared), state), {}, {
|
---|
417 | [this.aliasKey]: state.values
|
---|
418 | }));
|
---|
419 | if (memo !== undefined) state.memo = memo;
|
---|
420 | }
|
---|
421 | clean() {
|
---|
422 | this.eventStore.clean();
|
---|
423 | this.timeoutStore.clean();
|
---|
424 | }
|
---|
425 | }
|
---|
426 |
|
---|
427 | function selectAxis([dx, dy], threshold) {
|
---|
428 | const absDx = Math.abs(dx);
|
---|
429 | const absDy = Math.abs(dy);
|
---|
430 | if (absDx > absDy && absDx > threshold) {
|
---|
431 | return 'x';
|
---|
432 | }
|
---|
433 | if (absDy > absDx && absDy > threshold) {
|
---|
434 | return 'y';
|
---|
435 | }
|
---|
436 | return undefined;
|
---|
437 | }
|
---|
438 | class CoordinatesEngine extends Engine {
|
---|
439 | constructor(...args) {
|
---|
440 | super(...args);
|
---|
441 | _defineProperty(this, "aliasKey", 'xy');
|
---|
442 | }
|
---|
443 | reset() {
|
---|
444 | super.reset();
|
---|
445 | this.state.axis = undefined;
|
---|
446 | }
|
---|
447 | init() {
|
---|
448 | this.state.offset = [0, 0];
|
---|
449 | this.state.lastOffset = [0, 0];
|
---|
450 | }
|
---|
451 | computeOffset() {
|
---|
452 | this.state.offset = maths.V.add(this.state.lastOffset, this.state.movement);
|
---|
453 | }
|
---|
454 | computeMovement() {
|
---|
455 | this.state.movement = maths.V.sub(this.state.offset, this.state.lastOffset);
|
---|
456 | }
|
---|
457 | axisIntent(event) {
|
---|
458 | const state = this.state;
|
---|
459 | const config = this.config;
|
---|
460 | if (!state.axis && event) {
|
---|
461 | const threshold = typeof config.axisThreshold === 'object' ? config.axisThreshold[getPointerType(event)] : config.axisThreshold;
|
---|
462 | state.axis = selectAxis(state._movement, threshold);
|
---|
463 | }
|
---|
464 | state._blocked = (config.lockDirection || !!config.axis) && !state.axis || !!config.axis && config.axis !== state.axis;
|
---|
465 | }
|
---|
466 | restrictToAxis(v) {
|
---|
467 | if (this.config.axis || this.config.lockDirection) {
|
---|
468 | switch (this.state.axis) {
|
---|
469 | case 'x':
|
---|
470 | v[1] = 0;
|
---|
471 | break;
|
---|
472 | case 'y':
|
---|
473 | v[0] = 0;
|
---|
474 | break;
|
---|
475 | }
|
---|
476 | }
|
---|
477 | }
|
---|
478 | }
|
---|
479 |
|
---|
480 | const identity = v => v;
|
---|
481 | const DEFAULT_RUBBERBAND = 0.15;
|
---|
482 | const commonConfigResolver = {
|
---|
483 | enabled(value = true) {
|
---|
484 | return value;
|
---|
485 | },
|
---|
486 | eventOptions(value, _k, config) {
|
---|
487 | return _objectSpread2(_objectSpread2({}, config.shared.eventOptions), value);
|
---|
488 | },
|
---|
489 | preventDefault(value = false) {
|
---|
490 | return value;
|
---|
491 | },
|
---|
492 | triggerAllEvents(value = false) {
|
---|
493 | return value;
|
---|
494 | },
|
---|
495 | rubberband(value = 0) {
|
---|
496 | switch (value) {
|
---|
497 | case true:
|
---|
498 | return [DEFAULT_RUBBERBAND, DEFAULT_RUBBERBAND];
|
---|
499 | case false:
|
---|
500 | return [0, 0];
|
---|
501 | default:
|
---|
502 | return maths.V.toVector(value);
|
---|
503 | }
|
---|
504 | },
|
---|
505 | from(value) {
|
---|
506 | if (typeof value === 'function') return value;
|
---|
507 | if (value != null) return maths.V.toVector(value);
|
---|
508 | },
|
---|
509 | transform(value, _k, config) {
|
---|
510 | const transform = value || config.shared.transform;
|
---|
511 | this.hasCustomTransform = !!transform;
|
---|
512 | if (process.env.NODE_ENV === 'development') {
|
---|
513 | const originalTransform = transform || identity;
|
---|
514 | return v => {
|
---|
515 | const r = originalTransform(v);
|
---|
516 | if (!isFinite(r[0]) || !isFinite(r[1])) {
|
---|
517 | console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${r[0]},${[1]}]`);
|
---|
518 | }
|
---|
519 | return r;
|
---|
520 | };
|
---|
521 | }
|
---|
522 | return transform || identity;
|
---|
523 | },
|
---|
524 | threshold(value) {
|
---|
525 | return maths.V.toVector(value, 0);
|
---|
526 | }
|
---|
527 | };
|
---|
528 | if (process.env.NODE_ENV === 'development') {
|
---|
529 | Object.assign(commonConfigResolver, {
|
---|
530 | domTarget(value) {
|
---|
531 | if (value !== undefined) {
|
---|
532 | throw Error(`[@use-gesture]: \`domTarget\` option has been renamed to \`target\`.`);
|
---|
533 | }
|
---|
534 | return NaN;
|
---|
535 | },
|
---|
536 | lockDirection(value) {
|
---|
537 | if (value !== undefined) {
|
---|
538 | throw Error(`[@use-gesture]: \`lockDirection\` option has been merged with \`axis\`. Use it as in \`{ axis: 'lock' }\``);
|
---|
539 | }
|
---|
540 | return NaN;
|
---|
541 | },
|
---|
542 | initial(value) {
|
---|
543 | if (value !== undefined) {
|
---|
544 | throw Error(`[@use-gesture]: \`initial\` option has been renamed to \`from\`.`);
|
---|
545 | }
|
---|
546 | return NaN;
|
---|
547 | }
|
---|
548 | });
|
---|
549 | }
|
---|
550 |
|
---|
551 | const DEFAULT_AXIS_THRESHOLD = 0;
|
---|
552 | const coordinatesConfigResolver = _objectSpread2(_objectSpread2({}, commonConfigResolver), {}, {
|
---|
553 | axis(_v, _k, {
|
---|
554 | axis
|
---|
555 | }) {
|
---|
556 | this.lockDirection = axis === 'lock';
|
---|
557 | if (!this.lockDirection) return axis;
|
---|
558 | },
|
---|
559 | axisThreshold(value = DEFAULT_AXIS_THRESHOLD) {
|
---|
560 | return value;
|
---|
561 | },
|
---|
562 | bounds(value = {}) {
|
---|
563 | if (typeof value === 'function') {
|
---|
564 | return state => coordinatesConfigResolver.bounds(value(state));
|
---|
565 | }
|
---|
566 | if ('current' in value) {
|
---|
567 | return () => value.current;
|
---|
568 | }
|
---|
569 | if (typeof HTMLElement === 'function' && value instanceof HTMLElement) {
|
---|
570 | return value;
|
---|
571 | }
|
---|
572 | const {
|
---|
573 | left = -Infinity,
|
---|
574 | right = Infinity,
|
---|
575 | top = -Infinity,
|
---|
576 | bottom = Infinity
|
---|
577 | } = value;
|
---|
578 | return [[left, right], [top, bottom]];
|
---|
579 | }
|
---|
580 | });
|
---|
581 |
|
---|
582 | const KEYS_DELTA_MAP = {
|
---|
583 | ArrowRight: (displacement, factor = 1) => [displacement * factor, 0],
|
---|
584 | ArrowLeft: (displacement, factor = 1) => [-1 * displacement * factor, 0],
|
---|
585 | ArrowUp: (displacement, factor = 1) => [0, -1 * displacement * factor],
|
---|
586 | ArrowDown: (displacement, factor = 1) => [0, displacement * factor]
|
---|
587 | };
|
---|
588 | class DragEngine extends CoordinatesEngine {
|
---|
589 | constructor(...args) {
|
---|
590 | super(...args);
|
---|
591 | _defineProperty(this, "ingKey", 'dragging');
|
---|
592 | }
|
---|
593 | reset() {
|
---|
594 | super.reset();
|
---|
595 | const state = this.state;
|
---|
596 | state._pointerId = undefined;
|
---|
597 | state._pointerActive = false;
|
---|
598 | state._keyboardActive = false;
|
---|
599 | state._preventScroll = false;
|
---|
600 | state._delayed = false;
|
---|
601 | state.swipe = [0, 0];
|
---|
602 | state.tap = false;
|
---|
603 | state.canceled = false;
|
---|
604 | state.cancel = this.cancel.bind(this);
|
---|
605 | }
|
---|
606 | setup() {
|
---|
607 | const state = this.state;
|
---|
608 | if (state._bounds instanceof HTMLElement) {
|
---|
609 | const boundRect = state._bounds.getBoundingClientRect();
|
---|
610 | const targetRect = state.currentTarget.getBoundingClientRect();
|
---|
611 | const _bounds = {
|
---|
612 | left: boundRect.left - targetRect.left + state.offset[0],
|
---|
613 | right: boundRect.right - targetRect.right + state.offset[0],
|
---|
614 | top: boundRect.top - targetRect.top + state.offset[1],
|
---|
615 | bottom: boundRect.bottom - targetRect.bottom + state.offset[1]
|
---|
616 | };
|
---|
617 | state._bounds = coordinatesConfigResolver.bounds(_bounds);
|
---|
618 | }
|
---|
619 | }
|
---|
620 | cancel() {
|
---|
621 | const state = this.state;
|
---|
622 | if (state.canceled) return;
|
---|
623 | state.canceled = true;
|
---|
624 | state._active = false;
|
---|
625 | setTimeout(() => {
|
---|
626 | this.compute();
|
---|
627 | this.emit();
|
---|
628 | }, 0);
|
---|
629 | }
|
---|
630 | setActive() {
|
---|
631 | this.state._active = this.state._pointerActive || this.state._keyboardActive;
|
---|
632 | }
|
---|
633 | clean() {
|
---|
634 | this.pointerClean();
|
---|
635 | this.state._pointerActive = false;
|
---|
636 | this.state._keyboardActive = false;
|
---|
637 | super.clean();
|
---|
638 | }
|
---|
639 | pointerDown(event) {
|
---|
640 | const config = this.config;
|
---|
641 | const state = this.state;
|
---|
642 | if (event.buttons != null && (Array.isArray(config.pointerButtons) ? !config.pointerButtons.includes(event.buttons) : config.pointerButtons !== -1 && config.pointerButtons !== event.buttons)) return;
|
---|
643 | const ctrlIds = this.ctrl.setEventIds(event);
|
---|
644 | if (config.pointerCapture) {
|
---|
645 | event.target.setPointerCapture(event.pointerId);
|
---|
646 | }
|
---|
647 | if (ctrlIds && ctrlIds.size > 1 && state._pointerActive) return;
|
---|
648 | this.start(event);
|
---|
649 | this.setupPointer(event);
|
---|
650 | state._pointerId = pointerId(event);
|
---|
651 | state._pointerActive = true;
|
---|
652 | this.computeValues(pointerValues(event));
|
---|
653 | this.computeInitial();
|
---|
654 | if (config.preventScrollAxis && getPointerType(event) !== 'mouse') {
|
---|
655 | state._active = false;
|
---|
656 | this.setupScrollPrevention(event);
|
---|
657 | } else if (config.delay > 0) {
|
---|
658 | this.setupDelayTrigger(event);
|
---|
659 | if (config.triggerAllEvents) {
|
---|
660 | this.compute(event);
|
---|
661 | this.emit();
|
---|
662 | }
|
---|
663 | } else {
|
---|
664 | this.startPointerDrag(event);
|
---|
665 | }
|
---|
666 | }
|
---|
667 | startPointerDrag(event) {
|
---|
668 | const state = this.state;
|
---|
669 | state._active = true;
|
---|
670 | state._preventScroll = true;
|
---|
671 | state._delayed = false;
|
---|
672 | this.compute(event);
|
---|
673 | this.emit();
|
---|
674 | }
|
---|
675 | pointerMove(event) {
|
---|
676 | const state = this.state;
|
---|
677 | const config = this.config;
|
---|
678 | if (!state._pointerActive) return;
|
---|
679 | const id = pointerId(event);
|
---|
680 | if (state._pointerId !== undefined && id !== state._pointerId) return;
|
---|
681 | const _values = pointerValues(event);
|
---|
682 | if (document.pointerLockElement === event.target) {
|
---|
683 | state._delta = [event.movementX, event.movementY];
|
---|
684 | } else {
|
---|
685 | state._delta = maths.V.sub(_values, state._values);
|
---|
686 | this.computeValues(_values);
|
---|
687 | }
|
---|
688 | maths.V.addTo(state._movement, state._delta);
|
---|
689 | this.compute(event);
|
---|
690 | if (state._delayed && state.intentional) {
|
---|
691 | this.timeoutStore.remove('dragDelay');
|
---|
692 | state.active = false;
|
---|
693 | this.startPointerDrag(event);
|
---|
694 | return;
|
---|
695 | }
|
---|
696 | if (config.preventScrollAxis && !state._preventScroll) {
|
---|
697 | if (state.axis) {
|
---|
698 | if (state.axis === config.preventScrollAxis || config.preventScrollAxis === 'xy') {
|
---|
699 | state._active = false;
|
---|
700 | this.clean();
|
---|
701 | return;
|
---|
702 | } else {
|
---|
703 | this.timeoutStore.remove('startPointerDrag');
|
---|
704 | this.startPointerDrag(event);
|
---|
705 | return;
|
---|
706 | }
|
---|
707 | } else {
|
---|
708 | return;
|
---|
709 | }
|
---|
710 | }
|
---|
711 | this.emit();
|
---|
712 | }
|
---|
713 | pointerUp(event) {
|
---|
714 | this.ctrl.setEventIds(event);
|
---|
715 | try {
|
---|
716 | if (this.config.pointerCapture && event.target.hasPointerCapture(event.pointerId)) {
|
---|
717 | ;
|
---|
718 | event.target.releasePointerCapture(event.pointerId);
|
---|
719 | }
|
---|
720 | } catch (_unused) {
|
---|
721 | if (process.env.NODE_ENV === 'development') {
|
---|
722 | console.warn(`[@use-gesture]: If you see this message, it's likely that you're using an outdated version of \`@react-three/fiber\`. \n\nPlease upgrade to the latest version.`);
|
---|
723 | }
|
---|
724 | }
|
---|
725 | const state = this.state;
|
---|
726 | const config = this.config;
|
---|
727 | if (!state._active || !state._pointerActive) return;
|
---|
728 | const id = pointerId(event);
|
---|
729 | if (state._pointerId !== undefined && id !== state._pointerId) return;
|
---|
730 | this.state._pointerActive = false;
|
---|
731 | this.setActive();
|
---|
732 | this.compute(event);
|
---|
733 | const [dx, dy] = state._distance;
|
---|
734 | state.tap = dx <= config.tapsThreshold && dy <= config.tapsThreshold;
|
---|
735 | if (state.tap && config.filterTaps) {
|
---|
736 | state._force = true;
|
---|
737 | } else {
|
---|
738 | const [_dx, _dy] = state._delta;
|
---|
739 | const [_mx, _my] = state._movement;
|
---|
740 | const [svx, svy] = config.swipe.velocity;
|
---|
741 | const [sx, sy] = config.swipe.distance;
|
---|
742 | const sdt = config.swipe.duration;
|
---|
743 | if (state.elapsedTime < sdt) {
|
---|
744 | const _vx = Math.abs(_dx / state.timeDelta);
|
---|
745 | const _vy = Math.abs(_dy / state.timeDelta);
|
---|
746 | if (_vx > svx && Math.abs(_mx) > sx) state.swipe[0] = Math.sign(_dx);
|
---|
747 | if (_vy > svy && Math.abs(_my) > sy) state.swipe[1] = Math.sign(_dy);
|
---|
748 | }
|
---|
749 | }
|
---|
750 | this.emit();
|
---|
751 | }
|
---|
752 | pointerClick(event) {
|
---|
753 | if (!this.state.tap && event.detail > 0) {
|
---|
754 | event.preventDefault();
|
---|
755 | event.stopPropagation();
|
---|
756 | }
|
---|
757 | }
|
---|
758 | setupPointer(event) {
|
---|
759 | const config = this.config;
|
---|
760 | const device = config.device;
|
---|
761 | if (process.env.NODE_ENV === 'development') {
|
---|
762 | try {
|
---|
763 | if (device === 'pointer' && config.preventScrollDelay === undefined) {
|
---|
764 | const currentTarget = 'uv' in event ? event.sourceEvent.currentTarget : event.currentTarget;
|
---|
765 | const style = window.getComputedStyle(currentTarget);
|
---|
766 | if (style.touchAction === 'auto') {
|
---|
767 | console.warn(`[@use-gesture]: The drag target has its \`touch-action\` style property set to \`auto\`. It is recommended to add \`touch-action: 'none'\` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.`, currentTarget);
|
---|
768 | }
|
---|
769 | }
|
---|
770 | } catch (_unused2) {}
|
---|
771 | }
|
---|
772 | if (config.pointerLock) {
|
---|
773 | event.currentTarget.requestPointerLock();
|
---|
774 | }
|
---|
775 | if (!config.pointerCapture) {
|
---|
776 | this.eventStore.add(this.sharedConfig.window, device, 'change', this.pointerMove.bind(this));
|
---|
777 | this.eventStore.add(this.sharedConfig.window, device, 'end', this.pointerUp.bind(this));
|
---|
778 | this.eventStore.add(this.sharedConfig.window, device, 'cancel', this.pointerUp.bind(this));
|
---|
779 | }
|
---|
780 | }
|
---|
781 | pointerClean() {
|
---|
782 | if (this.config.pointerLock && document.pointerLockElement === this.state.currentTarget) {
|
---|
783 | document.exitPointerLock();
|
---|
784 | }
|
---|
785 | }
|
---|
786 | preventScroll(event) {
|
---|
787 | if (this.state._preventScroll && event.cancelable) {
|
---|
788 | event.preventDefault();
|
---|
789 | }
|
---|
790 | }
|
---|
791 | setupScrollPrevention(event) {
|
---|
792 | this.state._preventScroll = false;
|
---|
793 | persistEvent(event);
|
---|
794 | const remove = this.eventStore.add(this.sharedConfig.window, 'touch', 'change', this.preventScroll.bind(this), {
|
---|
795 | passive: false
|
---|
796 | });
|
---|
797 | this.eventStore.add(this.sharedConfig.window, 'touch', 'end', remove);
|
---|
798 | this.eventStore.add(this.sharedConfig.window, 'touch', 'cancel', remove);
|
---|
799 | this.timeoutStore.add('startPointerDrag', this.startPointerDrag.bind(this), this.config.preventScrollDelay, event);
|
---|
800 | }
|
---|
801 | setupDelayTrigger(event) {
|
---|
802 | this.state._delayed = true;
|
---|
803 | this.timeoutStore.add('dragDelay', () => {
|
---|
804 | this.state._step = [0, 0];
|
---|
805 | this.startPointerDrag(event);
|
---|
806 | }, this.config.delay);
|
---|
807 | }
|
---|
808 | keyDown(event) {
|
---|
809 | const deltaFn = KEYS_DELTA_MAP[event.key];
|
---|
810 | if (deltaFn) {
|
---|
811 | const state = this.state;
|
---|
812 | const factor = event.shiftKey ? 10 : event.altKey ? 0.1 : 1;
|
---|
813 | this.start(event);
|
---|
814 | state._delta = deltaFn(this.config.keyboardDisplacement, factor);
|
---|
815 | state._keyboardActive = true;
|
---|
816 | maths.V.addTo(state._movement, state._delta);
|
---|
817 | this.compute(event);
|
---|
818 | this.emit();
|
---|
819 | }
|
---|
820 | }
|
---|
821 | keyUp(event) {
|
---|
822 | if (!(event.key in KEYS_DELTA_MAP)) return;
|
---|
823 | this.state._keyboardActive = false;
|
---|
824 | this.setActive();
|
---|
825 | this.compute(event);
|
---|
826 | this.emit();
|
---|
827 | }
|
---|
828 | bind(bindFunction) {
|
---|
829 | const device = this.config.device;
|
---|
830 | bindFunction(device, 'start', this.pointerDown.bind(this));
|
---|
831 | if (this.config.pointerCapture) {
|
---|
832 | bindFunction(device, 'change', this.pointerMove.bind(this));
|
---|
833 | bindFunction(device, 'end', this.pointerUp.bind(this));
|
---|
834 | bindFunction(device, 'cancel', this.pointerUp.bind(this));
|
---|
835 | bindFunction('lostPointerCapture', '', this.pointerUp.bind(this));
|
---|
836 | }
|
---|
837 | if (this.config.keys) {
|
---|
838 | bindFunction('key', 'down', this.keyDown.bind(this));
|
---|
839 | bindFunction('key', 'up', this.keyUp.bind(this));
|
---|
840 | }
|
---|
841 | if (this.config.filterTaps) {
|
---|
842 | bindFunction('click', '', this.pointerClick.bind(this), {
|
---|
843 | capture: true,
|
---|
844 | passive: false
|
---|
845 | });
|
---|
846 | }
|
---|
847 | }
|
---|
848 | }
|
---|
849 | function persistEvent(event) {
|
---|
850 | 'persist' in event && typeof event.persist === 'function' && event.persist();
|
---|
851 | }
|
---|
852 |
|
---|
853 | const isBrowser = typeof window !== 'undefined' && window.document && window.document.createElement;
|
---|
854 | function supportsTouchEvents() {
|
---|
855 | return isBrowser && 'ontouchstart' in window;
|
---|
856 | }
|
---|
857 | function isTouchScreen() {
|
---|
858 | return supportsTouchEvents() || isBrowser && window.navigator.maxTouchPoints > 1;
|
---|
859 | }
|
---|
860 | function supportsPointerEvents() {
|
---|
861 | return isBrowser && 'onpointerdown' in window;
|
---|
862 | }
|
---|
863 | function supportsPointerLock() {
|
---|
864 | return isBrowser && 'exitPointerLock' in window.document;
|
---|
865 | }
|
---|
866 | function supportsGestureEvents() {
|
---|
867 | try {
|
---|
868 | return 'constructor' in GestureEvent;
|
---|
869 | } catch (e) {
|
---|
870 | return false;
|
---|
871 | }
|
---|
872 | }
|
---|
873 | const SUPPORT = {
|
---|
874 | isBrowser,
|
---|
875 | gesture: supportsGestureEvents(),
|
---|
876 | touch: supportsTouchEvents(),
|
---|
877 | touchscreen: isTouchScreen(),
|
---|
878 | pointer: supportsPointerEvents(),
|
---|
879 | pointerLock: supportsPointerLock()
|
---|
880 | };
|
---|
881 |
|
---|
882 | const DEFAULT_PREVENT_SCROLL_DELAY = 250;
|
---|
883 | const DEFAULT_DRAG_DELAY = 180;
|
---|
884 | const DEFAULT_SWIPE_VELOCITY = 0.5;
|
---|
885 | const DEFAULT_SWIPE_DISTANCE = 50;
|
---|
886 | const DEFAULT_SWIPE_DURATION = 250;
|
---|
887 | const DEFAULT_KEYBOARD_DISPLACEMENT = 10;
|
---|
888 | const DEFAULT_DRAG_AXIS_THRESHOLD = {
|
---|
889 | mouse: 0,
|
---|
890 | touch: 0,
|
---|
891 | pen: 8
|
---|
892 | };
|
---|
893 | const dragConfigResolver = _objectSpread2(_objectSpread2({}, coordinatesConfigResolver), {}, {
|
---|
894 | device(_v, _k, {
|
---|
895 | pointer: {
|
---|
896 | touch = false,
|
---|
897 | lock = false,
|
---|
898 | mouse = false
|
---|
899 | } = {}
|
---|
900 | }) {
|
---|
901 | this.pointerLock = lock && SUPPORT.pointerLock;
|
---|
902 | if (SUPPORT.touch && touch) return 'touch';
|
---|
903 | if (this.pointerLock) return 'mouse';
|
---|
904 | if (SUPPORT.pointer && !mouse) return 'pointer';
|
---|
905 | if (SUPPORT.touch) return 'touch';
|
---|
906 | return 'mouse';
|
---|
907 | },
|
---|
908 | preventScrollAxis(value, _k, {
|
---|
909 | preventScroll
|
---|
910 | }) {
|
---|
911 | this.preventScrollDelay = typeof preventScroll === 'number' ? preventScroll : preventScroll || preventScroll === undefined && value ? DEFAULT_PREVENT_SCROLL_DELAY : undefined;
|
---|
912 | if (!SUPPORT.touchscreen || preventScroll === false) return undefined;
|
---|
913 | return value ? value : preventScroll !== undefined ? 'y' : undefined;
|
---|
914 | },
|
---|
915 | pointerCapture(_v, _k, {
|
---|
916 | pointer: {
|
---|
917 | capture = true,
|
---|
918 | buttons = 1,
|
---|
919 | keys = true
|
---|
920 | } = {}
|
---|
921 | }) {
|
---|
922 | this.pointerButtons = buttons;
|
---|
923 | this.keys = keys;
|
---|
924 | return !this.pointerLock && this.device === 'pointer' && capture;
|
---|
925 | },
|
---|
926 | threshold(value, _k, {
|
---|
927 | filterTaps = false,
|
---|
928 | tapsThreshold = 3,
|
---|
929 | axis = undefined
|
---|
930 | }) {
|
---|
931 | const threshold = maths.V.toVector(value, filterTaps ? tapsThreshold : axis ? 1 : 0);
|
---|
932 | this.filterTaps = filterTaps;
|
---|
933 | this.tapsThreshold = tapsThreshold;
|
---|
934 | return threshold;
|
---|
935 | },
|
---|
936 | swipe({
|
---|
937 | velocity = DEFAULT_SWIPE_VELOCITY,
|
---|
938 | distance = DEFAULT_SWIPE_DISTANCE,
|
---|
939 | duration = DEFAULT_SWIPE_DURATION
|
---|
940 | } = {}) {
|
---|
941 | return {
|
---|
942 | velocity: this.transform(maths.V.toVector(velocity)),
|
---|
943 | distance: this.transform(maths.V.toVector(distance)),
|
---|
944 | duration
|
---|
945 | };
|
---|
946 | },
|
---|
947 | delay(value = 0) {
|
---|
948 | switch (value) {
|
---|
949 | case true:
|
---|
950 | return DEFAULT_DRAG_DELAY;
|
---|
951 | case false:
|
---|
952 | return 0;
|
---|
953 | default:
|
---|
954 | return value;
|
---|
955 | }
|
---|
956 | },
|
---|
957 | axisThreshold(value) {
|
---|
958 | if (!value) return DEFAULT_DRAG_AXIS_THRESHOLD;
|
---|
959 | return _objectSpread2(_objectSpread2({}, DEFAULT_DRAG_AXIS_THRESHOLD), value);
|
---|
960 | },
|
---|
961 | keyboardDisplacement(value = DEFAULT_KEYBOARD_DISPLACEMENT) {
|
---|
962 | return value;
|
---|
963 | }
|
---|
964 | });
|
---|
965 | if (process.env.NODE_ENV === 'development') {
|
---|
966 | Object.assign(dragConfigResolver, {
|
---|
967 | useTouch(value) {
|
---|
968 | if (value !== undefined) {
|
---|
969 | throw Error(`[@use-gesture]: \`useTouch\` option has been renamed to \`pointer.touch\`. Use it as in \`{ pointer: { touch: true } }\`.`);
|
---|
970 | }
|
---|
971 | return NaN;
|
---|
972 | },
|
---|
973 | experimental_preventWindowScrollY(value) {
|
---|
974 | if (value !== undefined) {
|
---|
975 | throw Error(`[@use-gesture]: \`experimental_preventWindowScrollY\` option has been renamed to \`preventScroll\`.`);
|
---|
976 | }
|
---|
977 | return NaN;
|
---|
978 | },
|
---|
979 | swipeVelocity(value) {
|
---|
980 | if (value !== undefined) {
|
---|
981 | throw Error(`[@use-gesture]: \`swipeVelocity\` option has been renamed to \`swipe.velocity\`. Use it as in \`{ swipe: { velocity: 0.5 } }\`.`);
|
---|
982 | }
|
---|
983 | return NaN;
|
---|
984 | },
|
---|
985 | swipeDistance(value) {
|
---|
986 | if (value !== undefined) {
|
---|
987 | throw Error(`[@use-gesture]: \`swipeDistance\` option has been renamed to \`swipe.distance\`. Use it as in \`{ swipe: { distance: 50 } }\`.`);
|
---|
988 | }
|
---|
989 | return NaN;
|
---|
990 | },
|
---|
991 | swipeDuration(value) {
|
---|
992 | if (value !== undefined) {
|
---|
993 | throw Error(`[@use-gesture]: \`swipeDuration\` option has been renamed to \`swipe.duration\`. Use it as in \`{ swipe: { duration: 250 } }\`.`);
|
---|
994 | }
|
---|
995 | return NaN;
|
---|
996 | }
|
---|
997 | });
|
---|
998 | }
|
---|
999 |
|
---|
1000 | function clampStateInternalMovementToBounds(state) {
|
---|
1001 | const [ox, oy] = state.overflow;
|
---|
1002 | const [dx, dy] = state._delta;
|
---|
1003 | const [dirx, diry] = state._direction;
|
---|
1004 | if (ox < 0 && dx > 0 && dirx < 0 || ox > 0 && dx < 0 && dirx > 0) {
|
---|
1005 | state._movement[0] = state._movementBound[0];
|
---|
1006 | }
|
---|
1007 | if (oy < 0 && dy > 0 && diry < 0 || oy > 0 && dy < 0 && diry > 0) {
|
---|
1008 | state._movement[1] = state._movementBound[1];
|
---|
1009 | }
|
---|
1010 | }
|
---|
1011 |
|
---|
1012 | const SCALE_ANGLE_RATIO_INTENT_DEG = 30;
|
---|
1013 | const PINCH_WHEEL_RATIO = 100;
|
---|
1014 | class PinchEngine extends Engine {
|
---|
1015 | constructor(...args) {
|
---|
1016 | super(...args);
|
---|
1017 | _defineProperty(this, "ingKey", 'pinching');
|
---|
1018 | _defineProperty(this, "aliasKey", 'da');
|
---|
1019 | }
|
---|
1020 | init() {
|
---|
1021 | this.state.offset = [1, 0];
|
---|
1022 | this.state.lastOffset = [1, 0];
|
---|
1023 | this.state._pointerEvents = new Map();
|
---|
1024 | }
|
---|
1025 | reset() {
|
---|
1026 | super.reset();
|
---|
1027 | const state = this.state;
|
---|
1028 | state._touchIds = [];
|
---|
1029 | state.canceled = false;
|
---|
1030 | state.cancel = this.cancel.bind(this);
|
---|
1031 | state.turns = 0;
|
---|
1032 | }
|
---|
1033 | computeOffset() {
|
---|
1034 | const {
|
---|
1035 | type,
|
---|
1036 | movement,
|
---|
1037 | lastOffset
|
---|
1038 | } = this.state;
|
---|
1039 | if (type === 'wheel') {
|
---|
1040 | this.state.offset = maths.V.add(movement, lastOffset);
|
---|
1041 | } else {
|
---|
1042 | this.state.offset = [(1 + movement[0]) * lastOffset[0], movement[1] + lastOffset[1]];
|
---|
1043 | }
|
---|
1044 | }
|
---|
1045 | computeMovement() {
|
---|
1046 | const {
|
---|
1047 | offset,
|
---|
1048 | lastOffset
|
---|
1049 | } = this.state;
|
---|
1050 | this.state.movement = [offset[0] / lastOffset[0], offset[1] - lastOffset[1]];
|
---|
1051 | }
|
---|
1052 | axisIntent() {
|
---|
1053 | const state = this.state;
|
---|
1054 | const [_m0, _m1] = state._movement;
|
---|
1055 | if (!state.axis) {
|
---|
1056 | const axisMovementDifference = Math.abs(_m0) * SCALE_ANGLE_RATIO_INTENT_DEG - Math.abs(_m1);
|
---|
1057 | if (axisMovementDifference < 0) state.axis = 'angle';else if (axisMovementDifference > 0) state.axis = 'scale';
|
---|
1058 | }
|
---|
1059 | }
|
---|
1060 | restrictToAxis(v) {
|
---|
1061 | if (this.config.lockDirection) {
|
---|
1062 | if (this.state.axis === 'scale') v[1] = 0;else if (this.state.axis === 'angle') v[0] = 0;
|
---|
1063 | }
|
---|
1064 | }
|
---|
1065 | cancel() {
|
---|
1066 | const state = this.state;
|
---|
1067 | if (state.canceled) return;
|
---|
1068 | setTimeout(() => {
|
---|
1069 | state.canceled = true;
|
---|
1070 | state._active = false;
|
---|
1071 | this.compute();
|
---|
1072 | this.emit();
|
---|
1073 | }, 0);
|
---|
1074 | }
|
---|
1075 | touchStart(event) {
|
---|
1076 | this.ctrl.setEventIds(event);
|
---|
1077 | const state = this.state;
|
---|
1078 | const ctrlTouchIds = this.ctrl.touchIds;
|
---|
1079 | if (state._active) {
|
---|
1080 | if (state._touchIds.every(id => ctrlTouchIds.has(id))) return;
|
---|
1081 | }
|
---|
1082 | if (ctrlTouchIds.size < 2) return;
|
---|
1083 | this.start(event);
|
---|
1084 | state._touchIds = Array.from(ctrlTouchIds).slice(0, 2);
|
---|
1085 | const payload = touchDistanceAngle(event, state._touchIds);
|
---|
1086 | if (!payload) return;
|
---|
1087 | this.pinchStart(event, payload);
|
---|
1088 | }
|
---|
1089 | pointerStart(event) {
|
---|
1090 | if (event.buttons != null && event.buttons % 2 !== 1) return;
|
---|
1091 | this.ctrl.setEventIds(event);
|
---|
1092 | event.target.setPointerCapture(event.pointerId);
|
---|
1093 | const state = this.state;
|
---|
1094 | const _pointerEvents = state._pointerEvents;
|
---|
1095 | const ctrlPointerIds = this.ctrl.pointerIds;
|
---|
1096 | if (state._active) {
|
---|
1097 | if (Array.from(_pointerEvents.keys()).every(id => ctrlPointerIds.has(id))) return;
|
---|
1098 | }
|
---|
1099 | if (_pointerEvents.size < 2) {
|
---|
1100 | _pointerEvents.set(event.pointerId, event);
|
---|
1101 | }
|
---|
1102 | if (state._pointerEvents.size < 2) return;
|
---|
1103 | this.start(event);
|
---|
1104 | const payload = distanceAngle(...Array.from(_pointerEvents.values()));
|
---|
1105 | if (!payload) return;
|
---|
1106 | this.pinchStart(event, payload);
|
---|
1107 | }
|
---|
1108 | pinchStart(event, payload) {
|
---|
1109 | const state = this.state;
|
---|
1110 | state.origin = payload.origin;
|
---|
1111 | this.computeValues([payload.distance, payload.angle]);
|
---|
1112 | this.computeInitial();
|
---|
1113 | this.compute(event);
|
---|
1114 | this.emit();
|
---|
1115 | }
|
---|
1116 | touchMove(event) {
|
---|
1117 | if (!this.state._active) return;
|
---|
1118 | const payload = touchDistanceAngle(event, this.state._touchIds);
|
---|
1119 | if (!payload) return;
|
---|
1120 | this.pinchMove(event, payload);
|
---|
1121 | }
|
---|
1122 | pointerMove(event) {
|
---|
1123 | const _pointerEvents = this.state._pointerEvents;
|
---|
1124 | if (_pointerEvents.has(event.pointerId)) {
|
---|
1125 | _pointerEvents.set(event.pointerId, event);
|
---|
1126 | }
|
---|
1127 | if (!this.state._active) return;
|
---|
1128 | const payload = distanceAngle(...Array.from(_pointerEvents.values()));
|
---|
1129 | if (!payload) return;
|
---|
1130 | this.pinchMove(event, payload);
|
---|
1131 | }
|
---|
1132 | pinchMove(event, payload) {
|
---|
1133 | const state = this.state;
|
---|
1134 | const prev_a = state._values[1];
|
---|
1135 | const delta_a = payload.angle - prev_a;
|
---|
1136 | let delta_turns = 0;
|
---|
1137 | if (Math.abs(delta_a) > 270) delta_turns += Math.sign(delta_a);
|
---|
1138 | this.computeValues([payload.distance, payload.angle - 360 * delta_turns]);
|
---|
1139 | state.origin = payload.origin;
|
---|
1140 | state.turns = delta_turns;
|
---|
1141 | state._movement = [state._values[0] / state._initial[0] - 1, state._values[1] - state._initial[1]];
|
---|
1142 | this.compute(event);
|
---|
1143 | this.emit();
|
---|
1144 | }
|
---|
1145 | touchEnd(event) {
|
---|
1146 | this.ctrl.setEventIds(event);
|
---|
1147 | if (!this.state._active) return;
|
---|
1148 | if (this.state._touchIds.some(id => !this.ctrl.touchIds.has(id))) {
|
---|
1149 | this.state._active = false;
|
---|
1150 | this.compute(event);
|
---|
1151 | this.emit();
|
---|
1152 | }
|
---|
1153 | }
|
---|
1154 | pointerEnd(event) {
|
---|
1155 | const state = this.state;
|
---|
1156 | this.ctrl.setEventIds(event);
|
---|
1157 | try {
|
---|
1158 | event.target.releasePointerCapture(event.pointerId);
|
---|
1159 | } catch (_unused) {}
|
---|
1160 | if (state._pointerEvents.has(event.pointerId)) {
|
---|
1161 | state._pointerEvents.delete(event.pointerId);
|
---|
1162 | }
|
---|
1163 | if (!state._active) return;
|
---|
1164 | if (state._pointerEvents.size < 2) {
|
---|
1165 | state._active = false;
|
---|
1166 | this.compute(event);
|
---|
1167 | this.emit();
|
---|
1168 | }
|
---|
1169 | }
|
---|
1170 | gestureStart(event) {
|
---|
1171 | if (event.cancelable) event.preventDefault();
|
---|
1172 | const state = this.state;
|
---|
1173 | if (state._active) return;
|
---|
1174 | this.start(event);
|
---|
1175 | this.computeValues([event.scale, event.rotation]);
|
---|
1176 | state.origin = [event.clientX, event.clientY];
|
---|
1177 | this.compute(event);
|
---|
1178 | this.emit();
|
---|
1179 | }
|
---|
1180 | gestureMove(event) {
|
---|
1181 | if (event.cancelable) event.preventDefault();
|
---|
1182 | if (!this.state._active) return;
|
---|
1183 | const state = this.state;
|
---|
1184 | this.computeValues([event.scale, event.rotation]);
|
---|
1185 | state.origin = [event.clientX, event.clientY];
|
---|
1186 | const _previousMovement = state._movement;
|
---|
1187 | state._movement = [event.scale - 1, event.rotation];
|
---|
1188 | state._delta = maths.V.sub(state._movement, _previousMovement);
|
---|
1189 | this.compute(event);
|
---|
1190 | this.emit();
|
---|
1191 | }
|
---|
1192 | gestureEnd(event) {
|
---|
1193 | if (!this.state._active) return;
|
---|
1194 | this.state._active = false;
|
---|
1195 | this.compute(event);
|
---|
1196 | this.emit();
|
---|
1197 | }
|
---|
1198 | wheel(event) {
|
---|
1199 | const modifierKey = this.config.modifierKey;
|
---|
1200 | if (modifierKey && (Array.isArray(modifierKey) ? !modifierKey.find(k => event[k]) : !event[modifierKey])) return;
|
---|
1201 | if (!this.state._active) this.wheelStart(event);else this.wheelChange(event);
|
---|
1202 | this.timeoutStore.add('wheelEnd', this.wheelEnd.bind(this));
|
---|
1203 | }
|
---|
1204 | wheelStart(event) {
|
---|
1205 | this.start(event);
|
---|
1206 | this.wheelChange(event);
|
---|
1207 | }
|
---|
1208 | wheelChange(event) {
|
---|
1209 | const isR3f = ('uv' in event);
|
---|
1210 | if (!isR3f) {
|
---|
1211 | if (event.cancelable) {
|
---|
1212 | event.preventDefault();
|
---|
1213 | }
|
---|
1214 | if (process.env.NODE_ENV === 'development' && !event.defaultPrevented) {
|
---|
1215 | console.warn(`[@use-gesture]: To properly support zoom on trackpads, try using the \`target\` option.\n\nThis message will only appear in development mode.`);
|
---|
1216 | }
|
---|
1217 | }
|
---|
1218 | const state = this.state;
|
---|
1219 | state._delta = [-wheelValues(event)[1] / PINCH_WHEEL_RATIO * state.offset[0], 0];
|
---|
1220 | maths.V.addTo(state._movement, state._delta);
|
---|
1221 | clampStateInternalMovementToBounds(state);
|
---|
1222 | this.state.origin = [event.clientX, event.clientY];
|
---|
1223 | this.compute(event);
|
---|
1224 | this.emit();
|
---|
1225 | }
|
---|
1226 | wheelEnd() {
|
---|
1227 | if (!this.state._active) return;
|
---|
1228 | this.state._active = false;
|
---|
1229 | this.compute();
|
---|
1230 | this.emit();
|
---|
1231 | }
|
---|
1232 | bind(bindFunction) {
|
---|
1233 | const device = this.config.device;
|
---|
1234 | if (!!device) {
|
---|
1235 | bindFunction(device, 'start', this[device + 'Start'].bind(this));
|
---|
1236 | bindFunction(device, 'change', this[device + 'Move'].bind(this));
|
---|
1237 | bindFunction(device, 'end', this[device + 'End'].bind(this));
|
---|
1238 | bindFunction(device, 'cancel', this[device + 'End'].bind(this));
|
---|
1239 | bindFunction('lostPointerCapture', '', this[device + 'End'].bind(this));
|
---|
1240 | }
|
---|
1241 | if (this.config.pinchOnWheel) {
|
---|
1242 | bindFunction('wheel', '', this.wheel.bind(this), {
|
---|
1243 | passive: false
|
---|
1244 | });
|
---|
1245 | }
|
---|
1246 | }
|
---|
1247 | }
|
---|
1248 |
|
---|
1249 | const pinchConfigResolver = _objectSpread2(_objectSpread2({}, commonConfigResolver), {}, {
|
---|
1250 | device(_v, _k, {
|
---|
1251 | shared,
|
---|
1252 | pointer: {
|
---|
1253 | touch = false
|
---|
1254 | } = {}
|
---|
1255 | }) {
|
---|
1256 | const sharedConfig = shared;
|
---|
1257 | if (sharedConfig.target && !SUPPORT.touch && SUPPORT.gesture) return 'gesture';
|
---|
1258 | if (SUPPORT.touch && touch) return 'touch';
|
---|
1259 | if (SUPPORT.touchscreen) {
|
---|
1260 | if (SUPPORT.pointer) return 'pointer';
|
---|
1261 | if (SUPPORT.touch) return 'touch';
|
---|
1262 | }
|
---|
1263 | },
|
---|
1264 | bounds(_v, _k, {
|
---|
1265 | scaleBounds = {},
|
---|
1266 | angleBounds = {}
|
---|
1267 | }) {
|
---|
1268 | const _scaleBounds = state => {
|
---|
1269 | const D = assignDefault(call(scaleBounds, state), {
|
---|
1270 | min: -Infinity,
|
---|
1271 | max: Infinity
|
---|
1272 | });
|
---|
1273 | return [D.min, D.max];
|
---|
1274 | };
|
---|
1275 | const _angleBounds = state => {
|
---|
1276 | const A = assignDefault(call(angleBounds, state), {
|
---|
1277 | min: -Infinity,
|
---|
1278 | max: Infinity
|
---|
1279 | });
|
---|
1280 | return [A.min, A.max];
|
---|
1281 | };
|
---|
1282 | if (typeof scaleBounds !== 'function' && typeof angleBounds !== 'function') return [_scaleBounds(), _angleBounds()];
|
---|
1283 | return state => [_scaleBounds(state), _angleBounds(state)];
|
---|
1284 | },
|
---|
1285 | threshold(value, _k, config) {
|
---|
1286 | this.lockDirection = config.axis === 'lock';
|
---|
1287 | const threshold = maths.V.toVector(value, this.lockDirection ? [0.1, 3] : 0);
|
---|
1288 | return threshold;
|
---|
1289 | },
|
---|
1290 | modifierKey(value) {
|
---|
1291 | if (value === undefined) return 'ctrlKey';
|
---|
1292 | return value;
|
---|
1293 | },
|
---|
1294 | pinchOnWheel(value = true) {
|
---|
1295 | return value;
|
---|
1296 | }
|
---|
1297 | });
|
---|
1298 |
|
---|
1299 | class MoveEngine extends CoordinatesEngine {
|
---|
1300 | constructor(...args) {
|
---|
1301 | super(...args);
|
---|
1302 | _defineProperty(this, "ingKey", 'moving');
|
---|
1303 | }
|
---|
1304 | move(event) {
|
---|
1305 | if (this.config.mouseOnly && event.pointerType !== 'mouse') return;
|
---|
1306 | if (!this.state._active) this.moveStart(event);else this.moveChange(event);
|
---|
1307 | this.timeoutStore.add('moveEnd', this.moveEnd.bind(this));
|
---|
1308 | }
|
---|
1309 | moveStart(event) {
|
---|
1310 | this.start(event);
|
---|
1311 | this.computeValues(pointerValues(event));
|
---|
1312 | this.compute(event);
|
---|
1313 | this.computeInitial();
|
---|
1314 | this.emit();
|
---|
1315 | }
|
---|
1316 | moveChange(event) {
|
---|
1317 | if (!this.state._active) return;
|
---|
1318 | const values = pointerValues(event);
|
---|
1319 | const state = this.state;
|
---|
1320 | state._delta = maths.V.sub(values, state._values);
|
---|
1321 | maths.V.addTo(state._movement, state._delta);
|
---|
1322 | this.computeValues(values);
|
---|
1323 | this.compute(event);
|
---|
1324 | this.emit();
|
---|
1325 | }
|
---|
1326 | moveEnd(event) {
|
---|
1327 | if (!this.state._active) return;
|
---|
1328 | this.state._active = false;
|
---|
1329 | this.compute(event);
|
---|
1330 | this.emit();
|
---|
1331 | }
|
---|
1332 | bind(bindFunction) {
|
---|
1333 | bindFunction('pointer', 'change', this.move.bind(this));
|
---|
1334 | bindFunction('pointer', 'leave', this.moveEnd.bind(this));
|
---|
1335 | }
|
---|
1336 | }
|
---|
1337 |
|
---|
1338 | const moveConfigResolver = _objectSpread2(_objectSpread2({}, coordinatesConfigResolver), {}, {
|
---|
1339 | mouseOnly: (value = true) => value
|
---|
1340 | });
|
---|
1341 |
|
---|
1342 | class ScrollEngine extends CoordinatesEngine {
|
---|
1343 | constructor(...args) {
|
---|
1344 | super(...args);
|
---|
1345 | _defineProperty(this, "ingKey", 'scrolling');
|
---|
1346 | }
|
---|
1347 | scroll(event) {
|
---|
1348 | if (!this.state._active) this.start(event);
|
---|
1349 | this.scrollChange(event);
|
---|
1350 | this.timeoutStore.add('scrollEnd', this.scrollEnd.bind(this));
|
---|
1351 | }
|
---|
1352 | scrollChange(event) {
|
---|
1353 | if (event.cancelable) event.preventDefault();
|
---|
1354 | const state = this.state;
|
---|
1355 | const values = scrollValues(event);
|
---|
1356 | state._delta = maths.V.sub(values, state._values);
|
---|
1357 | maths.V.addTo(state._movement, state._delta);
|
---|
1358 | this.computeValues(values);
|
---|
1359 | this.compute(event);
|
---|
1360 | this.emit();
|
---|
1361 | }
|
---|
1362 | scrollEnd() {
|
---|
1363 | if (!this.state._active) return;
|
---|
1364 | this.state._active = false;
|
---|
1365 | this.compute();
|
---|
1366 | this.emit();
|
---|
1367 | }
|
---|
1368 | bind(bindFunction) {
|
---|
1369 | bindFunction('scroll', '', this.scroll.bind(this));
|
---|
1370 | }
|
---|
1371 | }
|
---|
1372 |
|
---|
1373 | const scrollConfigResolver = coordinatesConfigResolver;
|
---|
1374 |
|
---|
1375 | class WheelEngine extends CoordinatesEngine {
|
---|
1376 | constructor(...args) {
|
---|
1377 | super(...args);
|
---|
1378 | _defineProperty(this, "ingKey", 'wheeling');
|
---|
1379 | }
|
---|
1380 | wheel(event) {
|
---|
1381 | if (!this.state._active) this.start(event);
|
---|
1382 | this.wheelChange(event);
|
---|
1383 | this.timeoutStore.add('wheelEnd', this.wheelEnd.bind(this));
|
---|
1384 | }
|
---|
1385 | wheelChange(event) {
|
---|
1386 | const state = this.state;
|
---|
1387 | state._delta = wheelValues(event);
|
---|
1388 | maths.V.addTo(state._movement, state._delta);
|
---|
1389 | clampStateInternalMovementToBounds(state);
|
---|
1390 | this.compute(event);
|
---|
1391 | this.emit();
|
---|
1392 | }
|
---|
1393 | wheelEnd() {
|
---|
1394 | if (!this.state._active) return;
|
---|
1395 | this.state._active = false;
|
---|
1396 | this.compute();
|
---|
1397 | this.emit();
|
---|
1398 | }
|
---|
1399 | bind(bindFunction) {
|
---|
1400 | bindFunction('wheel', '', this.wheel.bind(this));
|
---|
1401 | }
|
---|
1402 | }
|
---|
1403 |
|
---|
1404 | const wheelConfigResolver = coordinatesConfigResolver;
|
---|
1405 |
|
---|
1406 | class HoverEngine extends CoordinatesEngine {
|
---|
1407 | constructor(...args) {
|
---|
1408 | super(...args);
|
---|
1409 | _defineProperty(this, "ingKey", 'hovering');
|
---|
1410 | }
|
---|
1411 | enter(event) {
|
---|
1412 | if (this.config.mouseOnly && event.pointerType !== 'mouse') return;
|
---|
1413 | this.start(event);
|
---|
1414 | this.computeValues(pointerValues(event));
|
---|
1415 | this.compute(event);
|
---|
1416 | this.emit();
|
---|
1417 | }
|
---|
1418 | leave(event) {
|
---|
1419 | if (this.config.mouseOnly && event.pointerType !== 'mouse') return;
|
---|
1420 | const state = this.state;
|
---|
1421 | if (!state._active) return;
|
---|
1422 | state._active = false;
|
---|
1423 | const values = pointerValues(event);
|
---|
1424 | state._movement = state._delta = maths.V.sub(values, state._values);
|
---|
1425 | this.computeValues(values);
|
---|
1426 | this.compute(event);
|
---|
1427 | state.delta = state.movement;
|
---|
1428 | this.emit();
|
---|
1429 | }
|
---|
1430 | bind(bindFunction) {
|
---|
1431 | bindFunction('pointer', 'enter', this.enter.bind(this));
|
---|
1432 | bindFunction('pointer', 'leave', this.leave.bind(this));
|
---|
1433 | }
|
---|
1434 | }
|
---|
1435 |
|
---|
1436 | const hoverConfigResolver = _objectSpread2(_objectSpread2({}, coordinatesConfigResolver), {}, {
|
---|
1437 | mouseOnly: (value = true) => value
|
---|
1438 | });
|
---|
1439 |
|
---|
1440 | const EngineMap = new Map();
|
---|
1441 | const ConfigResolverMap = new Map();
|
---|
1442 | function registerAction(action) {
|
---|
1443 | EngineMap.set(action.key, action.engine);
|
---|
1444 | ConfigResolverMap.set(action.key, action.resolver);
|
---|
1445 | }
|
---|
1446 | const dragAction = {
|
---|
1447 | key: 'drag',
|
---|
1448 | engine: DragEngine,
|
---|
1449 | resolver: dragConfigResolver
|
---|
1450 | };
|
---|
1451 | const hoverAction = {
|
---|
1452 | key: 'hover',
|
---|
1453 | engine: HoverEngine,
|
---|
1454 | resolver: hoverConfigResolver
|
---|
1455 | };
|
---|
1456 | const moveAction = {
|
---|
1457 | key: 'move',
|
---|
1458 | engine: MoveEngine,
|
---|
1459 | resolver: moveConfigResolver
|
---|
1460 | };
|
---|
1461 | const pinchAction = {
|
---|
1462 | key: 'pinch',
|
---|
1463 | engine: PinchEngine,
|
---|
1464 | resolver: pinchConfigResolver
|
---|
1465 | };
|
---|
1466 | const scrollAction = {
|
---|
1467 | key: 'scroll',
|
---|
1468 | engine: ScrollEngine,
|
---|
1469 | resolver: scrollConfigResolver
|
---|
1470 | };
|
---|
1471 | const wheelAction = {
|
---|
1472 | key: 'wheel',
|
---|
1473 | engine: WheelEngine,
|
---|
1474 | resolver: wheelConfigResolver
|
---|
1475 | };
|
---|
1476 |
|
---|
1477 | exports.ConfigResolverMap = ConfigResolverMap;
|
---|
1478 | exports.EngineMap = EngineMap;
|
---|
1479 | exports.SUPPORT = SUPPORT;
|
---|
1480 | exports._defineProperty = _defineProperty;
|
---|
1481 | exports._objectSpread2 = _objectSpread2;
|
---|
1482 | exports.chain = chain;
|
---|
1483 | exports.dragAction = dragAction;
|
---|
1484 | exports.hoverAction = hoverAction;
|
---|
1485 | exports.isTouch = isTouch;
|
---|
1486 | exports.moveAction = moveAction;
|
---|
1487 | exports.parseProp = parseProp;
|
---|
1488 | exports.pinchAction = pinchAction;
|
---|
1489 | exports.registerAction = registerAction;
|
---|
1490 | exports.scrollAction = scrollAction;
|
---|
1491 | exports.toDomEventType = toDomEventType;
|
---|
1492 | exports.toHandlerProp = toHandlerProp;
|
---|
1493 | exports.touchIds = touchIds;
|
---|
1494 | exports.wheelAction = wheelAction;
|
---|