1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16export declare enum GestureDirection { 17 All, 18 Horizontal, 19 Vertical 20} 21 22export declare enum PanDirection { 23 None, 24 Horizontal, 25 Left, 26 Right, 27 Vertical, 28 Up, 29 Down, 30 All 31} 32 33export declare enum GestureMode { 34 Sequence, 35 Parallel, 36 Exclusive 37} 38 39export declare enum GestureMask { 40 Normal, 41 IgnoreInternal 42} 43 44export declare type GestureType = 45 TapGesture 46 | LongPressGesture 47 | PanGesture 48 | PinchGesture 49 | RotationGesture 50 | GestureGroup 51 52export interface GestureEvent { 53 repeat: boolean; 54 offsetX: number; 55 offsetY: number; 56 scale: number; 57 angle: number; 58 timestamp: number; 59 globalX: number; 60 globalY: number; 61 localX: number; 62 localY: number; 63 pinchCenterX: number; 64 pinchCenterY: number; 65} 66 67interface TapGesture { 68 (value?: { count?: number, fingers?: number }): TapGesture; 69 70 onAction(event: (event?: GestureEvent) => void): TapGesture; 71} 72 73interface LongPressGesture { 74 (value?: { fingers?: number, repeat?: boolean, duration?: number }): LongPressGesture; 75 76 onAction(event: (event?: GestureEvent) => void): LongPressGesture; 77 78 onActionEnd(event: (event?: GestureEvent) => void): LongPressGesture; 79 80 onActionCancel(event: () => void): LongPressGesture; 81} 82 83export declare class PanGestureOption { 84 constructor(value?: { fingers?: number, direction?: PanDirection, distance?: number }); 85 setDirection(value: PanDirection); 86 setDistance(value: number); 87 setFingers(value: number); 88} 89 90interface PanGesture { 91 (value?: { fingers?: number, direction?: PanDirection, distance?: number } | PanGestureOption): PanGesture; 92 93 onActionStart(event: (event?: GestureEvent) => void): PanGesture; 94 95 onActionUpdate(event: (event?: GestureEvent) => void): PanGesture; 96 97 onActionEnd(event: (event?: GestureEvent) => void): PanGesture; 98 99 onActionCancel(event: () => void): PanGesture; 100} 101 102interface PinchGesture { 103 (value?: { fingers?: number, distance?: number }): PinchGesture; 104 105 onActionStart(event: (event?: GestureEvent) => void): PinchGesture; 106 107 onActionUpdate(event: (event?: GestureEvent) => void): PinchGesture; 108 109 onActionEnd(event: (event?: GestureEvent) => void): PinchGesture; 110 111 onActionCancel(event: () => void): PinchGesture; 112} 113 114interface RotationGesture { 115 (value?: { fingers?: number, angle?: number }): RotationGesture; 116 117 onActionStart(event: (event?: GestureEvent) => void): RotationGesture; 118 119 onActionUpdate(event: (event?: GestureEvent) => void): RotationGesture; 120 121 onActionEnd(event: (event?: GestureEvent) => void): RotationGesture; 122 123 onActionCancel(event: () => void): RotationGesture; 124} 125 126interface GestureGroup { 127 (mode: GestureMode, ...gesture: GestureType[]): GestureGroup; 128 129 onCancel(event: () => void): GestureGroup; 130} 131 132export declare const TapGestureInterface: TapGesture; 133export declare const LongPressGestureInterface: LongPressGesture; 134export declare const PanGestureInterface: PanGesture; 135export declare const PinchGestureInterface: PinchGesture; 136export declare const RotationGestureInterface: RotationGesture; 137export declare const GestureGroupInterface: GestureGroup; 138