@nativescript-community/gesturehandler 2.0.20 → 2.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,97 @@
1
+ import Observable from '@nativescript-community/observable';
2
+ import { EventData, GridLayout } from '@nativescript/core';
3
+ import { CssProperty, Style, View } from '@nativescript/core/ui';
4
+ import { FlingGestureHandler, FlingGestureHandlerOptions, ForceTouchGestureHandler, ForceTouchGestureHandlerOptions, Handler, LongPressGestureHandler, LongPressGestureHandlerOptions, NativePropertyOptions, NativeViewGestureHandler, NativeViewGestureHandlerOptions, PanGestureHandler, PanGestureHandlerOptions, PinchGestureHandler, PinchGestureHandlerOptions, RotationGestureHandler, RotationGestureHandlerOptions, TapGestureHandler, TapGestureHandlerOptions } from './gesturehandler';
5
+ export declare const GestureHandlerStateEvent = "GestureHandlerStateEvent";
6
+ export declare const GestureHandlerTouchEvent = "GestureHandlerTouchEvent";
7
+ export declare const ROOT_GESTURE_HANDLER_TAG = -12345;
8
+ export declare enum HandlerType {
9
+ PAN = "pan",
10
+ TAP = "tap",
11
+ FLING = "fling",
12
+ LONG_PRESS = "longPress",
13
+ NATIVE_VIEW = "nativeView",
14
+ PINCH = "pinch",
15
+ ROTATION = "rotation",
16
+ FORCE_TOUCH = "forceTouch"
17
+ }
18
+ export interface OptionsTypeMap {
19
+ [HandlerType.TAP]: TapGestureHandlerOptions;
20
+ [HandlerType.LONG_PRESS]: LongPressGestureHandlerOptions;
21
+ [HandlerType.PINCH]: PinchGestureHandlerOptions;
22
+ [HandlerType.FLING]: FlingGestureHandlerOptions;
23
+ [HandlerType.PAN]: PanGestureHandlerOptions;
24
+ [HandlerType.ROTATION]: RotationGestureHandlerOptions;
25
+ [HandlerType.NATIVE_VIEW]: NativeViewGestureHandlerOptions;
26
+ [HandlerType.FORCE_TOUCH]: ForceTouchGestureHandlerOptions;
27
+ }
28
+ export interface TypeMap {
29
+ [HandlerType.TAP]: TapGestureHandler;
30
+ [HandlerType.LONG_PRESS]: LongPressGestureHandler;
31
+ [HandlerType.PINCH]: PinchGestureHandler;
32
+ [HandlerType.FLING]: FlingGestureHandler;
33
+ [HandlerType.PAN]: PanGestureHandler;
34
+ [HandlerType.ROTATION]: RotationGestureHandler;
35
+ [HandlerType.NATIVE_VIEW]: NativeViewGestureHandler;
36
+ [HandlerType.FORCE_TOUCH]: ForceTouchGestureHandler;
37
+ }
38
+ export declare function nativeProperty(target: any, k?: any, desc?: PropertyDescriptor): any;
39
+ export declare function nativeProperty(options: NativePropertyOptions): (target: any, k?: any, desc?: PropertyDescriptor) => any;
40
+ export declare abstract class BaseNative<T, U extends {}> extends Observable {
41
+ options?: U;
42
+ constructor(options?: U, native?: T);
43
+ native: T;
44
+ initNativeView(native: T, options: U): void;
45
+ disposeNativeView(): void;
46
+ getNative(): T;
47
+ abstract createNative(options: U): T;
48
+ }
49
+ export declare abstract class ManagerBase extends Observable {
50
+ abstract createGestureHandler<T extends HandlerType>(handlerName: T, handlerTag: number, config?: OptionsTypeMap[T]): TypeMap[T];
51
+ }
52
+ export declare enum GestureState {
53
+ UNDETERMINED = 0,
54
+ FAILED = 1,
55
+ BEGAN = 2,
56
+ CANCELLED = 3,
57
+ ACTIVE = 4,
58
+ END = 5
59
+ }
60
+ export interface GestureStateEventData extends EventData {
61
+ object: Handler<any, any>;
62
+ data: {
63
+ state: GestureState;
64
+ prevState: GestureState;
65
+ ios?: any;
66
+ android?: any;
67
+ view: View;
68
+ extraData: {
69
+ [k: string]: number;
70
+ };
71
+ };
72
+ }
73
+ export interface GestureTouchEventData extends EventData {
74
+ object: Handler<any, any>;
75
+ data: {
76
+ state: GestureState;
77
+ ios?: any;
78
+ android?: any;
79
+ view?: View;
80
+ extraData: {
81
+ [k: string]: number;
82
+ };
83
+ };
84
+ }
85
+ export declare class BaseGestureRootView extends GridLayout {
86
+ }
87
+ export declare function applyMixins(derivedCtor: any, baseCtors: any[], options?: {
88
+ after?: boolean;
89
+ override?: boolean;
90
+ omit?: (string | symbol)[];
91
+ }): void;
92
+ export declare const exclusiveTouchProperty: CssProperty<Style, boolean>;
93
+ export declare const disallowInterceptTouchProperty: CssProperty<Style, boolean>;
94
+ export declare const ViewInitEvent = "ViewInitEvent";
95
+ export declare const ViewDisposeEvent = "ViewDisposeEvent";
96
+ export declare function overrideViewBase(): void;
97
+ export declare function install(overrideNGestures?: boolean): void;
@@ -0,0 +1,274 @@
1
+ /* eslint-disable no-redeclare */
2
+ import Observable from '@nativescript-community/observable';
3
+ import { GridLayout } from '@nativescript/core';
4
+ import { CssProperty, Style, View, booleanConverter } from '@nativescript/core/ui';
5
+ import { FlingGestureHandler, ForceTouchGestureHandler, Handler, LongPressGestureHandler, Manager, NativeViewGestureHandler, PanGestureHandler, PinchGestureHandler, RotationGestureHandler, TapGestureHandler } from './gesturehandler';
6
+ export const GestureHandlerStateEvent = 'GestureHandlerStateEvent';
7
+ export const GestureHandlerTouchEvent = 'GestureHandlerTouchEvent';
8
+ export const ROOT_GESTURE_HANDLER_TAG = -12345;
9
+ export var HandlerType;
10
+ (function (HandlerType) {
11
+ HandlerType["PAN"] = "pan";
12
+ HandlerType["TAP"] = "tap";
13
+ HandlerType["FLING"] = "fling";
14
+ HandlerType["LONG_PRESS"] = "longPress";
15
+ HandlerType["NATIVE_VIEW"] = "nativeView";
16
+ HandlerType["PINCH"] = "pinch";
17
+ HandlerType["ROTATION"] = "rotation";
18
+ HandlerType["FORCE_TOUCH"] = "forceTouch";
19
+ })(HandlerType || (HandlerType = {}));
20
+ function createGetter(key, options) {
21
+ const nativeGetterName = ((__ANDROID__ ? options.android : options.ios) || options).nativeGetterName || 'get' + key.charAt(0).toUpperCase() + key.slice(1);
22
+ const converter = options.converter;
23
+ return function () {
24
+ let result;
25
+ if (this.native && this.native[nativeGetterName]) {
26
+ result = this.native[nativeGetterName]();
27
+ }
28
+ else {
29
+ result = this.options[key] || options.defaultValue;
30
+ }
31
+ result = converter && converter.fromNative ? converter.fromNative.call(this, result, key) : result;
32
+ return result;
33
+ };
34
+ }
35
+ function createSetter(key, options) {
36
+ const nativeSetterName = ((__ANDROID__ ? options.android : options.ios) || options).nativeSetterName || 'set' + key.charAt(0).toUpperCase() + key.slice(1);
37
+ return function (newVal) {
38
+ this.options[key] = newVal;
39
+ if (this.native && this.native[nativeSetterName]) {
40
+ const actualVal = options.converter && options.converter.toNative ? options.converter.toNative.call(this, newVal, key) : newVal;
41
+ this.native[nativeSetterName].call(this.native, actualVal);
42
+ }
43
+ };
44
+ }
45
+ function nativePropertyGenerator(target, key, options) {
46
+ Object.defineProperty(target, key, {
47
+ get: createGetter(key, options),
48
+ set: createSetter(key, options),
49
+ enumerable: true,
50
+ configurable: true
51
+ });
52
+ }
53
+ export function nativeProperty(...args) {
54
+ if (args.length === 1) {
55
+ /// this must be a factory
56
+ return function (target, key, descriptor) {
57
+ return nativePropertyGenerator(target, key, args[0] || {});
58
+ };
59
+ }
60
+ else {
61
+ const options = typeof args[1] === 'string' ? undefined : args[0];
62
+ const startIndex = !!options ? 1 : 0;
63
+ return nativePropertyGenerator(args[startIndex], args[startIndex + 1], options || {});
64
+ }
65
+ }
66
+ export class BaseNative extends Observable {
67
+ constructor(options, native) {
68
+ super();
69
+ this.options = options;
70
+ if (native) {
71
+ this.native = native;
72
+ }
73
+ }
74
+ initNativeView(native, options) {
75
+ for (const key in options) {
76
+ this[key] = options[key];
77
+ }
78
+ }
79
+ disposeNativeView() {
80
+ this.native = null;
81
+ }
82
+ getNative() {
83
+ if (!this.native) {
84
+ this.native = this.createNative(this.options);
85
+ this.initNativeView(this.native, this.options);
86
+ }
87
+ return this.native;
88
+ }
89
+ }
90
+ export class ManagerBase extends Observable {
91
+ }
92
+ export var GestureState;
93
+ (function (GestureState) {
94
+ GestureState[GestureState["UNDETERMINED"] = 0] = "UNDETERMINED";
95
+ GestureState[GestureState["FAILED"] = 1] = "FAILED";
96
+ GestureState[GestureState["BEGAN"] = 2] = "BEGAN";
97
+ GestureState[GestureState["CANCELLED"] = 3] = "CANCELLED";
98
+ GestureState[GestureState["ACTIVE"] = 4] = "ACTIVE";
99
+ GestureState[GestureState["END"] = 5] = "END";
100
+ })(GestureState || (GestureState = {}));
101
+ export class BaseGestureRootView extends GridLayout {
102
+ }
103
+ export function applyMixins(derivedCtor, baseCtors, options) {
104
+ const omits = options && options.omit ? options.omit : [];
105
+ baseCtors.forEach((baseCtor) => {
106
+ Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
107
+ if (omits.indexOf(name) !== -1) {
108
+ return;
109
+ }
110
+ const descriptor = Object.getOwnPropertyDescriptor(baseCtor.prototype, name);
111
+ if (name === 'constructor')
112
+ return;
113
+ if (descriptor && (!descriptor.writable || !descriptor.configurable || descriptor.get || descriptor.set)) {
114
+ Object.defineProperty(derivedCtor.prototype, name, descriptor);
115
+ }
116
+ else {
117
+ const oldImpl = derivedCtor.prototype[name];
118
+ if (!oldImpl) {
119
+ derivedCtor.prototype[name] = baseCtor.prototype[name];
120
+ }
121
+ else {
122
+ derivedCtor.prototype[name] = function (...args) {
123
+ if (options) {
124
+ if (!!options.override) {
125
+ return baseCtor.prototype[name].apply(this, args);
126
+ }
127
+ else if (!!options.after) {
128
+ oldImpl.apply(this, args);
129
+ return baseCtor.prototype[name].apply(this, args);
130
+ }
131
+ else {
132
+ baseCtor.prototype[name].apply(this, args);
133
+ return oldImpl.apply(this, args);
134
+ }
135
+ }
136
+ else {
137
+ baseCtor.prototype[name].apply(this, args);
138
+ return oldImpl.apply(this, args);
139
+ }
140
+ };
141
+ }
142
+ }
143
+ });
144
+ Object.getOwnPropertySymbols(baseCtor.prototype).forEach((symbol) => {
145
+ if (omits.indexOf(symbol) !== -1) {
146
+ return;
147
+ }
148
+ const oldImpl = derivedCtor.prototype[symbol];
149
+ if (!oldImpl) {
150
+ derivedCtor.prototype[symbol] = baseCtor.prototype[symbol];
151
+ }
152
+ else {
153
+ derivedCtor.prototype[symbol] = function (...args) {
154
+ if (options) {
155
+ if (!!options.override) {
156
+ return baseCtor.prototype[symbol].apply(this, args);
157
+ }
158
+ else if (!!options.after) {
159
+ oldImpl.apply(this, args);
160
+ return baseCtor.prototype[symbol].apply(this, args);
161
+ }
162
+ else {
163
+ baseCtor.prototype[symbol].apply(this, args);
164
+ return oldImpl.apply(this, args);
165
+ }
166
+ }
167
+ else {
168
+ baseCtor.prototype[symbol].apply(this, args);
169
+ return oldImpl.apply(this, args);
170
+ }
171
+ };
172
+ }
173
+ });
174
+ });
175
+ }
176
+ export const exclusiveTouchProperty = new CssProperty({
177
+ name: 'exclusiveTouch',
178
+ cssName: 'exclusive-touch',
179
+ defaultValue: false,
180
+ valueConverter: booleanConverter
181
+ });
182
+ export const disallowInterceptTouchProperty = new CssProperty({
183
+ name: 'disallowInterceptTouch',
184
+ cssName: 'disallow-intercept-touch',
185
+ defaultValue: false,
186
+ valueConverter: booleanConverter
187
+ });
188
+ export const ViewInitEvent = 'ViewInitEvent';
189
+ export const ViewDisposeEvent = 'ViewDisposeEvent';
190
+ let NATIVE_GESTURE_TAG = 74000;
191
+ class ViewGestureExtended extends View {
192
+ constructor() {
193
+ super(...arguments);
194
+ this.disallowInterceptTouchEventRegistered = false;
195
+ }
196
+ set exclusiveTouch(value) {
197
+ this.style['exclusiveTouch'] = value;
198
+ }
199
+ get exclusiveTouch() {
200
+ return this.style['exclusiveTouch'];
201
+ }
202
+ initNativeView() {
203
+ if (this.nativeView) {
204
+ this.nativeView.nsView = new WeakRef(this);
205
+ }
206
+ this.notify({ eventName: ViewInitEvent, object: this });
207
+ }
208
+ disposeNativeView() {
209
+ if (this.nativeView) {
210
+ this.nativeView.nsView = null;
211
+ }
212
+ if (this.exclusiveTouchGestureHandler) {
213
+ this.exclusiveTouchGestureHandler.detachFromView();
214
+ this.exclusiveTouchGestureHandler = null;
215
+ }
216
+ this.notify({ eventName: ViewDisposeEvent, object: this });
217
+ }
218
+ [exclusiveTouchProperty.setNative](value) {
219
+ if (value) {
220
+ if (!this.exclusiveTouchGestureHandler) {
221
+ const gestureHandler = Manager.getInstance().createGestureHandler(HandlerType.NATIVE_VIEW, NATIVE_GESTURE_TAG++, {
222
+ disallowInterruption: true,
223
+ shouldActivateOnStart: false,
224
+ shouldCancelWhenOutside: false
225
+ });
226
+ this.exclusiveTouchGestureHandler = gestureHandler;
227
+ }
228
+ this.exclusiveTouchGestureHandler.attachToView(this);
229
+ }
230
+ else if (this.exclusiveTouchGestureHandler) {
231
+ this.exclusiveTouchGestureHandler.detachFromView();
232
+ }
233
+ }
234
+ onTouch(event) {
235
+ if (__ANDROID__) {
236
+ const mask = event.android.getActionMasked();
237
+ if (mask === 0 /* android.view.MotionEvent.ACTION_DOWN */) {
238
+ this.nativeViewProtected.requestDisallowInterceptTouchEvent(true);
239
+ }
240
+ else if (mask === 3 /* android.view.MotionEvent.ACTION_CANCEL */ || mask === 1 /* android.view.MotionEvent.ACTION_UP */) {
241
+ this.nativeViewProtected.requestDisallowInterceptTouchEvent(false);
242
+ }
243
+ }
244
+ }
245
+ [disallowInterceptTouchProperty.setNative](value) {
246
+ if (__ANDROID__) {
247
+ if (value) {
248
+ if (!this.disallowInterceptTouchEventRegistered) {
249
+ this.disallowInterceptTouchEventRegistered = true;
250
+ this.on('touch', this.onTouch, this);
251
+ }
252
+ }
253
+ else if (this.disallowInterceptTouchEventRegistered) {
254
+ this.disallowInterceptTouchEventRegistered = false;
255
+ this.off('touch', this.onTouch, this);
256
+ }
257
+ }
258
+ }
259
+ }
260
+ exclusiveTouchProperty.register(Style);
261
+ disallowInterceptTouchProperty.register(Style);
262
+ let installed = false;
263
+ export function overrideViewBase() {
264
+ const NSView = require('@nativescript/core/ui/core/view').View;
265
+ applyMixins(NSView, [ViewGestureExtended]);
266
+ }
267
+ export function install(overrideNGestures) {
268
+ if (installed) {
269
+ return;
270
+ }
271
+ installed = true;
272
+ overrideViewBase();
273
+ }
274
+ //# sourceMappingURL=gesturehandler.common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gesturehandler.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';
3
+ import { View } from '@nativescript/core';
4
+ import { BaseGestureRootView, HandlerType, OptionsTypeMap, TypeMap } from './gesturehandler.common';
5
+
6
+ export { GestureState, GestureHandlerStateEvent, GestureHandlerTouchEvent, GestureStateEventData, GestureTouchEventData, HandlerType } from './gesturehandler.common';
7
+ // export * from './gesturehandler.ios';
8
+
9
+ export enum FlingDirection {
10
+ DIRECTION_LEFT,
11
+ DIRECTION_UP,
12
+ DIRECTION_DOWN,
13
+ DIRECTION_RIGHT,
14
+ }
15
+
16
+ export abstract class BaseNative<T, U extends {}> extends Observable {
17
+ options?: U;
18
+ native: T;
19
+ constructor(options?: U, native?: T);
20
+ initNativeView(native: T, options: U): void;
21
+ getNative(): T;
22
+ log(...args);
23
+ }
24
+ export interface NativePropertyOptions {
25
+ converter?: {
26
+ fromNative: Function;
27
+ toNative: Function;
28
+ };
29
+ defaultValue?: any;
30
+ nativeGetterName?: string;
31
+ nativeSetterName?: string;
32
+ getConverter?: Function;
33
+ ios?: {
34
+ nativeGetterName?: string;
35
+ nativeSetterName?: string;
36
+ };
37
+ android?: {
38
+ nativeGetterName?: string;
39
+ nativeSetterName?: string;
40
+ };
41
+ }
42
+
43
+ export declare function nativeProperty(target: any, k?, desc?: PropertyDescriptor): any;
44
+ export declare function nativeProperty(options: NativePropertyOptions): (target: any, k?, desc?: PropertyDescriptor) => any;
45
+ export declare function nativeProperty(...args);
46
+
47
+ export interface HandlerOptions {
48
+ [k: string]: any;
49
+ enabled?: boolean;
50
+ shouldCancelWhenOutside?: boolean;
51
+ waitFor?: number[];
52
+ simultaneousHandlers?: number[];
53
+ /**
54
+ * optional property to access the View nativeView
55
+ *
56
+ * @memberof HandlerOptions
57
+ */
58
+ nativeGetterKey?: string;
59
+ }
60
+ export abstract class Handler<T, U extends HandlerOptions> extends BaseNative<T, U> {
61
+ enabled: boolean;
62
+ shouldCancelWhenOutside: boolean;
63
+ setTag(tag: number);
64
+ getTag(): number;
65
+ getView(): View;
66
+ cancel();
67
+ attachToView(view: View);
68
+ detachFromView(view?: View);
69
+ }
70
+ export interface TapGestureHandlerOptions extends HandlerOptions {
71
+ numberOfTaps?: number;
72
+ maxDurationMs?: number;
73
+ maxDelayMs?: number;
74
+ maxDeltaX?: number;
75
+ maxDeltaY?: number;
76
+ maxDist?: number;
77
+ minPointers?: number;
78
+ }
79
+
80
+ export class TapGestureHandler extends Handler<any, TapGestureHandlerOptions> {
81
+ numberOfTaps: number;
82
+ maxDurationMs: number;
83
+ maxDelayMs: number;
84
+ maxDeltaX: number;
85
+ maxDeltaY: number;
86
+ maxDist: number;
87
+ minPointers: number;
88
+ }
89
+ export interface PanGestureHandlerOptions extends HandlerOptions {
90
+ minDist?: number;
91
+ activeOffsetXStart?: number;
92
+ activeOffsetXEnd?: number;
93
+ failOffsetXStart?: number;
94
+ failOffsetXEnd?: number;
95
+ activeOffsetYStart?: number;
96
+ activeOffsetYEnd?: number;
97
+ failOffsetYStart?: number;
98
+ failOffsetYEnd?: number;
99
+ }
100
+
101
+ export class PanGestureHandler extends Handler<any, PanGestureHandlerOptions> {
102
+ minDist: number;
103
+ activeOffsetXStart: number;
104
+ activeOffsetXEnd: number;
105
+ failOffsetXStart: number;
106
+ failOffsetXEnd: number;
107
+ activeOffsetYStart: number;
108
+ activeOffsetYEnd: number;
109
+ failOffsetYStart: number;
110
+ failOffsetYEnd: number;
111
+ }
112
+ export interface NativeViewGestureHandlerOptions extends HandlerOptions {
113
+ shouldActivateOnStart?: boolean;
114
+ disallowInterruption?: boolean;
115
+ }
116
+ export class NativeViewGestureHandler extends Handler<any, NativeViewGestureHandlerOptions> {
117
+ shouldActivateOnStart: boolean;
118
+ disallowInterruption: boolean;
119
+ }
120
+ export interface LongPressGestureHandlerOptions extends HandlerOptions {
121
+ maxDist?: number;
122
+ minDurationMs?: number;
123
+ }
124
+ export class LongPressGestureHandler extends Handler<any, LongPressGestureHandlerOptions> {
125
+ maxDist: number;
126
+ minDurationMs: number;
127
+ }
128
+ export interface FlingGestureHandlerOptions extends HandlerOptions {
129
+ numberOfPointers?: number;
130
+ direction?: number;
131
+ }
132
+ export class FlingGestureHandler extends Handler<any, FlingGestureHandlerOptions> {
133
+ numberOfPointers: number;
134
+ direction: number;
135
+ }
136
+ export interface PinchGestureHandlerOptions extends HandlerOptions {}
137
+ export class PinchGestureHandler extends Handler<any, PinchGestureHandlerOptions> {}
138
+ export interface RotationGestureHandlerOptions extends HandlerOptions {}
139
+ export class RotationGestureHandler extends Handler<any, RotationGestureHandlerOptions> {}
140
+
141
+ export interface ForceTouchGestureHandlerOptions extends HandlerOptions {
142
+ minForce?: number;
143
+ maxForce?: number;
144
+ }
145
+ export class ForceTouchGestureHandler extends Handler<any, ForceTouchGestureHandlerOptions> {
146
+ minForce: number;
147
+ maxForce: number;
148
+ }
149
+
150
+ export class Manager extends Observable {
151
+ static getInstance(): Manager;
152
+ createGestureHandler<T extends HandlerType>(handlerName: T, handlerTag: number, config?: OptionsTypeMap[T]): TypeMap[T];
153
+ }
154
+ export function install(overrideNGestures?: boolean);
155
+
156
+ export class GestureRootView extends BaseGestureRootView {}
@@ -0,0 +1,56 @@
1
+ import { View } from '@nativescript/core/ui';
2
+ import { HandlerOptions } from './gesturehandler';
3
+ import { BaseGestureRootView, BaseNative, GestureHandlerStateEvent, GestureHandlerTouchEvent, GestureState, GestureStateEventData, GestureTouchEventData, HandlerType, ManagerBase, OptionsTypeMap, TypeMap, ViewDisposeEvent, ViewInitEvent } from './gesturehandler.common';
4
+ export { GestureState, GestureHandlerStateEvent, GestureHandlerTouchEvent, GestureStateEventData, GestureTouchEventData, HandlerType, ViewInitEvent, ViewDisposeEvent };
5
+ export declare enum FlingDirection {
6
+ DIRECTION_LEFT = 2,
7
+ DIRECTION_UP = 4,
8
+ DIRECTION_DOWN = 8,
9
+ DIRECTION_RIGHT = 1
10
+ }
11
+ export declare function install(overrideNGestures?: boolean): void;
12
+ export declare class GestureRootView extends BaseGestureRootView {
13
+ }
14
+ export declare class HandlerDelegate extends NSObject implements GestureHandlerDelegate {
15
+ static ObjCProtocols: {
16
+ prototype: GestureHandlerDelegate;
17
+ }[];
18
+ private _owner;
19
+ static new(): HandlerDelegate;
20
+ static initWithOwner(owner: WeakRef<Handler<any, any>>): HandlerDelegate;
21
+ gestureHandlerDidChangeStatePrevStateExtraDataView(handler: GestureHandler, state: GestureHandlerState, prevState: GestureHandlerState, extraData: NSDictionary<any, any>, view: UIView & {
22
+ nsView?: WeakRef<View>;
23
+ }): void;
24
+ gestureHandlerTouchEventOnViewStateExtraData(handler: GestureHandler, view: UIView & {
25
+ nsView?: WeakRef<View>;
26
+ }, state: GestureHandlerState, extraData: NSDictionary<any, any>): void;
27
+ gestureHandlerShouldActivateForEvent(handler: GestureHandler, extraData: NSDictionary<any, any>): any;
28
+ }
29
+ export declare class Handler<T extends GestureHandler, U extends HandlerOptions> extends BaseNative<T, U> {
30
+ manager: WeakRef<Manager>;
31
+ delegate: HandlerDelegate;
32
+ enabled: boolean;
33
+ shouldCancelWhenOutside: boolean;
34
+ createNative(): any;
35
+ attachedView: View;
36
+ nativeGetterKey: string;
37
+ attachToView(view: View): void;
38
+ detachFromView(view?: View): void;
39
+ getTag(): number;
40
+ setTag(value: any): void;
41
+ getView(): View;
42
+ cancel(): void;
43
+ }
44
+ export declare class Manager extends ManagerBase {
45
+ _manager: GestureHandlerManager;
46
+ get manager(): GestureHandlerManager;
47
+ static sManager: Manager;
48
+ static getInstance(): Manager;
49
+ createGestureHandler<T extends HandlerType>(handlerName: T, handlerTag: number, config?: OptionsTypeMap[T]): TypeMap[T];
50
+ viewListeners: Map<View, Map<number, {
51
+ init: () => void;
52
+ dispose: () => void;
53
+ }>>;
54
+ attachGestureHandler(handler: Handler<any, any>, view: View): void;
55
+ detachGestureHandler(handlerTag: number, view: View): void;
56
+ }