@use-gesture/core
Advanced tools
Comparing version 10.2.20 to 10.2.21
@@ -5,4 +5,4 @@ 'use strict'; | ||
var actions_dist_useGestureCoreActions = require('../../dist/actions-0cfdaa2b.cjs.dev.js'); | ||
require('../../dist/maths-125ca19a.cjs.dev.js'); | ||
var actions_dist_useGestureCoreActions = require('../../dist/actions-d22126b2.cjs.dev.js'); | ||
require('../../dist/maths-0c237923.cjs.dev.js'); | ||
@@ -9,0 +9,0 @@ |
@@ -5,4 +5,4 @@ 'use strict'; | ||
var actions_dist_useGestureCoreActions = require('../../dist/actions-a6340fd5.cjs.prod.js'); | ||
require('../../dist/maths-a42ecce1.cjs.prod.js'); | ||
var actions_dist_useGestureCoreActions = require('../../dist/actions-7f18c240.cjs.prod.js'); | ||
require('../../dist/maths-306fe672.cjs.prod.js'); | ||
@@ -9,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
export { C as ConfigResolverMap, E as EngineMap, e as dragAction, h as hoverAction, m as moveAction, f as pinchAction, r as registerAction, s as scrollAction, w as wheelAction } from '../../dist/actions-aeda4790.esm.js'; | ||
import '../../dist/maths-b2a210f4.esm.js'; | ||
export { C as ConfigResolverMap, E as EngineMap, e as dragAction, h as hoverAction, m as moveAction, f as pinchAction, r as registerAction, s as scrollAction, w as wheelAction } from '../../dist/actions-71ad3053.esm.js'; | ||
import '../../dist/maths-b28d9b98.esm.js'; |
# @use-gesture/core | ||
## 10.2.21 | ||
### Patch Changes | ||
- 6f4c09b55: fix: rolls back wheel-based pinch movement to bounds (thanks [@Andarist](https://github.com/Andarist)!) | ||
- 854f4dfc1: feat (pinch): | ||
- `pinchOnwheel: false` prevents pinching with wheel. | ||
## 10.2.20 | ||
@@ -4,0 +13,0 @@ |
@@ -29,2 +29,3 @@ import { ModifierKey } from '../types'; | ||
modifierKey?: ModifierKey | undefined; | ||
pinchOnWheel?: boolean | undefined; | ||
}): "touch" | "pointer" | "gesture" | undefined; | ||
@@ -34,2 +35,3 @@ bounds(_v: any, _k: string, { scaleBounds, angleBounds }: PinchConfig): number[][] | ((state: State) => number[][]); | ||
modifierKey(value: ModifierKey): ModifierKey; | ||
pinchOnWheel(value?: boolean): boolean; | ||
enabled(value?: boolean): boolean; | ||
@@ -36,0 +38,0 @@ eventOptions(value: AddEventListenerOptions | undefined, _k: string, config: { |
@@ -120,2 +120,6 @@ import { State } from './state'; | ||
modifierKey?: ModifierKey; | ||
/** | ||
* Whether wheel should trigger a pinch at all. | ||
*/ | ||
pinchOnWheel?: boolean; | ||
}; | ||
@@ -122,0 +126,0 @@ export declare type DragBounds = Bounds | HTMLElement | { |
@@ -53,2 +53,3 @@ import { GestureKey, CoordinatesKey, ModifierKey } from './config'; | ||
modifierKey: ModifierKey; | ||
pinchOnWheel: boolean; | ||
}; | ||
@@ -55,0 +56,0 @@ declare type MoveAndHoverMouseOnly = { |
@@ -5,4 +5,4 @@ 'use strict'; | ||
var actions_dist_useGestureCoreActions = require('./actions-0cfdaa2b.cjs.dev.js'); | ||
require('./maths-125ca19a.cjs.dev.js'); | ||
var actions_dist_useGestureCoreActions = require('./actions-d22126b2.cjs.dev.js'); | ||
require('./maths-0c237923.cjs.dev.js'); | ||
@@ -14,3 +14,2 @@ function _objectWithoutPropertiesLoose(source, excluded) { | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
@@ -21,3 +20,2 @@ key = sourceKeys[i]; | ||
} | ||
return target; | ||
@@ -30,6 +28,4 @@ } | ||
var key, i; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
@@ -42,3 +38,2 @@ key = sourceSymbolKeys[i]; | ||
} | ||
return target; | ||
@@ -52,14 +47,10 @@ } | ||
} | ||
return undefined; | ||
}, | ||
enabled(value = true) { | ||
return value; | ||
}, | ||
window(value = actions_dist_useGestureCoreActions.SUPPORT.isBrowser ? window : undefined) { | ||
return value; | ||
}, | ||
eventOptions({ | ||
@@ -74,7 +65,5 @@ passive = true, | ||
}, | ||
transform(value) { | ||
return value; | ||
} | ||
}; | ||
@@ -85,3 +74,2 @@ | ||
const result = {}; | ||
for (const [key, resolver] of Object.entries(resolvers)) { | ||
@@ -96,9 +84,6 @@ switch (typeof resolver) { | ||
} | ||
break; | ||
case 'object': | ||
result[key] = resolveWith(config[key], resolver); | ||
break; | ||
case 'boolean': | ||
@@ -109,3 +94,2 @@ if (resolver) result[key] = config[key]; | ||
} | ||
return result; | ||
@@ -115,11 +99,10 @@ } | ||
const _ref = newConfig, | ||
{ | ||
target, | ||
eventOptions, | ||
window, | ||
enabled, | ||
transform | ||
} = _ref, | ||
rest = _objectWithoutProperties(_ref, _excluded); | ||
{ | ||
target, | ||
eventOptions, | ||
window, | ||
enabled, | ||
transform | ||
} = _ref, | ||
rest = _objectWithoutProperties(_ref, _excluded); | ||
_config.shared = resolveWith({ | ||
@@ -132,3 +115,2 @@ target, | ||
}, sharedConfigResolver); | ||
if (gestureKey) { | ||
@@ -142,3 +124,2 @@ const resolver = actions_dist_useGestureCoreActions.ConfigResolverMap.get(gestureKey); | ||
const resolver = actions_dist_useGestureCoreActions.ConfigResolverMap.get(key); | ||
if (resolver) { | ||
@@ -153,3 +134,2 @@ _config[key] = resolveWith(actions_dist_useGestureCoreActions._objectSpread2({ | ||
} | ||
console.warn(`[@use-gesture]: Unknown config key \`${key}\` was used. Please read the documentation for further information.`); | ||
@@ -160,3 +140,2 @@ } | ||
} | ||
return _config; | ||
@@ -168,17 +147,11 @@ } | ||
actions_dist_useGestureCoreActions._defineProperty(this, "_listeners", new Set()); | ||
this._ctrl = ctrl; | ||
this._gestureKey = gestureKey; | ||
} | ||
add(element, device, action, handler, options) { | ||
const listeners = this._listeners; | ||
const type = actions_dist_useGestureCoreActions.toDomEventType(device, action); | ||
const _options = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}; | ||
const eventOptions = actions_dist_useGestureCoreActions._objectSpread2(actions_dist_useGestureCoreActions._objectSpread2({}, _options), options); | ||
element.addEventListener(type, handler, eventOptions); | ||
const remove = () => { | ||
@@ -188,13 +161,9 @@ element.removeEventListener(type, handler, eventOptions); | ||
}; | ||
listeners.add(remove); | ||
return remove; | ||
} | ||
clean() { | ||
this._listeners.forEach(remove => remove()); | ||
this._listeners.clear(); | ||
} | ||
} | ||
@@ -206,41 +175,27 @@ | ||
} | ||
add(key, callback, ms = 140, ...args) { | ||
this.remove(key); | ||
this._timeouts.set(key, window.setTimeout(callback, ms, ...args)); | ||
} | ||
remove(key) { | ||
const timeout = this._timeouts.get(key); | ||
if (timeout) window.clearTimeout(timeout); | ||
} | ||
clean() { | ||
this._timeouts.forEach(timeout => void window.clearTimeout(timeout)); | ||
this._timeouts.clear(); | ||
} | ||
} | ||
class Controller { | ||
constructor(handlers) { | ||
actions_dist_useGestureCoreActions._defineProperty(this, "gestures", new Set()); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "_targetEventStore", new EventStore(this)); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "gestureEventStores", {}); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "gestureTimeoutStores", {}); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "handlers", {}); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "config", {}); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "pointerIds", new Set()); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "touchIds", new Set()); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "state", { | ||
@@ -254,6 +209,4 @@ shared: { | ||
}); | ||
resolveGestures(this, handlers); | ||
} | ||
setEventIds(event) { | ||
@@ -268,3 +221,2 @@ if (actions_dist_useGestureCoreActions.isTouch(event)) { | ||
} | ||
applyHandlers(handlers, nativeHandlers) { | ||
@@ -274,10 +226,7 @@ this.handlers = handlers; | ||
} | ||
applyConfig(config, gestureKey) { | ||
this.config = parse(config, gestureKey, this.config); | ||
} | ||
clean() { | ||
this._targetEventStore.clean(); | ||
for (const key of this.gestures) { | ||
@@ -288,3 +237,2 @@ this.gestureEventStores[key].clean(); | ||
} | ||
effect() { | ||
@@ -294,3 +242,2 @@ if (this.config.shared.target) this.bind(); | ||
} | ||
bind(...args) { | ||
@@ -300,3 +247,2 @@ const sharedConfig = this.config.shared; | ||
let target; | ||
if (sharedConfig.target) { | ||
@@ -306,3 +252,2 @@ target = sharedConfig.target(); | ||
} | ||
if (sharedConfig.enabled) { | ||
@@ -312,3 +257,2 @@ for (const gestureKey of this.gestures) { | ||
const bindFunction = bindToProps(props, gestureConfig.eventOptions, !!target); | ||
if (gestureConfig.enabled) { | ||
@@ -321,5 +265,5 @@ const Engine = actions_dist_useGestureCoreActions.EngineMap.get(gestureKey); | ||
const nativeBindFunction = bindToProps(props, sharedConfig.eventOptions, !!target); | ||
for (const eventKey in this.nativeHandlers) { | ||
nativeBindFunction(eventKey, '', event => this.nativeHandlers[eventKey](actions_dist_useGestureCoreActions._objectSpread2(actions_dist_useGestureCoreActions._objectSpread2({}, this.state.shared), {}, { | ||
nativeBindFunction(eventKey, '', | ||
event => this.nativeHandlers[eventKey](actions_dist_useGestureCoreActions._objectSpread2(actions_dist_useGestureCoreActions._objectSpread2({}, this.state.shared), {}, { | ||
event, | ||
@@ -343,3 +287,2 @@ args | ||
} = actions_dist_useGestureCoreActions.parseProp(handlerProp); | ||
this._targetEventStore.add(target, device, '', props[handlerProp], { | ||
@@ -351,5 +294,3 @@ capture, | ||
} | ||
} | ||
function setupGesture(ctrl, gestureKey) { | ||
@@ -360,3 +301,2 @@ ctrl.gestures.add(gestureKey); | ||
} | ||
function resolveGestures(ctrl, internalHandlers) { | ||
@@ -370,6 +310,4 @@ if (internalHandlers.drag) setupGesture(ctrl, 'drag'); | ||
} | ||
const bindToProps = (props, eventOptions, withPassiveOption) => (device, action, handler, options = {}, isNative = false) => { | ||
var _options$capture, _options$passive; | ||
const capture = (_options$capture = options.capture) !== null && _options$capture !== void 0 ? _options$capture : eventOptions.capture; | ||
@@ -384,3 +322,2 @@ const passive = (_options$passive = options.passive) !== null && _options$passive !== void 0 ? _options$passive : eventOptions.passive; | ||
const RE_NOT_NATIVE = /^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/; | ||
function sortHandlers(_handlers) { | ||
@@ -390,3 +327,2 @@ const native = {}; | ||
const actions = new Set(); | ||
for (let key in _handlers) { | ||
@@ -400,9 +336,6 @@ if (RE_NOT_NATIVE.test(key)) { | ||
} | ||
return [handlers, native, actions]; | ||
} | ||
function registerGesture(actions, handlers, handlerKey, key, internalHandlers, config) { | ||
if (!actions.has(handlerKey)) return; | ||
if (!actions_dist_useGestureCoreActions.EngineMap.has(key)) { | ||
@@ -412,9 +345,6 @@ if (process.env.NODE_ENV === 'development') { | ||
} | ||
return; | ||
} | ||
const startKey = handlerKey + 'Start'; | ||
const endKey = handlerKey + 'End'; | ||
const fn = state => { | ||
@@ -427,7 +357,5 @@ let memo = undefined; | ||
}; | ||
internalHandlers[key] = fn; | ||
config[key] = config[key] || {}; | ||
} | ||
function parseMergedHandlers(mergedHandlers, mergedConfig) { | ||
@@ -434,0 +362,0 @@ const [handlers, nativeHandlers, actions] = sortHandlers(mergedHandlers); |
@@ -5,4 +5,4 @@ 'use strict'; | ||
var actions_dist_useGestureCoreActions = require('./actions-a6340fd5.cjs.prod.js'); | ||
require('./maths-a42ecce1.cjs.prod.js'); | ||
var actions_dist_useGestureCoreActions = require('./actions-7f18c240.cjs.prod.js'); | ||
require('./maths-306fe672.cjs.prod.js'); | ||
@@ -14,3 +14,2 @@ function _objectWithoutPropertiesLoose(source, excluded) { | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
@@ -21,3 +20,2 @@ key = sourceKeys[i]; | ||
} | ||
return target; | ||
@@ -30,6 +28,4 @@ } | ||
var key, i; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
@@ -42,3 +38,2 @@ key = sourceSymbolKeys[i]; | ||
} | ||
return target; | ||
@@ -52,14 +47,10 @@ } | ||
} | ||
return undefined; | ||
}, | ||
enabled(value = true) { | ||
return value; | ||
}, | ||
window(value = actions_dist_useGestureCoreActions.SUPPORT.isBrowser ? window : undefined) { | ||
return value; | ||
}, | ||
eventOptions({ | ||
@@ -74,7 +65,5 @@ passive = true, | ||
}, | ||
transform(value) { | ||
return value; | ||
} | ||
}; | ||
@@ -85,3 +74,2 @@ | ||
const result = {}; | ||
for (const [key, resolver] of Object.entries(resolvers)) { | ||
@@ -93,9 +81,6 @@ switch (typeof resolver) { | ||
} | ||
break; | ||
case 'object': | ||
result[key] = resolveWith(config[key], resolver); | ||
break; | ||
case 'boolean': | ||
@@ -106,3 +91,2 @@ if (resolver) result[key] = config[key]; | ||
} | ||
return result; | ||
@@ -112,11 +96,10 @@ } | ||
const _ref = newConfig, | ||
{ | ||
target, | ||
eventOptions, | ||
window, | ||
enabled, | ||
transform | ||
} = _ref, | ||
rest = _objectWithoutProperties(_ref, _excluded); | ||
{ | ||
target, | ||
eventOptions, | ||
window, | ||
enabled, | ||
transform | ||
} = _ref, | ||
rest = _objectWithoutProperties(_ref, _excluded); | ||
_config.shared = resolveWith({ | ||
@@ -129,3 +112,2 @@ target, | ||
}, sharedConfigResolver); | ||
if (gestureKey) { | ||
@@ -139,3 +121,2 @@ const resolver = actions_dist_useGestureCoreActions.ConfigResolverMap.get(gestureKey); | ||
const resolver = actions_dist_useGestureCoreActions.ConfigResolverMap.get(key); | ||
if (resolver) { | ||
@@ -148,3 +129,2 @@ _config[key] = resolveWith(actions_dist_useGestureCoreActions._objectSpread2({ | ||
} | ||
return _config; | ||
@@ -156,17 +136,11 @@ } | ||
actions_dist_useGestureCoreActions._defineProperty(this, "_listeners", new Set()); | ||
this._ctrl = ctrl; | ||
this._gestureKey = gestureKey; | ||
} | ||
add(element, device, action, handler, options) { | ||
const listeners = this._listeners; | ||
const type = actions_dist_useGestureCoreActions.toDomEventType(device, action); | ||
const _options = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}; | ||
const eventOptions = actions_dist_useGestureCoreActions._objectSpread2(actions_dist_useGestureCoreActions._objectSpread2({}, _options), options); | ||
element.addEventListener(type, handler, eventOptions); | ||
const remove = () => { | ||
@@ -176,13 +150,9 @@ element.removeEventListener(type, handler, eventOptions); | ||
}; | ||
listeners.add(remove); | ||
return remove; | ||
} | ||
clean() { | ||
this._listeners.forEach(remove => remove()); | ||
this._listeners.clear(); | ||
} | ||
} | ||
@@ -194,41 +164,27 @@ | ||
} | ||
add(key, callback, ms = 140, ...args) { | ||
this.remove(key); | ||
this._timeouts.set(key, window.setTimeout(callback, ms, ...args)); | ||
} | ||
remove(key) { | ||
const timeout = this._timeouts.get(key); | ||
if (timeout) window.clearTimeout(timeout); | ||
} | ||
clean() { | ||
this._timeouts.forEach(timeout => void window.clearTimeout(timeout)); | ||
this._timeouts.clear(); | ||
} | ||
} | ||
class Controller { | ||
constructor(handlers) { | ||
actions_dist_useGestureCoreActions._defineProperty(this, "gestures", new Set()); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "_targetEventStore", new EventStore(this)); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "gestureEventStores", {}); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "gestureTimeoutStores", {}); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "handlers", {}); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "config", {}); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "pointerIds", new Set()); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "touchIds", new Set()); | ||
actions_dist_useGestureCoreActions._defineProperty(this, "state", { | ||
@@ -242,6 +198,4 @@ shared: { | ||
}); | ||
resolveGestures(this, handlers); | ||
} | ||
setEventIds(event) { | ||
@@ -256,3 +210,2 @@ if (actions_dist_useGestureCoreActions.isTouch(event)) { | ||
} | ||
applyHandlers(handlers, nativeHandlers) { | ||
@@ -262,10 +215,7 @@ this.handlers = handlers; | ||
} | ||
applyConfig(config, gestureKey) { | ||
this.config = parse(config, gestureKey, this.config); | ||
} | ||
clean() { | ||
this._targetEventStore.clean(); | ||
for (const key of this.gestures) { | ||
@@ -276,3 +226,2 @@ this.gestureEventStores[key].clean(); | ||
} | ||
effect() { | ||
@@ -282,3 +231,2 @@ if (this.config.shared.target) this.bind(); | ||
} | ||
bind(...args) { | ||
@@ -288,3 +236,2 @@ const sharedConfig = this.config.shared; | ||
let target; | ||
if (sharedConfig.target) { | ||
@@ -294,3 +241,2 @@ target = sharedConfig.target(); | ||
} | ||
if (sharedConfig.enabled) { | ||
@@ -300,3 +246,2 @@ for (const gestureKey of this.gestures) { | ||
const bindFunction = bindToProps(props, gestureConfig.eventOptions, !!target); | ||
if (gestureConfig.enabled) { | ||
@@ -309,5 +254,5 @@ const Engine = actions_dist_useGestureCoreActions.EngineMap.get(gestureKey); | ||
const nativeBindFunction = bindToProps(props, sharedConfig.eventOptions, !!target); | ||
for (const eventKey in this.nativeHandlers) { | ||
nativeBindFunction(eventKey, '', event => this.nativeHandlers[eventKey](actions_dist_useGestureCoreActions._objectSpread2(actions_dist_useGestureCoreActions._objectSpread2({}, this.state.shared), {}, { | ||
nativeBindFunction(eventKey, '', | ||
event => this.nativeHandlers[eventKey](actions_dist_useGestureCoreActions._objectSpread2(actions_dist_useGestureCoreActions._objectSpread2({}, this.state.shared), {}, { | ||
event, | ||
@@ -331,3 +276,2 @@ args | ||
} = actions_dist_useGestureCoreActions.parseProp(handlerProp); | ||
this._targetEventStore.add(target, device, '', props[handlerProp], { | ||
@@ -339,5 +283,3 @@ capture, | ||
} | ||
} | ||
function setupGesture(ctrl, gestureKey) { | ||
@@ -348,3 +290,2 @@ ctrl.gestures.add(gestureKey); | ||
} | ||
function resolveGestures(ctrl, internalHandlers) { | ||
@@ -358,6 +299,4 @@ if (internalHandlers.drag) setupGesture(ctrl, 'drag'); | ||
} | ||
const bindToProps = (props, eventOptions, withPassiveOption) => (device, action, handler, options = {}, isNative = false) => { | ||
var _options$capture, _options$passive; | ||
const capture = (_options$capture = options.capture) !== null && _options$capture !== void 0 ? _options$capture : eventOptions.capture; | ||
@@ -372,3 +311,2 @@ const passive = (_options$passive = options.passive) !== null && _options$passive !== void 0 ? _options$passive : eventOptions.passive; | ||
const RE_NOT_NATIVE = /^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/; | ||
function sortHandlers(_handlers) { | ||
@@ -378,3 +316,2 @@ const native = {}; | ||
const actions = new Set(); | ||
for (let key in _handlers) { | ||
@@ -388,17 +325,11 @@ if (RE_NOT_NATIVE.test(key)) { | ||
} | ||
return [handlers, native, actions]; | ||
} | ||
function registerGesture(actions, handlers, handlerKey, key, internalHandlers, config) { | ||
if (!actions.has(handlerKey)) return; | ||
if (!actions_dist_useGestureCoreActions.EngineMap.has(key)) { | ||
return; | ||
} | ||
const startKey = handlerKey + 'Start'; | ||
const endKey = handlerKey + 'End'; | ||
const fn = state => { | ||
@@ -411,7 +342,5 @@ let memo = undefined; | ||
}; | ||
internalHandlers[key] = fn; | ||
config[key] = config[key] || {}; | ||
} | ||
function parseMergedHandlers(mergedHandlers, mergedConfig) { | ||
@@ -418,0 +347,0 @@ const [handlers, nativeHandlers, actions] = sortHandlers(mergedHandlers); |
@@ -1,3 +0,3 @@ | ||
import { S as SUPPORT, C as ConfigResolverMap, _ as _objectSpread2, a as _defineProperty, t as toDomEventType, i as isTouch, b as touchIds, E as EngineMap, c as chain, p as parseProp, d as toHandlerProp } from './actions-aeda4790.esm.js'; | ||
import './maths-b2a210f4.esm.js'; | ||
import { S as SUPPORT, C as ConfigResolverMap, _ as _objectSpread2, a as _defineProperty, t as toDomEventType, i as isTouch, b as touchIds, E as EngineMap, c as chain, p as parseProp, d as toHandlerProp } from './actions-71ad3053.esm.js'; | ||
import './maths-b28d9b98.esm.js'; | ||
@@ -9,3 +9,2 @@ function _objectWithoutPropertiesLoose(source, excluded) { | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
@@ -16,3 +15,2 @@ key = sourceKeys[i]; | ||
} | ||
return target; | ||
@@ -25,6 +23,4 @@ } | ||
var key, i; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
@@ -37,3 +33,2 @@ key = sourceSymbolKeys[i]; | ||
} | ||
return target; | ||
@@ -47,14 +42,10 @@ } | ||
} | ||
return undefined; | ||
}, | ||
enabled(value = true) { | ||
return value; | ||
}, | ||
window(value = SUPPORT.isBrowser ? window : undefined) { | ||
return value; | ||
}, | ||
eventOptions({ | ||
@@ -69,7 +60,5 @@ passive = true, | ||
}, | ||
transform(value) { | ||
return value; | ||
} | ||
}; | ||
@@ -80,3 +69,2 @@ | ||
const result = {}; | ||
for (const [key, resolver] of Object.entries(resolvers)) { | ||
@@ -91,9 +79,6 @@ switch (typeof resolver) { | ||
} | ||
break; | ||
case 'object': | ||
result[key] = resolveWith(config[key], resolver); | ||
break; | ||
case 'boolean': | ||
@@ -104,3 +89,2 @@ if (resolver) result[key] = config[key]; | ||
} | ||
return result; | ||
@@ -110,11 +94,10 @@ } | ||
const _ref = newConfig, | ||
{ | ||
target, | ||
eventOptions, | ||
window, | ||
enabled, | ||
transform | ||
} = _ref, | ||
rest = _objectWithoutProperties(_ref, _excluded); | ||
{ | ||
target, | ||
eventOptions, | ||
window, | ||
enabled, | ||
transform | ||
} = _ref, | ||
rest = _objectWithoutProperties(_ref, _excluded); | ||
_config.shared = resolveWith({ | ||
@@ -127,3 +110,2 @@ target, | ||
}, sharedConfigResolver); | ||
if (gestureKey) { | ||
@@ -137,3 +119,2 @@ const resolver = ConfigResolverMap.get(gestureKey); | ||
const resolver = ConfigResolverMap.get(key); | ||
if (resolver) { | ||
@@ -148,3 +129,2 @@ _config[key] = resolveWith(_objectSpread2({ | ||
} | ||
console.warn(`[@use-gesture]: Unknown config key \`${key}\` was used. Please read the documentation for further information.`); | ||
@@ -155,3 +135,2 @@ } | ||
} | ||
return _config; | ||
@@ -163,17 +142,11 @@ } | ||
_defineProperty(this, "_listeners", new Set()); | ||
this._ctrl = ctrl; | ||
this._gestureKey = gestureKey; | ||
} | ||
add(element, device, action, handler, options) { | ||
const listeners = this._listeners; | ||
const type = toDomEventType(device, action); | ||
const _options = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}; | ||
const eventOptions = _objectSpread2(_objectSpread2({}, _options), options); | ||
element.addEventListener(type, handler, eventOptions); | ||
const remove = () => { | ||
@@ -183,13 +156,9 @@ element.removeEventListener(type, handler, eventOptions); | ||
}; | ||
listeners.add(remove); | ||
return remove; | ||
} | ||
clean() { | ||
this._listeners.forEach(remove => remove()); | ||
this._listeners.clear(); | ||
} | ||
} | ||
@@ -201,41 +170,27 @@ | ||
} | ||
add(key, callback, ms = 140, ...args) { | ||
this.remove(key); | ||
this._timeouts.set(key, window.setTimeout(callback, ms, ...args)); | ||
} | ||
remove(key) { | ||
const timeout = this._timeouts.get(key); | ||
if (timeout) window.clearTimeout(timeout); | ||
} | ||
clean() { | ||
this._timeouts.forEach(timeout => void window.clearTimeout(timeout)); | ||
this._timeouts.clear(); | ||
} | ||
} | ||
class Controller { | ||
constructor(handlers) { | ||
_defineProperty(this, "gestures", new Set()); | ||
_defineProperty(this, "_targetEventStore", new EventStore(this)); | ||
_defineProperty(this, "gestureEventStores", {}); | ||
_defineProperty(this, "gestureTimeoutStores", {}); | ||
_defineProperty(this, "handlers", {}); | ||
_defineProperty(this, "config", {}); | ||
_defineProperty(this, "pointerIds", new Set()); | ||
_defineProperty(this, "touchIds", new Set()); | ||
_defineProperty(this, "state", { | ||
@@ -249,6 +204,4 @@ shared: { | ||
}); | ||
resolveGestures(this, handlers); | ||
} | ||
setEventIds(event) { | ||
@@ -263,3 +216,2 @@ if (isTouch(event)) { | ||
} | ||
applyHandlers(handlers, nativeHandlers) { | ||
@@ -269,10 +221,7 @@ this.handlers = handlers; | ||
} | ||
applyConfig(config, gestureKey) { | ||
this.config = parse(config, gestureKey, this.config); | ||
} | ||
clean() { | ||
this._targetEventStore.clean(); | ||
for (const key of this.gestures) { | ||
@@ -283,3 +232,2 @@ this.gestureEventStores[key].clean(); | ||
} | ||
effect() { | ||
@@ -289,3 +237,2 @@ if (this.config.shared.target) this.bind(); | ||
} | ||
bind(...args) { | ||
@@ -295,3 +242,2 @@ const sharedConfig = this.config.shared; | ||
let target; | ||
if (sharedConfig.target) { | ||
@@ -301,3 +247,2 @@ target = sharedConfig.target(); | ||
} | ||
if (sharedConfig.enabled) { | ||
@@ -307,3 +252,2 @@ for (const gestureKey of this.gestures) { | ||
const bindFunction = bindToProps(props, gestureConfig.eventOptions, !!target); | ||
if (gestureConfig.enabled) { | ||
@@ -316,5 +260,5 @@ const Engine = EngineMap.get(gestureKey); | ||
const nativeBindFunction = bindToProps(props, sharedConfig.eventOptions, !!target); | ||
for (const eventKey in this.nativeHandlers) { | ||
nativeBindFunction(eventKey, '', event => this.nativeHandlers[eventKey](_objectSpread2(_objectSpread2({}, this.state.shared), {}, { | ||
nativeBindFunction(eventKey, '', | ||
event => this.nativeHandlers[eventKey](_objectSpread2(_objectSpread2({}, this.state.shared), {}, { | ||
event, | ||
@@ -338,3 +282,2 @@ args | ||
} = parseProp(handlerProp); | ||
this._targetEventStore.add(target, device, '', props[handlerProp], { | ||
@@ -346,5 +289,3 @@ capture, | ||
} | ||
} | ||
function setupGesture(ctrl, gestureKey) { | ||
@@ -355,3 +296,2 @@ ctrl.gestures.add(gestureKey); | ||
} | ||
function resolveGestures(ctrl, internalHandlers) { | ||
@@ -365,6 +305,4 @@ if (internalHandlers.drag) setupGesture(ctrl, 'drag'); | ||
} | ||
const bindToProps = (props, eventOptions, withPassiveOption) => (device, action, handler, options = {}, isNative = false) => { | ||
var _options$capture, _options$passive; | ||
const capture = (_options$capture = options.capture) !== null && _options$capture !== void 0 ? _options$capture : eventOptions.capture; | ||
@@ -379,3 +317,2 @@ const passive = (_options$passive = options.passive) !== null && _options$passive !== void 0 ? _options$passive : eventOptions.passive; | ||
const RE_NOT_NATIVE = /^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/; | ||
function sortHandlers(_handlers) { | ||
@@ -385,3 +322,2 @@ const native = {}; | ||
const actions = new Set(); | ||
for (let key in _handlers) { | ||
@@ -395,9 +331,6 @@ if (RE_NOT_NATIVE.test(key)) { | ||
} | ||
return [handlers, native, actions]; | ||
} | ||
function registerGesture(actions, handlers, handlerKey, key, internalHandlers, config) { | ||
if (!actions.has(handlerKey)) return; | ||
if (!EngineMap.has(key)) { | ||
@@ -407,9 +340,6 @@ if (process.env.NODE_ENV === 'development') { | ||
} | ||
return; | ||
} | ||
const startKey = handlerKey + 'Start'; | ||
const endKey = handlerKey + 'End'; | ||
const fn = state => { | ||
@@ -422,7 +352,5 @@ let memo = undefined; | ||
}; | ||
internalHandlers[key] = fn; | ||
config[key] = config[key] || {}; | ||
} | ||
function parseMergedHandlers(mergedHandlers, mergedConfig) { | ||
@@ -429,0 +357,0 @@ const [handlers, nativeHandlers, actions] = sortHandlers(mergedHandlers); |
{ | ||
"name": "@use-gesture/core", | ||
"version": "10.2.20", | ||
"version": "10.2.21", | ||
"description": "Core engine for receiving gestures", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -50,3 +50,6 @@ import { ModifierKey } from '../types' | ||
return value | ||
}, | ||
pinchOnWheel(value = true) { | ||
return value | ||
} | ||
} |
@@ -5,2 +5,3 @@ import { Engine } from './Engine' | ||
import { Vector2, WebKitGestureEvent } from '../types' | ||
import { clampStateInternalMovementToBounds } from '../utils/state' | ||
@@ -269,2 +270,5 @@ const SCALE_ANGLE_RATIO_INTENT_DEG = 30 | ||
// _movement rolls back to when it passed the bounds. | ||
clampStateInternalMovementToBounds(state) | ||
this.state.origin = [event.clientX, event.clientY] | ||
@@ -297,4 +301,6 @@ | ||
// ignore it. | ||
bindFunction('wheel', '', this.wheel.bind(this), { passive: false }) | ||
if (this.config.pinchOnWheel) { | ||
bindFunction('wheel', '', this.wheel.bind(this), { passive: false }) | ||
} | ||
} | ||
} |
import { CoordinatesEngine } from './CoordinatesEngine' | ||
import { wheelValues } from '../utils/events' | ||
import { V } from '../utils/maths' | ||
import { clampStateInternalMovementToBounds } from '../utils/state' | ||
@@ -26,14 +27,4 @@ export interface WheelEngine extends CoordinatesEngine<'wheel'> { | ||
// _movement rolls back to when it passed the bounds. | ||
const [ox, oy] = state.overflow | ||
const [dx, dy] = state._delta | ||
const [dirx, diry] = state._direction | ||
clampStateInternalMovementToBounds(state) | ||
if ((ox < 0 && dx > 0 && dirx < 0) || (ox > 0 && dx < 0 && dirx > 0)) { | ||
state._movement[0] = state._movementBound[0] as number | ||
} | ||
if ((oy < 0 && dy > 0 && diry < 0) || (oy > 0 && dy < 0 && diry > 0)) { | ||
state._movement[1] = state._movementBound[1] as number | ||
} | ||
this.compute(event) | ||
@@ -40,0 +31,0 @@ this.emit() |
@@ -124,2 +124,6 @@ import { State } from './state' | ||
modifierKey?: ModifierKey | ||
/** | ||
* Whether wheel should trigger a pinch at all. | ||
*/ | ||
pinchOnWheel?: boolean | ||
} | ||
@@ -126,0 +130,0 @@ |
@@ -58,2 +58,3 @@ import { GestureKey, CoordinatesKey, ModifierKey } from './config' | ||
modifierKey: ModifierKey | ||
pinchOnWheel: boolean | ||
} | ||
@@ -60,0 +61,0 @@ |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var maths = require('../../dist/maths-125ca19a.cjs.dev.js'); | ||
var maths = require('../../dist/maths-0c237923.cjs.dev.js'); | ||
@@ -8,0 +8,0 @@ |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var maths = require('../../dist/maths-a42ecce1.cjs.prod.js'); | ||
var maths = require('../../dist/maths-306fe672.cjs.prod.js'); | ||
@@ -8,0 +8,0 @@ |
@@ -1,1 +0,1 @@ | ||
export { r as rubberbandIfOutOfBounds } from '../../dist/maths-b2a210f4.esm.js'; | ||
export { r as rubberbandIfOutOfBounds } from '../../dist/maths-b28d9b98.esm.js'; |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
343872
108
9742
22