@use-gesture/core
Advanced tools
Comparing version 10.2.10 to 10.2.11
@@ -5,3 +5,3 @@ 'use strict'; | ||
var actions_dist_useGestureCoreActions = require('../../dist/actions-f4308453.cjs.dev.js'); | ||
var actions_dist_useGestureCoreActions = require('../../dist/actions-8f953794.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-3f0bff14.cjs.prod.js'); | ||
var actions_dist_useGestureCoreActions = require('../../dist/actions-0120f176.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-8fb255d4.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-8e12537b.esm.js'; | ||
import '../../dist/maths-b2a210f4.esm.js'; |
# @use-gesture/core | ||
## 10.2.11 | ||
### Patch Changes | ||
- 670e6e2db: - fix: trigger `pointerDown` event when `triggerAllEvents` and `delay` options are set | ||
- fix: disable scroll prevention when the event type is `'mouse'` | ||
- feat: add `axisThreshold` property to set a threshold for axis calculation (can be set per device for the drag gesture) | ||
- fix: axis are now calculated on pixel movement rather than on transformed movement | ||
- 5979b1add: feat: add modifierKey for wheel option. Defaults to `'ctrlKey'`. | ||
## 10.2.10 | ||
@@ -4,0 +14,0 @@ |
import { InternalCoordinatesOptions, CoordinatesConfig, DragBounds, State, Vector2 } from '../types'; | ||
export declare const coordinatesConfigResolver: { | ||
axis(this: InternalCoordinatesOptions, _v: any, _k: string, { axis }: CoordinatesConfig): InternalCoordinatesOptions['axis']; | ||
axisThreshold(value?: number): number; | ||
bounds(value?: DragBounds | ((state: State) => DragBounds)): (() => EventTarget | null) | HTMLElement | [Vector2, Vector2]; | ||
@@ -5,0 +6,0 @@ enabled(value?: boolean): boolean; |
@@ -0,1 +1,2 @@ | ||
import { PointerType } from '../types'; | ||
import { DragConfig, InternalDragOptions, Vector2 } from '../types'; | ||
@@ -8,3 +9,3 @@ export declare const DEFAULT_PREVENT_SCROLL_DELAY = 250; | ||
export declare const dragConfigResolver: { | ||
device(this: InternalDragOptions, _v: any, _k: string, { pointer: { touch, lock, mouse } }: DragConfig): "touch" | "mouse" | "pointer"; | ||
device(this: InternalDragOptions, _v: any, _k: string, { pointer: { touch, lock, mouse } }: DragConfig): "mouse" | "touch" | "pointer"; | ||
preventScrollAxis(this: InternalDragOptions, value: 'x' | 'y' | 'xy', _k: string, { preventScroll }: DragConfig): "x" | "y" | "xy" | undefined; | ||
@@ -32,2 +33,3 @@ pointerCapture(this: InternalDragOptions, _v: any, _k: string, { pointer: { capture, buttons } }: { | ||
delay(value?: number | boolean): number; | ||
axisThreshold(value: Record<PointerType, number>): Record<PointerType, number>; | ||
axis(this: import("../types").InternalCoordinatesOptions<import("../types").CoordinatesKey>, _v: any, _k: string, { axis }: import("../types").CoordinatesConfig<import("../types").CoordinatesKey>): "x" | "y" | undefined; | ||
@@ -34,0 +36,0 @@ bounds(value?: import("../types").DragBounds | ((state: import("../types").State) => import("../types").DragBounds)): HTMLElement | [Vector2, Vector2] | (() => EventTarget | null); |
export declare const hoverConfigResolver: { | ||
mouseOnly: (value?: boolean) => boolean; | ||
axis(this: import("../types").InternalCoordinatesOptions<import("../types").CoordinatesKey>, _v: any, _k: string, { axis }: import("../types").CoordinatesConfig<import("../types").CoordinatesKey>): "x" | "y" | undefined; | ||
axisThreshold(value?: number): number; | ||
bounds(value?: import("../types").DragBounds | ((state: import("../types").State) => import("../types").DragBounds)): HTMLElement | [import("../types").Vector2, import("../types").Vector2] | (() => EventTarget | null); | ||
@@ -5,0 +6,0 @@ enabled(value?: boolean): boolean; |
export declare const moveConfigResolver: { | ||
mouseOnly: (value?: boolean) => boolean; | ||
axis(this: import("../types").InternalCoordinatesOptions<import("../types").CoordinatesKey>, _v: any, _k: string, { axis }: import("../types").CoordinatesConfig<import("../types").CoordinatesKey>): "x" | "y" | undefined; | ||
axisThreshold(value?: number): number; | ||
bounds(value?: import("../types").DragBounds | ((state: import("../types").State) => import("../types").DragBounds)): HTMLElement | [import("../types").Vector2, import("../types").Vector2] | (() => EventTarget | null); | ||
@@ -5,0 +6,0 @@ enabled(value?: boolean): boolean; |
@@ -0,1 +1,2 @@ | ||
import { ModifierKey } from '../types'; | ||
import { PinchConfig, GenericOptions, InternalPinchOptions, State, Vector2 } from '../types'; | ||
@@ -26,5 +27,7 @@ export declare const pinchConfigResolver: { | ||
axis?: "lock" | undefined; | ||
modifierKey?: ModifierKey | undefined; | ||
}): "touch" | "pointer" | "gesture" | undefined; | ||
bounds(_v: any, _k: string, { scaleBounds, angleBounds }: PinchConfig): number[][] | ((state: State) => number[][]); | ||
threshold(this: InternalPinchOptions, value: number | Vector2, _k: string, config: PinchConfig): [number, number]; | ||
modifierKey(value: ModifierKey): ModifierKey; | ||
enabled(value?: boolean): boolean; | ||
@@ -31,0 +34,0 @@ preventDefault(value?: boolean): boolean; |
export declare const scrollConfigResolver: { | ||
axis(this: import("../types").InternalCoordinatesOptions<import("../types").CoordinatesKey>, _v: any, _k: string, { axis }: import("../types").CoordinatesConfig<import("../types").CoordinatesKey>): "x" | "y" | undefined; | ||
axisThreshold(value?: number): number; | ||
bounds(value?: import("../types").DragBounds | ((state: import("../types").State) => import("../types").DragBounds)): HTMLElement | [import("../types").Vector2, import("../types").Vector2] | (() => EventTarget | null); | ||
@@ -4,0 +5,0 @@ enabled(value?: boolean): boolean; |
export declare const wheelConfigResolver: { | ||
axis(this: import("../types").InternalCoordinatesOptions<import("../types").CoordinatesKey>, _v: any, _k: string, { axis }: import("../types").CoordinatesConfig<import("../types").CoordinatesKey>): "x" | "y" | undefined; | ||
axisThreshold(value?: number): number; | ||
bounds(value?: import("../types").DragBounds | ((state: import("../types").State) => import("../types").DragBounds)): HTMLElement | [import("../types").Vector2, import("../types").Vector2] | (() => EventTarget | null); | ||
@@ -4,0 +5,0 @@ enabled(value?: boolean): boolean; |
@@ -9,3 +9,4 @@ import { Engine } from './Engine'; | ||
computeMovement(): void; | ||
intent(v: Vector2): void; | ||
axisIntent(event?: UIEvent): void; | ||
restrictToAxis(v: Vector2): void; | ||
} |
@@ -18,5 +18,6 @@ import { Controller } from '../Controller'; | ||
* `state._active` or `state._blocked` flags if the gesture isn't intentional. | ||
* @param movement | ||
* @param event | ||
*/ | ||
intent?(movement: Vector2): void; | ||
axisIntent?(event?: UIEvent): void; | ||
restrictToAxis?(movement: Vector2): void; | ||
} | ||
@@ -23,0 +24,0 @@ export declare abstract class Engine<Key extends GestureKey> { |
@@ -10,3 +10,4 @@ import { Engine } from './Engine'; | ||
computeMovement(): void; | ||
intent(v: Vector2): void; | ||
axisIntent(): void; | ||
restrictToAxis(v: Vector2): void; | ||
cancel(): void; | ||
@@ -13,0 +14,0 @@ touchStart(event: TouchEvent): void; |
/// <reference types="react" /> | ||
import { State } from './state'; | ||
import { Vector2, Target } from './utils'; | ||
import { Vector2, Target, PointerType } from './utils'; | ||
export declare type GestureKey = Exclude<keyof State, 'shared'>; | ||
@@ -83,2 +83,7 @@ export declare type CoordinatesKey = Exclude<GestureKey, 'pinch'>; | ||
bounds?: Bounds | ((state: State[Key]) => Bounds); | ||
/** | ||
* Determines the number of pixels in one direction needed for axises to be | ||
* calculated. | ||
*/ | ||
axisThreshold?: number; | ||
}; | ||
@@ -89,2 +94,3 @@ export declare type PinchBounds = { | ||
}; | ||
export declare type ModifierKey = 'ctrlKey' | 'altKey' | 'metaKey' | null; | ||
export declare type PinchConfig = GestureOptions<'pinch'> & { | ||
@@ -109,2 +115,6 @@ pointer?: { | ||
axis?: 'lock' | undefined; | ||
/** | ||
* Key that triggers scale when using the wheel. Defaults to `'ctrlKey'`. | ||
*/ | ||
modifierKey?: ModifierKey; | ||
}; | ||
@@ -120,3 +130,3 @@ export declare type DragBounds = Bounds | HTMLElement | React.RefObject<HTMLElement>; | ||
export declare type HoverConfig = MoveAndHoverMouseOnly; | ||
export declare type DragConfig = CoordinatesConfig<'drag'> & { | ||
export declare type DragConfig = Omit<CoordinatesConfig<'drag'>, 'axisThreshold'> & { | ||
/** | ||
@@ -197,2 +207,8 @@ * If true, the component won't trigger your drag logic if the user just clicked on the component. | ||
delay?: boolean | number; | ||
/** | ||
* Key-number record that determines for each device (`'mouse'`, `'touch'`, | ||
* `'pen'`) the number of pixels of drag in one direction needed for axises to | ||
* be calculated. | ||
*/ | ||
axisThreshold?: Partial<Record<PointerType, number>>; | ||
}; | ||
@@ -199,0 +215,0 @@ export declare type UserDragConfig = GenericOptions & DragConfig; |
@@ -1,4 +0,4 @@ | ||
import { GestureKey, CoordinatesKey } from './config'; | ||
import { GestureKey, CoordinatesKey, ModifierKey } from './config'; | ||
import { State } from './state'; | ||
import { Vector2 } from './utils'; | ||
import { PointerType, Vector2 } from './utils'; | ||
export declare type InternalGenericOptions = { | ||
@@ -25,4 +25,5 @@ target?: () => EventTarget; | ||
lockDirection: boolean; | ||
axisThreshold: number; | ||
}; | ||
export declare type InternalDragOptions = InternalCoordinatesOptions<'drag'> & { | ||
export declare type InternalDragOptions = Omit<InternalCoordinatesOptions<'drag'>, 'axisThreshold'> & { | ||
filterTaps: boolean; | ||
@@ -42,2 +43,3 @@ tapsThreshold: number; | ||
delay: number; | ||
axisThreshold: Record<PointerType, number>; | ||
}; | ||
@@ -50,2 +52,3 @@ export declare type InternalPinchOptions = InternalGestureOptions<'pinch'> & { | ||
lockDirection: boolean; | ||
modifierKey: ModifierKey; | ||
}; | ||
@@ -52,0 +55,0 @@ declare type MoveAndHoverMouseOnly = { |
@@ -8,1 +8,2 @@ /// <reference types="react" /> | ||
export declare type Target = EventTarget | React.RefObject<EventTarget>; | ||
export declare type PointerType = 'mouse' | 'touch' | 'pen'; |
@@ -0,1 +1,2 @@ | ||
import { PointerType } from '../types'; | ||
import { Vector2 } from '../types'; | ||
@@ -10,2 +11,3 @@ export declare function toHandlerProp(device: string, action?: string, capture?: boolean): string; | ||
export declare function isTouch(event: UIEvent): boolean; | ||
export declare function getPointerType(event: UIEvent): PointerType; | ||
export declare function distanceAngle(P1: Touch | PointerEvent, P2: Touch | PointerEvent): { | ||
@@ -12,0 +14,0 @@ angle: number; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var actions_dist_useGestureCoreActions = require('./actions-f4308453.cjs.dev.js'); | ||
var actions_dist_useGestureCoreActions = require('./actions-8f953794.cjs.dev.js'); | ||
require('./maths-125ca19a.cjs.dev.js'); | ||
@@ -8,0 +8,0 @@ |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var actions_dist_useGestureCoreActions = require('./actions-3f0bff14.cjs.prod.js'); | ||
var actions_dist_useGestureCoreActions = require('./actions-0120f176.cjs.prod.js'); | ||
require('./maths-a42ecce1.cjs.prod.js'); | ||
@@ -8,0 +8,0 @@ |
@@ -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-8fb255d4.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-8e12537b.esm.js'; | ||
import './maths-b2a210f4.esm.js'; | ||
@@ -3,0 +3,0 @@ |
{ | ||
"name": "@use-gesture/core", | ||
"version": "10.2.10", | ||
"version": "10.2.11", | ||
"description": "Core engine for receiving gestures", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
import { commonConfigResolver } from './commonConfigResolver' | ||
import { InternalCoordinatesOptions, CoordinatesConfig, Bounds, DragBounds, State, Vector2 } from '../types' | ||
const DEFAULT_AXIS_THRESHOLD = 0 | ||
export const coordinatesConfigResolver = { | ||
@@ -15,2 +17,5 @@ ...commonConfigResolver, | ||
}, | ||
axisThreshold(value = DEFAULT_AXIS_THRESHOLD) { | ||
return value | ||
}, | ||
bounds( | ||
@@ -17,0 +22,0 @@ value: DragBounds | ((state: State) => DragBounds) = {} |
@@ -0,1 +1,2 @@ | ||
import { PointerType } from '../types' | ||
import { DragConfig, InternalDragOptions, Vector2 } from '../types' | ||
@@ -12,2 +13,4 @@ import { V } from '../utils/maths' | ||
const DEFAULT_DRAG_AXIS_THRESHOLD: Record<PointerType, number> = { mouse: 0, touch: 0, pen: 8 } | ||
export const dragConfigResolver = { | ||
@@ -73,2 +76,6 @@ ...coordinatesConfigResolver, | ||
} | ||
}, | ||
axisThreshold(value: Record<PointerType, number>) { | ||
if (!value) return DEFAULT_DRAG_AXIS_THRESHOLD | ||
return { ...DEFAULT_DRAG_AXIS_THRESHOLD, ...value } | ||
} | ||
@@ -75,0 +82,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { ModifierKey } from '../types' | ||
import { PinchConfig, GenericOptions, InternalPinchOptions, State, Vector2 } from '../types' | ||
@@ -45,3 +46,7 @@ import { call, assignDefault } from '../utils/fn' | ||
return threshold | ||
}, | ||
modifierKey(value: ModifierKey) { | ||
if (value === undefined) return 'ctrlKey' | ||
return value | ||
} | ||
} |
import { Engine } from './Engine' | ||
import { V } from '../utils/maths' | ||
import { CoordinatesKey, Vector2 } from '../types' | ||
import { getPointerType } from '../utils/events' | ||
function selectAxis([dx, dy]: Vector2) { | ||
const d = Math.abs(dx) - Math.abs(dy) | ||
if (d > 0) return 'x' | ||
if (d < 0) return 'y' | ||
return undefined | ||
} | ||
function selectAxis([dx, dy]: Vector2, threshold: number) { | ||
const absDx = Math.abs(dx) | ||
const absDy = Math.abs(dy) | ||
function restrictVectorToAxis(v: Vector2, axis?: 'x' | 'y') { | ||
switch (axis) { | ||
case 'x': | ||
v[1] = 0 | ||
break // [ x, 0 ] | ||
case 'y': | ||
v[0] = 0 | ||
break // [ 0, y ] | ||
if (absDx > absDy && absDx > threshold) { | ||
return 'x' | ||
} | ||
if (absDy > absDx && absDy > threshold) { | ||
return 'y' | ||
} | ||
return undefined | ||
} | ||
@@ -44,18 +40,32 @@ | ||
intent(v: Vector2) { | ||
this.state.axis = this.state.axis || selectAxis(v) | ||
axisIntent(event?: UIEvent) { | ||
const state = this.state | ||
const config = this.config | ||
if (!state.axis && event) { | ||
const threshold = | ||
typeof config.axisThreshold === 'object' ? config.axisThreshold[getPointerType(event)] : config.axisThreshold | ||
state.axis = selectAxis(state._movement, threshold) | ||
} | ||
// We block the movement if either: | ||
// - config.lockDirection or config.axis was set but axis isn't detected yet | ||
// - config.axis was set but is different than detected axis | ||
this.state._blocked = | ||
((this.config.lockDirection || !!this.config.axis) && !this.state.axis) || | ||
(!!this.config.axis && this.config.axis !== this.state.axis) | ||
state._blocked = | ||
((config.lockDirection || !!config.axis) && !state.axis) || (!!config.axis && config.axis !== state.axis) | ||
} | ||
if (this.state._blocked) return | ||
restrictToAxis(v: Vector2) { | ||
if (this.config.axis || this.config.lockDirection) { | ||
restrictVectorToAxis(v, this.state.axis) | ||
switch (this.state.axis) { | ||
case 'x': | ||
v[1] = 0 | ||
break // [ x, 0 ] | ||
case 'y': | ||
v[0] = 0 | ||
break // [ 0, y ] | ||
} | ||
} | ||
} | ||
} |
import { CoordinatesEngine } from './CoordinatesEngine' | ||
import { coordinatesConfigResolver } from '../config/coordinatesConfigResolver' | ||
import { pointerId, pointerValues } from '../utils/events' | ||
import { pointerId, getPointerType, pointerValues } from '../utils/events' | ||
import { V } from '../utils/maths' | ||
@@ -109,3 +109,3 @@ import { Vector2 } from '../types' | ||
if (config.preventScrollAxis) { | ||
if (config.preventScrollAxis && getPointerType(event) !== 'mouse') { | ||
// when preventScrollAxis is set we don't consider the gesture active | ||
@@ -117,2 +117,7 @@ // until it's deliberate | ||
this.setupDelayTrigger(event) | ||
// makes sure we emit all events when `triggerAllEvents` flag is `true` | ||
if (config.triggerAllEvents) { | ||
this.compute(event) | ||
this.emit() | ||
} | ||
} else { | ||
@@ -119,0 +124,0 @@ this.startPointerDrag(event) |
@@ -38,5 +38,7 @@ import { Controller } from '../Controller' | ||
* `state._active` or `state._blocked` flags if the gesture isn't intentional. | ||
* @param movement | ||
* @param event | ||
*/ | ||
intent?(movement: Vector2): void | ||
axisIntent?(event?: UIEvent): void | ||
restrictToAxis?(movement: Vector2): void | ||
} | ||
@@ -255,2 +257,5 @@ | ||
// let's run intentionality check. | ||
if (this.axisIntent) this.axisIntent(event) | ||
// _movement is calculated by each gesture engine | ||
@@ -289,4 +294,4 @@ const [_m0, _m1] = state._movement | ||
// let's run intentionality check. | ||
if (this.intent) this.intent(movement) | ||
if (this.restrictToAxis && !state._blocked) this.restrictToAxis(movement) | ||
const previousOffset = state.offset | ||
@@ -293,0 +298,0 @@ |
@@ -43,13 +43,16 @@ import { Engine } from './Engine' | ||
intent(v: Vector2) { | ||
axisIntent() { | ||
const state = this.state | ||
const [_m0, _m1] = state._movement | ||
if (!state.axis) { | ||
const axisMovementDifference = Math.abs(v[0]) * SCALE_ANGLE_RATIO_INTENT_DEG - Math.abs(v[1]) | ||
const axisMovementDifference = Math.abs(_m0) * SCALE_ANGLE_RATIO_INTENT_DEG - Math.abs(_m1) | ||
if (axisMovementDifference < 0) state.axis = 'angle' | ||
else if (axisMovementDifference > 0) state.axis = 'scale' | ||
} | ||
} | ||
restrictToAxis(v: Vector2) { | ||
if (this.config.lockDirection) { | ||
if (state.axis === 'scale') v[1] = 0 | ||
else if (state.axis === 'angle') v[0] = 0 | ||
if (this.state.axis === 'scale') v[1] = 0 | ||
else if (this.state.axis === 'angle') v[0] = 0 | ||
} | ||
@@ -237,3 +240,4 @@ } | ||
wheel(event: WheelEvent) { | ||
if (!event.ctrlKey) return | ||
const modifierKey = this.config.modifierKey | ||
if (modifierKey && !event[modifierKey]) return | ||
if (!this.state._active) this.wheelStart(event) | ||
@@ -240,0 +244,0 @@ else this.wheelChange(event) |
import { State } from './state' | ||
import { Vector2, Target } from './utils' | ||
import { Vector2, Target, PointerType } from './utils' | ||
@@ -87,5 +87,11 @@ export type GestureKey = Exclude<keyof State, 'shared'> | ||
bounds?: Bounds | ((state: State[Key]) => Bounds) | ||
/** | ||
* Determines the number of pixels in one direction needed for axises to be | ||
* calculated. | ||
*/ | ||
axisThreshold?: number | ||
} | ||
export type PinchBounds = { min?: number; max?: number } | ||
export type ModifierKey = 'ctrlKey' | 'altKey' | 'metaKey' | null | ||
@@ -111,2 +117,6 @@ export type PinchConfig = GestureOptions<'pinch'> & { | ||
axis?: 'lock' | undefined | ||
/** | ||
* Key that triggers scale when using the wheel. Defaults to `'ctrlKey'`. | ||
*/ | ||
modifierKey?: ModifierKey | ||
} | ||
@@ -127,3 +137,3 @@ | ||
export type DragConfig = CoordinatesConfig<'drag'> & { | ||
export type DragConfig = Omit<CoordinatesConfig<'drag'>, 'axisThreshold'> & { | ||
/** | ||
@@ -204,2 +214,8 @@ * If true, the component won't trigger your drag logic if the user just clicked on the component. | ||
delay?: boolean | number | ||
/** | ||
* Key-number record that determines for each device (`'mouse'`, `'touch'`, | ||
* `'pen'`) the number of pixels of drag in one direction needed for axises to | ||
* be calculated. | ||
*/ | ||
axisThreshold?: Partial<Record<PointerType, number>> | ||
} | ||
@@ -206,0 +222,0 @@ |
@@ -1,4 +0,4 @@ | ||
import { GestureKey, CoordinatesKey } from './config' | ||
import { GestureKey, CoordinatesKey, ModifierKey } from './config' | ||
import { State } from './state' | ||
import { Vector2 } from './utils' | ||
import { PointerType, Vector2 } from './utils' | ||
@@ -28,5 +28,6 @@ export type InternalGenericOptions = { | ||
lockDirection: boolean | ||
axisThreshold: number | ||
} | ||
export type InternalDragOptions = InternalCoordinatesOptions<'drag'> & { | ||
export type InternalDragOptions = Omit<InternalCoordinatesOptions<'drag'>, 'axisThreshold'> & { | ||
filterTaps: boolean | ||
@@ -46,2 +47,3 @@ tapsThreshold: number | ||
delay: number | ||
axisThreshold: Record<PointerType, number> | ||
} | ||
@@ -55,2 +57,3 @@ | ||
lockDirection: boolean | ||
modifierKey: ModifierKey | ||
} | ||
@@ -57,0 +60,0 @@ |
export type Vector2 = [number, number] | ||
export type WebKitGestureEvent = PointerEvent & { scale: number; rotation: number } | ||
export type Target = EventTarget | React.RefObject<EventTarget> | ||
export type PointerType = 'mouse' | 'touch' | 'pen' |
@@ -0,1 +1,2 @@ | ||
import { PointerType } from '../types' | ||
import { Vector2 } from '../types' | ||
@@ -46,2 +47,8 @@ | ||
export function getPointerType(event: UIEvent): PointerType { | ||
if (isTouch(event)) return 'touch' | ||
if ('pointerType' in event) return (event as PointerEvent).pointerType as PointerType | ||
return 'mouse' | ||
} | ||
function getCurrentTargetTouchList(event: TouchEvent) { | ||
@@ -48,0 +55,0 @@ return Array.from(event.touches).filter( |
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
318553
9133
25