@use-gesture/core
Advanced tools
Comparing version 10.2.12 to 10.2.13
@@ -5,3 +5,3 @@ 'use strict'; | ||
var actions_dist_useGestureCoreActions = require('../../dist/actions-8f953794.cjs.dev.js'); | ||
var actions_dist_useGestureCoreActions = require('../../dist/actions-5a43ec1e.cjs.dev.js'); | ||
require('../../dist/maths-125ca19a.cjs.dev.js'); | ||
@@ -8,0 +8,0 @@ |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var actions_dist_useGestureCoreActions = require('../../dist/actions-0120f176.cjs.prod.js'); | ||
var actions_dist_useGestureCoreActions = require('../../dist/actions-874431a8.cjs.prod.js'); | ||
require('../../dist/maths-a42ecce1.cjs.prod.js'); | ||
@@ -8,0 +8,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-8e12537b.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-55c076a0.esm.js'; | ||
import '../../dist/maths-b2a210f4.esm.js'; |
# @use-gesture/core | ||
## 10.2.13 | ||
### Patch Changes | ||
- 6896094b3: fix: preventScroll should resist to multiple fingers drag | ||
- 15724eb5c: - Have `delta` increment on first keydown for drag | ||
- Fix `config.bounds` type for drag gestures | ||
- Add `eventOptions` option for each gesture | ||
## 10.2.12 | ||
@@ -4,0 +13,0 @@ |
@@ -7,2 +7,10 @@ import { InternalGestureOptions } from '../types'; | ||
enabled(value?: boolean): boolean; | ||
eventOptions(value: AddEventListenerOptions | undefined, _k: string, config: { | ||
shared: GenericOptions; | ||
}): { | ||
once?: boolean | undefined; | ||
passive?: boolean | undefined; | ||
signal?: AbortSignal | undefined; | ||
capture?: boolean | undefined; | ||
}; | ||
preventDefault(value?: boolean): boolean; | ||
@@ -9,0 +17,0 @@ triggerAllEvents(value?: boolean): boolean; |
@@ -7,2 +7,10 @@ import { InternalCoordinatesOptions, CoordinatesConfig, DragBounds, State, Vector2 } from '../types'; | ||
enabled(value?: boolean): boolean; | ||
eventOptions(value: AddEventListenerOptions | undefined, _k: string, config: { | ||
shared: import("../types").GenericOptions; | ||
}): { | ||
once?: boolean | undefined; | ||
passive?: boolean | undefined; | ||
signal?: AbortSignal | undefined; | ||
capture?: boolean | undefined; | ||
}; | ||
preventDefault(value?: boolean): boolean; | ||
@@ -9,0 +17,0 @@ triggerAllEvents(value?: boolean): boolean; |
@@ -36,2 +36,10 @@ import { PointerType } from '../types'; | ||
enabled(value?: boolean): boolean; | ||
eventOptions(value: AddEventListenerOptions | undefined, _k: string, config: { | ||
shared: import("../types").GenericOptions; | ||
}): { | ||
once?: boolean | undefined; | ||
passive?: boolean | undefined; | ||
signal?: AbortSignal | undefined; | ||
capture?: boolean | undefined; | ||
}; | ||
preventDefault(value?: boolean): boolean; | ||
@@ -38,0 +46,0 @@ triggerAllEvents(value?: boolean): boolean; |
@@ -7,2 +7,10 @@ export declare const hoverConfigResolver: { | ||
enabled(value?: boolean): boolean; | ||
eventOptions(value: AddEventListenerOptions | undefined, _k: string, config: { | ||
shared: import("../types").GenericOptions; | ||
}): { | ||
once?: boolean | undefined; | ||
passive?: boolean | undefined; | ||
signal?: AbortSignal | undefined; | ||
capture?: boolean | undefined; | ||
}; | ||
preventDefault(value?: boolean): boolean; | ||
@@ -9,0 +17,0 @@ triggerAllEvents(value?: boolean): boolean; |
@@ -7,2 +7,10 @@ export declare const moveConfigResolver: { | ||
enabled(value?: boolean): boolean; | ||
eventOptions(value: AddEventListenerOptions | undefined, _k: string, config: { | ||
shared: import("../types").GenericOptions; | ||
}): { | ||
once?: boolean | undefined; | ||
passive?: boolean | undefined; | ||
signal?: AbortSignal | undefined; | ||
capture?: boolean | undefined; | ||
}; | ||
preventDefault(value?: boolean): boolean; | ||
@@ -9,0 +17,0 @@ triggerAllEvents(value?: boolean): boolean; |
@@ -8,2 +8,3 @@ import { ModifierKey } from '../types'; | ||
enabled?: boolean | undefined; | ||
eventOptions?: AddEventListenerOptions | undefined; | ||
from?: Vector2 | ((state: import("../types").PinchState & { | ||
@@ -34,2 +35,10 @@ event: PointerEvent | TouchEvent | WheelEvent | import("../types").WebKitGestureEvent; | ||
enabled(value?: boolean): boolean; | ||
eventOptions(value: AddEventListenerOptions | undefined, _k: string, config: { | ||
shared: GenericOptions; | ||
}): { | ||
once?: boolean | undefined; | ||
passive?: boolean | undefined; | ||
signal?: AbortSignal | undefined; | ||
capture?: boolean | undefined; | ||
}; | ||
preventDefault(value?: boolean): boolean; | ||
@@ -36,0 +45,0 @@ triggerAllEvents(value?: boolean): boolean; |
@@ -6,2 +6,10 @@ export declare const scrollConfigResolver: { | ||
enabled(value?: boolean): boolean; | ||
eventOptions(value: AddEventListenerOptions | undefined, _k: string, config: { | ||
shared: import("../types").GenericOptions; | ||
}): { | ||
once?: boolean | undefined; | ||
passive?: boolean | undefined; | ||
signal?: AbortSignal | undefined; | ||
capture?: boolean | undefined; | ||
}; | ||
preventDefault(value?: boolean): boolean; | ||
@@ -8,0 +16,0 @@ triggerAllEvents(value?: boolean): boolean; |
@@ -6,2 +6,10 @@ export declare const wheelConfigResolver: { | ||
enabled(value?: boolean): boolean; | ||
eventOptions(value: AddEventListenerOptions | undefined, _k: string, config: { | ||
shared: import("../types").GenericOptions; | ||
}): { | ||
once?: boolean | undefined; | ||
passive?: boolean | undefined; | ||
signal?: AbortSignal | undefined; | ||
capture?: boolean | undefined; | ||
}; | ||
preventDefault(value?: boolean): boolean; | ||
@@ -8,0 +16,0 @@ triggerAllEvents(value?: boolean): boolean; |
@@ -37,2 +37,6 @@ /// <reference types="react" /> | ||
/** | ||
* Lets you customize if you want events to be passive or captured. | ||
*/ | ||
eventOptions?: AddEventListenerOptions; | ||
/** | ||
* The position `offset` will start from. | ||
@@ -128,3 +132,3 @@ */ | ||
export declare type HoverConfig = MoveAndHoverMouseOnly; | ||
export declare type DragConfig = Omit<CoordinatesConfig<'drag'>, 'axisThreshold'> & { | ||
export declare type DragConfig = Omit<CoordinatesConfig<'drag'>, 'axisThreshold' | 'bounds'> & { | ||
/** | ||
@@ -131,0 +135,0 @@ * If true, the component won't trigger your drag logic if the user just clicked on the component. |
@@ -13,2 +13,3 @@ import { GestureKey, CoordinatesKey, ModifierKey } from './config'; | ||
enabled: boolean; | ||
eventOptions: AddEventListenerOptions; | ||
from: Vector2 | ((state: State[Key]) => Vector2); | ||
@@ -15,0 +16,0 @@ threshold: Vector2; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var actions_dist_useGestureCoreActions = require('./actions-8f953794.cjs.dev.js'); | ||
var actions_dist_useGestureCoreActions = require('./actions-5a43ec1e.cjs.dev.js'); | ||
require('./maths-125ca19a.cjs.dev.js'); | ||
@@ -167,3 +167,5 @@ | ||
this._listeners.push(() => element.removeEventListener(type, handler, eventOptions)); | ||
this._listeners.push(() => { | ||
element.removeEventListener(type, handler, eventOptions); | ||
}); | ||
} | ||
@@ -267,3 +269,2 @@ | ||
const sharedConfig = this.config.shared; | ||
const eventOptions = sharedConfig.eventOptions; | ||
const props = {}; | ||
@@ -277,7 +278,8 @@ let target; | ||
const bindFunction = bindToProps(props, eventOptions, !!target); | ||
if (sharedConfig.enabled) { | ||
for (const gestureKey of this.gestures) { | ||
if (this.config[gestureKey].enabled) { | ||
const gestureConfig = this.config[gestureKey]; | ||
const bindFunction = bindToProps(props, gestureConfig.eventOptions, !!target); | ||
if (gestureConfig.enabled) { | ||
const Engine = actions_dist_useGestureCoreActions.EngineMap.get(gestureKey); | ||
@@ -288,4 +290,6 @@ new Engine(this, args, gestureKey).bind(bindFunction); | ||
const nativeBindFunction = bindToProps(props, sharedConfig.eventOptions, !!target); | ||
for (const eventKey in this.nativeHandlers) { | ||
bindFunction(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, | ||
@@ -292,0 +296,0 @@ args |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var actions_dist_useGestureCoreActions = require('./actions-0120f176.cjs.prod.js'); | ||
var actions_dist_useGestureCoreActions = require('./actions-874431a8.cjs.prod.js'); | ||
require('./maths-a42ecce1.cjs.prod.js'); | ||
@@ -156,3 +156,5 @@ | ||
this._listeners.push(() => element.removeEventListener(type, handler, eventOptions)); | ||
this._listeners.push(() => { | ||
element.removeEventListener(type, handler, eventOptions); | ||
}); | ||
} | ||
@@ -256,3 +258,2 @@ | ||
const sharedConfig = this.config.shared; | ||
const eventOptions = sharedConfig.eventOptions; | ||
const props = {}; | ||
@@ -266,7 +267,8 @@ let target; | ||
const bindFunction = bindToProps(props, eventOptions, !!target); | ||
if (sharedConfig.enabled) { | ||
for (const gestureKey of this.gestures) { | ||
if (this.config[gestureKey].enabled) { | ||
const gestureConfig = this.config[gestureKey]; | ||
const bindFunction = bindToProps(props, gestureConfig.eventOptions, !!target); | ||
if (gestureConfig.enabled) { | ||
const Engine = actions_dist_useGestureCoreActions.EngineMap.get(gestureKey); | ||
@@ -277,4 +279,6 @@ new Engine(this, args, gestureKey).bind(bindFunction); | ||
const nativeBindFunction = bindToProps(props, sharedConfig.eventOptions, !!target); | ||
for (const eventKey in this.nativeHandlers) { | ||
bindFunction(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, | ||
@@ -281,0 +285,0 @@ args |
@@ -1,2 +0,2 @@ | ||
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-8e12537b.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-55c076a0.esm.js'; | ||
import './maths-b2a210f4.esm.js'; | ||
@@ -162,3 +162,5 @@ | ||
this._listeners.push(() => element.removeEventListener(type, handler, eventOptions)); | ||
this._listeners.push(() => { | ||
element.removeEventListener(type, handler, eventOptions); | ||
}); | ||
} | ||
@@ -262,3 +264,2 @@ | ||
const sharedConfig = this.config.shared; | ||
const eventOptions = sharedConfig.eventOptions; | ||
const props = {}; | ||
@@ -272,7 +273,8 @@ let target; | ||
const bindFunction = bindToProps(props, eventOptions, !!target); | ||
if (sharedConfig.enabled) { | ||
for (const gestureKey of this.gestures) { | ||
if (this.config[gestureKey].enabled) { | ||
const gestureConfig = this.config[gestureKey]; | ||
const bindFunction = bindToProps(props, gestureConfig.eventOptions, !!target); | ||
if (gestureConfig.enabled) { | ||
const Engine = EngineMap.get(gestureKey); | ||
@@ -283,4 +285,6 @@ new Engine(this, args, gestureKey).bind(bindFunction); | ||
const nativeBindFunction = bindToProps(props, sharedConfig.eventOptions, !!target); | ||
for (const eventKey in this.nativeHandlers) { | ||
bindFunction(eventKey, '', event => this.nativeHandlers[eventKey](_objectSpread2(_objectSpread2({}, this.state.shared), {}, { | ||
nativeBindFunction(eventKey, '', event => this.nativeHandlers[eventKey](_objectSpread2(_objectSpread2({}, this.state.shared), {}, { | ||
event, | ||
@@ -287,0 +291,0 @@ args |
{ | ||
"name": "@use-gesture/core", | ||
"version": "10.2.12", | ||
"version": "10.2.13", | ||
"description": "Core engine for receiving gestures", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -12,2 +12,5 @@ import { InternalGestureOptions } from '../types' | ||
}, | ||
eventOptions(value: AddEventListenerOptions | undefined, _k: string, config: { shared: GenericOptions }) { | ||
return { ...config.shared.eventOptions, ...value } | ||
}, | ||
preventDefault(value = false) { | ||
@@ -14,0 +17,0 @@ return value |
@@ -95,3 +95,2 @@ import { EngineMap } from './actions' | ||
const sharedConfig = this.config.shared | ||
const eventOptions = sharedConfig.eventOptions | ||
const props: any = {} | ||
@@ -106,8 +105,8 @@ | ||
const bindFunction = bindToProps(props, eventOptions, !!target) | ||
if (sharedConfig.enabled) { | ||
// Adding gesture handlers | ||
for (const gestureKey of this.gestures) { | ||
if (this.config[gestureKey]!.enabled) { | ||
const gestureConfig = this.config[gestureKey]! | ||
const bindFunction = bindToProps(props, gestureConfig.eventOptions, !!target) | ||
if (gestureConfig.enabled) { | ||
const Engine = EngineMap.get(gestureKey)! | ||
@@ -120,4 +119,5 @@ // @ts-ignore | ||
// Adding native handlers | ||
const nativeBindFunction = bindToProps(props, sharedConfig.eventOptions, !!target) | ||
for (const eventKey in this.nativeHandlers) { | ||
bindFunction( | ||
nativeBindFunction( | ||
eventKey, | ||
@@ -124,0 +124,0 @@ '', |
@@ -296,4 +296,2 @@ import { CoordinatesEngine } from './CoordinatesEngine' | ||
this.eventStore.add(this.sharedConfig.window!, 'touch', 'change', this.preventScroll.bind(this), { passive: false }) | ||
this.eventStore.add(this.sharedConfig.window!, 'touch', 'end', this.clean.bind(this)) | ||
this.eventStore.add(this.sharedConfig.window!, 'touch', 'cancel', this.clean.bind(this)) | ||
this.timeoutStore.add('startPointerDrag', this.startPointerDrag.bind(this), this.config.preventScrollDelay!, event) | ||
@@ -321,7 +319,7 @@ } | ||
const factor = event.shiftKey ? 10 : event.altKey ? 0.1 : 1 | ||
state._delta = deltaFn(factor) | ||
this.start(event) | ||
state._delta = deltaFn(factor) | ||
state._keyboardActive = true | ||
V.addTo(state._movement, state._delta) | ||
@@ -328,0 +326,0 @@ |
@@ -21,3 +21,5 @@ import type { Controller } from './Controller' | ||
element.addEventListener(type, handler, eventOptions) | ||
this._listeners.push(() => element.removeEventListener(type, handler, eventOptions)) | ||
this._listeners.push(() => { | ||
element.removeEventListener(type, handler, eventOptions) | ||
}) | ||
} | ||
@@ -24,0 +26,0 @@ |
@@ -39,2 +39,6 @@ import { State } from './state' | ||
/** | ||
* Lets you customize if you want events to be passive or captured. | ||
*/ | ||
eventOptions?: AddEventListenerOptions | ||
/** | ||
* The position `offset` will start from. | ||
@@ -136,3 +140,3 @@ */ | ||
export type DragConfig = Omit<CoordinatesConfig<'drag'>, 'axisThreshold'> & { | ||
export type DragConfig = Omit<CoordinatesConfig<'drag'>, 'axisThreshold' | 'bounds'> & { | ||
/** | ||
@@ -139,0 +143,0 @@ * If true, the component won't trigger your drag logic if the user just clicked on the component. |
@@ -15,2 +15,3 @@ import { GestureKey, CoordinatesKey, ModifierKey } from './config' | ||
enabled: boolean | ||
eventOptions: AddEventListenerOptions | ||
from: Vector2 | ((state: State[Key]) => Vector2) | ||
@@ -17,0 +18,0 @@ threshold: Vector2 |
@@ -16,6 +16,12 @@ import { PointerType } from '../types' | ||
const actionsWithoutCaptureSupported = ['enter', 'leave'] | ||
function hasCapture(capture = false, actionKey: string) { | ||
return capture && !actionsWithoutCaptureSupported.includes(actionKey) | ||
} | ||
export function toHandlerProp(device: string, action = '', capture: boolean = false) { | ||
const deviceProps = EVENT_TYPE_MAP[device] | ||
const actionKey = deviceProps ? deviceProps[action] || action : action | ||
return 'on' + capitalize(device) + capitalize(actionKey) + (capture ? 'Capture' : '') | ||
return 'on' + capitalize(device) + capitalize(actionKey) + (hasCapture(capture, actionKey) ? 'Capture' : '') | ||
} | ||
@@ -22,0 +28,0 @@ |
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
322853
9240