react-use-gesture
Advanced tools
Comparing version 8.0.1 to 9.1.3
@@ -0,1 +1,2 @@ | ||
/// <reference types="react" /> | ||
import { StateKey, State, Fn, ReactEventHandlers, InternalConfig, InternalHandlers, RecognizerClass } from './types'; | ||
@@ -19,2 +20,6 @@ /** | ||
}; | ||
pointerIds: Set<number>; | ||
touchIds: Set<number>; | ||
supportsTouchEvents: boolean; | ||
supportsGestureEvents: boolean; | ||
constructor(classes: Set<RecognizerClass>); | ||
@@ -28,5 +33,13 @@ bind: (...args: any[]) => void | ReactEventHandlers; | ||
} | ||
export declare function addEventIds(controller: Controller, event: React.TouchEvent | TouchEvent | React.PointerEvent | PointerEvent): void; | ||
export declare function removeEventIds(controller: Controller, event: React.TouchEvent | TouchEvent | React.PointerEvent | PointerEvent): void; | ||
export declare function clearAllWindowListeners(controller: Controller): void; | ||
export declare function clearWindowListeners({ config, windowListeners }: Controller, stateKey: StateKey): void; | ||
export declare function updateWindowListeners({ config, windowListeners }: Controller, stateKey: StateKey, listeners?: [string, Fn][]): void; | ||
export declare function clearWindowListeners({ config, windowListeners }: Controller, stateKey: StateKey, options?: { | ||
capture?: boolean | undefined; | ||
passive?: boolean | undefined; | ||
}): void; | ||
export declare function updateWindowListeners({ config, windowListeners }: Controller, stateKey: StateKey, listeners?: [string, Fn][], options?: { | ||
capture?: boolean | undefined; | ||
passive?: boolean | undefined; | ||
}): void; | ||
/** | ||
@@ -33,0 +46,0 @@ * bindings is an object which keys match ReactEventHandlerKeys. |
@@ -5,5 +5,5 @@ | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./react-use-gesture.cjs.production.min.js') | ||
module.exports = require('./reactusegesture.cjs.production.min.js') | ||
} else { | ||
module.exports = require('./react-use-gesture.cjs.development.js') | ||
module.exports = require('./reactusegesture.cjs.development.js') | ||
} |
@@ -10,3 +10,3 @@ /// <reference types="react" /> | ||
/** | ||
* Returns the real movement (without taking intentionality into acount) | ||
* Returns the real movement (without taking intentionality into account) | ||
*/ | ||
@@ -13,0 +13,0 @@ protected getInternalMovement(values: Vector2, state: GestureState<T>): Vector2; |
@@ -8,18 +8,13 @@ /// <reference types="react" /> | ||
readonly stateKey = "drag"; | ||
/** | ||
* TODO add back when setPointerCapture is widely wupported | ||
* https://caniuse.com/#search=setPointerCapture | ||
* private setPointers = (event: UseGestureEvent<PointerEvent>) => { | ||
* const { currentTarget, pointerId } = event | ||
* if (currentTarget) currentTarget.setPointerCapture(pointerId) | ||
* this.updateGestureState({ currentTarget, pointerId }) | ||
* } | ||
* private removePointers = () => { | ||
* const { currentTarget, pointerId } = this.state | ||
* if (currentTarget && pointerId) currentTarget.releasePointerCapture(pointerId) | ||
* } | ||
*/ | ||
private setPointerCapture; | ||
private releasePointerCapture; | ||
private preventScroll; | ||
private getEventId; | ||
private isValidEvent; | ||
private shouldPreventWindowScrollY; | ||
private setUpWindowScrollDetection; | ||
private setUpDelayedDragTrigger; | ||
private setStartState; | ||
onDragStart: (event: React.PointerEvent | PointerEvent) => void; | ||
startDrag(event: React.PointerEvent | PointerEvent): void; | ||
startDrag(event: React.PointerEvent | PointerEvent, onDragIsStart?: boolean): void; | ||
onDragChange: (event: PointerEvent) => void; | ||
@@ -26,0 +21,0 @@ onDragEnd: (event: PointerEvent) => void; |
@@ -10,2 +10,3 @@ import CoordinatesRecognizer from './CoordinatesRecognizer'; | ||
onMoveEnd: () => void; | ||
hoverTransform: () => ((v: import("../types").Vector2) => import("../types").Vector2) | undefined; | ||
onPointerEnter: (event: React.PointerEvent | PointerEvent) => void; | ||
@@ -12,0 +13,0 @@ onPointerLeave: (event: React.PointerEvent | PointerEvent) => void; |
@@ -6,3 +6,2 @@ import DistanceAngleRecognizer from './DistanceAngleRecognizer'; | ||
readonly stateKey = "pinch"; | ||
private pinchShouldStart; | ||
onPinchStart: (event: React.TouchEvent | TouchEvent) => void; | ||
@@ -9,0 +8,0 @@ onPinchChange: (event: React.TouchEvent | TouchEvent) => void; |
@@ -26,2 +26,3 @@ /// <reference types="react" /> | ||
get handler(): NonNullable<import("../types").InternalHandlers[T]>; | ||
get transform(): (xy: Vector2) => Vector2; | ||
protected updateSharedState(sharedState: Partial<SharedGestureState> | null): void; | ||
@@ -55,3 +56,3 @@ protected updateGestureState(gestureState: PartialGestureState<T> | null): void; | ||
*/ | ||
export declare function getGenericPayload<T extends StateKey>({ state, args }: Recognizer<T>, event: EventTypes[T], isStartEvent?: boolean): { | ||
export declare function getGenericPayload<T extends StateKey>({ state }: Recognizer<T>, event: EventTypes[T], isStartEvent?: boolean): { | ||
_lastEventType: string; | ||
@@ -61,3 +62,2 @@ event: EventTypes[T]; | ||
elapsedTime: number; | ||
args: any[]; | ||
previous: Vector2; | ||
@@ -69,6 +69,10 @@ }; | ||
*/ | ||
export declare function getStartGestureState<T extends StateKey>(recognizer: Recognizer<T>, values: Vector2, event: EventTypes[T]): GestureState<T> & { | ||
export declare function getStartGestureState<T extends StateKey>({ state, config, stateKey, args, transform }: Recognizer<T>, values: Vector2, event: EventTypes[T], initial?: Vector2): GestureState<T> & { | ||
_initial: Vector2; | ||
_bounds: [Vector2, Vector2]; | ||
_active: boolean; | ||
args: any[]; | ||
values: Vector2; | ||
initial: Vector2; | ||
_threshold: number[]; | ||
offset: Vector2; | ||
@@ -75,0 +79,0 @@ lastOffset: Vector2; |
@@ -19,2 +19,3 @@ import type React from 'react'; | ||
enabled?: boolean; | ||
transform?: (v: Vector2) => Vector2; | ||
} | ||
@@ -27,2 +28,3 @@ export interface GestureOptions<T extends StateKey> { | ||
rubberband?: boolean | number | Vector2; | ||
transform?: (v: Vector2) => Vector2; | ||
} | ||
@@ -50,4 +52,7 @@ export declare type Bounds = { | ||
filterTaps?: boolean; | ||
useTouch?: boolean; | ||
swipeVelocity?: number | Vector2; | ||
swipeDistance?: number | Vector2; | ||
swipeDuration?: number; | ||
experimental_preventWindowScrollY?: boolean; | ||
delay?: boolean | number; | ||
@@ -79,2 +84,3 @@ }; | ||
enabled: boolean; | ||
transform?: (v: Vector2) => Vector2; | ||
} | ||
@@ -88,2 +94,3 @@ export interface InternalGestureOptions<T extends StateKey> { | ||
bounds: [Vector2, Vector2] | ((state: State[T]) => [Vector2, Vector2]); | ||
transform?: (v: Vector2) => Vector2; | ||
} | ||
@@ -98,4 +105,7 @@ export interface InternalCoordinatesOptions<T extends CoordinatesKey> extends InternalGestureOptions<T> { | ||
filterTaps: boolean; | ||
useTouch: boolean; | ||
experimental_preventWindowScrollY: boolean; | ||
swipeVelocity: Vector2; | ||
swipeDistance: Vector2; | ||
swipeDuration: number; | ||
delay: number; | ||
@@ -111,2 +121,3 @@ } | ||
enabled: boolean; | ||
transform?: (v: Vector2) => Vector2; | ||
}; | ||
@@ -186,2 +197,3 @@ }; | ||
ctrlKey: boolean; | ||
locked: boolean; | ||
}; | ||
@@ -203,4 +215,10 @@ export declare type EventTypes = { | ||
_bounds: [Vector2, Vector2]; | ||
_threshold: Vector2; | ||
_lastEventType?: string; | ||
_pointerIds?: number[]; | ||
_dragTarget?: EventTarget | (EventTarget & Element) | null; | ||
_dragPointerId?: number | null; | ||
_dragStarted: boolean; | ||
_dragPreventScroll: boolean; | ||
_dragIsTap: boolean; | ||
_dragDelayed: boolean; | ||
event?: React.UIEvent | UIEvent; | ||
@@ -236,4 +254,2 @@ intentional: boolean; | ||
export interface DragState { | ||
_isTap: boolean; | ||
_delayedEvent: boolean; | ||
_pointerId?: number; | ||
@@ -243,2 +259,5 @@ tap: boolean; | ||
} | ||
export interface PinchState { | ||
_pointerIds: [number, number]; | ||
} | ||
export interface DistanceAngle { | ||
@@ -256,3 +275,3 @@ da: Vector2; | ||
move: CommonGestureState & Coordinates; | ||
pinch: CommonGestureState & DistanceAngle; | ||
pinch: CommonGestureState & DistanceAngle & PinchState; | ||
}; | ||
@@ -259,0 +278,0 @@ export declare type GestureState<T extends StateKey> = State[T]; |
@@ -5,3 +5,4 @@ import { GenericOptions, InternalGenericOptions, DragConfig, GestureOptions, InternalDragOptions, InternalGestureOptions, CoordinatesConfig, InternalCoordinatesOptions, DistanceAngleConfig, InternalDistanceAngleOptions, StateKey, CoordinatesKey, DistanceAngleKey } from '../types'; | ||
export declare const DEFAULT_SWIPE_VELOCITY = 0.5; | ||
export declare const DEFAULT_SWIPE_DISTANCE = 60; | ||
export declare const DEFAULT_SWIPE_DISTANCE = 50; | ||
export declare const DEFAULT_SWIPE_DURATION = 250; | ||
export declare function getInternalGenericOptions(config?: GenericOptions): InternalGenericOptions; | ||
@@ -8,0 +9,0 @@ export declare function getInternalGestureOptions<T extends StateKey>(config?: GestureOptions<T>): InternalGestureOptions<T>; |
@@ -9,5 +9,5 @@ /// <reference types="react" /> | ||
export declare function supportsTouchEvents(): boolean; | ||
export declare function supportsPointerEvents(): boolean; | ||
export declare function getTouchIds(event: TouchEvent | React.TouchEvent): number[]; | ||
export declare function getGenericEventData(event: DomEvents): { | ||
touches: number; | ||
down: boolean; | ||
buttons: number; | ||
@@ -24,4 +24,13 @@ shiftKey: any; | ||
*/ | ||
export declare function getPointerEventValues(event: TouchEvent | React.TouchEvent | React.PointerEvent | PointerEvent): Vector2; | ||
export declare function getPointerEventValues(event: TouchEvent | React.TouchEvent | React.PointerEvent | PointerEvent, transform?: (xy: Vector2) => Vector2): Vector2; | ||
/** | ||
* Gets two touches event data | ||
* @param event | ||
* @returns two touches event data | ||
*/ | ||
export declare function getTwoTouchesEventValues(event: React.TouchEvent | TouchEvent, pointerIds: [number, number], transform?: (xy: Vector2) => Vector2): { | ||
values: Vector2; | ||
origin: Vector2; | ||
}; | ||
/** | ||
* Gets scroll event values | ||
@@ -31,3 +40,3 @@ * @param event | ||
*/ | ||
export declare function getScrollEventValues(event: React.UIEvent | UIEvent): Vector2; | ||
export declare function getScrollEventValues(event: React.UIEvent | UIEvent, transform?: (xy: Vector2) => Vector2): Vector2; | ||
/** | ||
@@ -38,3 +47,3 @@ * Gets wheel event values. | ||
*/ | ||
export declare function getWheelEventValues(event: React.WheelEvent | WheelEvent): Vector2; | ||
export declare function getWheelEventValues(event: React.WheelEvent | WheelEvent, transform?: (xy: Vector2) => Vector2): Vector2; | ||
/** | ||
@@ -45,11 +54,2 @@ * Gets webkit gesture event values. | ||
*/ | ||
export declare function getWebkitGestureEventValues(event: WebKitGestureEvent): Vector2; | ||
/** | ||
* Gets two touches event data | ||
* @param event | ||
* @returns two touches event data | ||
*/ | ||
export declare function getTwoTouchesEventData(event: React.TouchEvent | TouchEvent): { | ||
values: Vector2; | ||
origin: Vector2; | ||
}; | ||
export declare function getWebkitGestureEventValues(event: WebKitGestureEvent, transform?: (xy: Vector2) => Vector2): Vector2; |
{ | ||
"name": "react-use-gesture", | ||
"version": "8.0.1", | ||
"version": "9.1.3", | ||
"description": "React hook for receiving gestures https://use-gesture.netlify.app", | ||
"main": "dist/index.js", | ||
"module": "dist/react-use-gesture.esm.js", | ||
"module": "dist/reactusegesture.esm.js", | ||
"typings": "dist/index.d.ts", | ||
@@ -14,9 +14,23 @@ "files": [ | ||
"start": "tsdx watch", | ||
"build": "tsdx build", | ||
"build": "tsdx build --name ReactUseGesture --format cjs,esm,umd", | ||
"lint": "tsdx lint", | ||
"prepare": "yarn build", | ||
"build-docs": "cd ./docusaurus && yarn build", | ||
"docs": "yarn --cwd ./documentation start", | ||
"test": "tsdx test", | ||
"test:watch": "tsdx test --watchAll" | ||
"test:watch": "tsdx test --watchAll", | ||
"size": "size-limit", | ||
"analyze": "size-limit --why", | ||
"storybook": "start-storybook -p 6006", | ||
"build-storybook": "build-storybook" | ||
}, | ||
"size-limit": [ | ||
{ | ||
"path": "dist/reactusegesture.cjs.production.min.js", | ||
"limit": "9 KB" | ||
}, | ||
{ | ||
"path": "dist/reactusegesture.esm.js", | ||
"limit": "10 KB" | ||
} | ||
], | ||
"jest": { | ||
@@ -44,3 +58,3 @@ "testEnvironment": "jsdom", | ||
"type": "git", | ||
"url": "git+https://github.com/react-spring/react-use-gesture.git" | ||
"url": "git+https://github.com/pmndrs/react-use-gesture.git" | ||
}, | ||
@@ -68,3 +82,3 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/react-spring/react-use-gesture/issues" | ||
"url": "https://github.com/pmndrs/react-use-gesture/issues" | ||
}, | ||
@@ -76,19 +90,33 @@ "homepage": "https://use-gesture.netlify.app", | ||
"devDependencies": { | ||
"@size-limit/preset-small-lib": "^4.6.2", | ||
"@testing-library/jest-dom": "^5.9.0", | ||
"@testing-library/react": "^11.1.0", | ||
"@types/jest": "^26.0.15", | ||
"@types/react": "^16.9.53", | ||
"@types/react-dom": "^16.9.8", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"husky": "^4.3.0", | ||
"prettier": "^2.1.2", | ||
"@babel/core": "^7.13.8", | ||
"@size-limit/preset-small-lib": "^4.9.2", | ||
"@storybook/addon-actions": "^6.1.11", | ||
"@storybook/addon-essentials": "^6.1.11", | ||
"@storybook/addon-info": "^5.3.21", | ||
"@storybook/addon-links": "^6.1.11", | ||
"@storybook/addons": "^6.1.11", | ||
"@storybook/react": "^6.1.11", | ||
"@testing-library/jest-dom": "^5.11.9", | ||
"@testing-library/react": "^11.2.5", | ||
"@types/jest": "^26.0.20", | ||
"@types/react": "^17.0.2", | ||
"@types/react-dom": "^17.0.1", | ||
"babel-jest": "^26.6.3", | ||
"babel-loader": "^8.2.2", | ||
"eslint-plugin-jest-dom": "^3.6.5", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-testing-library": "^3.10.1", | ||
"husky": "^4.3.7", | ||
"prettier": "^2.2.1", | ||
"pretty-quick": "^3.1.0", | ||
"react": "^17.0.0", | ||
"react-dom": "^17.0.0", | ||
"size-limit": "^4.6.2", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1", | ||
"react-is": "^17.0.1", | ||
"react-spring": "^9.0.0-rc.3", | ||
"size-limit": "^4.9.2", | ||
"tsdx": "^0.14.1", | ||
"tslib": "^2.0.3", | ||
"typescript": "^4.0.3" | ||
} | ||
"tslib": "^2.1.0", | ||
"typescript": "^4.1.3" | ||
}, | ||
"dependencies": {} | ||
} |
# React UseGesture | ||
![npm (tag)](https://img.shields.io/npm/v/react-use-gesture?style=flat&colorA=000000&colorB=000000) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/react-use-gesture?style=flat&colorA=000000&colorB=000000) ![NPM](https://img.shields.io/npm/l/react-use-gesture?style=flat&colorA=000000&colorB=000000) ![Travis (.org) branch](https://img.shields.io/travis/pmndrs/react-use-gesture/master?style=flat&colorA=000000&colorB=000000) [![Discord Shield](https://img.shields.io/discord/740090768164651008?style=flat&colorA=000000&colorB=000000&label=discord&logo=discord&logoColor=ffffff)](https://discord.gg/ZZjjNvJ) | ||
[![npm (tag)](https://img.shields.io/npm/v/react-use-gesture?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/react-use-gesture) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/react-use-gesture?style=flat&colorA=000000&colorB=000000) ![NPM](https://img.shields.io/npm/l/react-use-gesture?style=flat&colorA=000000&colorB=000000) ![Travis (.org) branch](https://img.shields.io/travis/pmndrs/react-use-gesture/master?style=flat&colorA=000000&colorB=000000) [![Discord Shield](https://img.shields.io/discord/740090768164651008?style=flat&colorA=000000&colorB=000000&label=discord&logo=discord&logoColor=ffffff)](https://discord.gg/poimandres) | ||
@@ -6,0 +6,0 @@ React UseGesture is a hook that lets you bind richer mouse and touch events to any component or view. With the data you receive, it becomes trivial to set up gestures, and often takes no more than a few lines of code. |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1066653
45
8066
29
2