This repository has been archived by the owner on Sep 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 283
/
Copy pathimage-zoom.type.ts
225 lines (189 loc) · 4.43 KB
/
image-zoom.type.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
import { GestureResponderEvent, PanResponderGestureState, LayoutChangeEvent, ViewStyle } from 'react-native';
export interface ICenterOn {
x: number;
y: number;
scale: number;
duration: number;
}
export interface IOnMove {
type: string;
positionX: number;
positionY: number;
scale: number;
zoomCurrentDistance: number;
}
export interface IOnClick {
locationX: number;
locationY: number;
pageX: number;
pageY: number;
}
export class ImageZoomProps {
/**
* 操作区域宽度
*/
public cropWidth: number = 100;
/**
* 操作区域高度
*/
public cropHeight: number = 100;
/**
* 图片宽度
*/
public imageWidth: number = 100;
/**
* 图片高度
*/
public imageHeight: number = 100;
/**
* 单手是否能移动图片
*/
public panToMove?: boolean = true;
/**
* 多手指是否能缩放
*/
public pinchToZoom?: boolean = true;
/**
* 双击能否放大
*/
public enableDoubleClickZoom?: boolean = true;
/**
* 单击最大位移
*/
public clickDistance?: number = 10;
/**
* 最大滑动阈值
*/
public maxOverflow?: number = 100;
/**
* 长按的阈值(毫秒)
*/
public longPressTime?: number = 800;
/**
* 双击计时器最大间隔
*/
public doubleClickInterval?: number = 175;
/**
* If provided this will cause the view to zoom and pan to the center point
* Duration is optional and defaults to 300 ms.
*/
public centerOn?: ICenterOn;
public style?: ViewStyle = {};
/**
* threshold for firing swipe down function
*/
public swipeDownThreshold?: number = 230;
/**
* for enabling vertical movement if user doesn't want it
*/
public enableSwipeDown?: boolean = false;
/**
* for disabling focus on image center if user doesn't want it
*/
public enableCenterFocus?: boolean = true;
/**
* for disabling rendering to hardware texture on Android
*/
public useHardwareTextureAndroid?: boolean = true;
/**
* minimum zoom scale
*/
public minScale?: number = 0.6;
/**
* maximum zoom scale
*/
public maxScale?: number = 10;
/**
* 是否启用原生动画驱动
* Whether to use native code to perform animations.
*/
public useNativeDriver?: boolean = false;
/**
* 单击的回调
*/
public onClick?: (eventParams: IOnClick) => void = () => {
//
};
/**
* 双击的回调
*/
public onDoubleClick?: (eventParams: IOnClick) => void = () => {
//
};
/**
* 长按的回调
*/
public onLongPress?: (eventParams: IOnClick) => void = () => {
//
};
/**
* 横向超出的距离,父级做图片切换时,可以监听这个函数
* 当此函数触发时,可以做切换操作
*/
public horizontalOuterRangeOffset?: (offsetX: number) => void = () => {
//
};
/**
* 触发想切换到左边的图,向左滑动速度超出阈值时触发
*/
public onDragLeft?: () => void = () => {
//
};
/**
* 松手但是没有取消看图的回调
*/
public responderRelease?: (vx: number, scale: number) => void = () => {
//
};
/**
* If provided, this will be called everytime the map is moved
*/
public onMove?: (position: IOnMove) => void = () => {
//
};
/**
* If provided, this method will be called when the onLayout event fires
*/
public layoutChange?: (event: LayoutChangeEvent) => void = () => {
//
};
/**
* function that fires when user swipes down
*/
public onSwipeDown?: () => void = () => {
//
};
/**
* Allows defining the onMoveShouldSetResponder behavior.
*/
public onMoveShouldSetPanResponder?: (
event: GestureResponderEvent,
gestureState: PanResponderGestureState
) => boolean;
/**
* Allows overriding the default onStartShouldSetPanResponder behavior.
* By default, always becomes the responder
*/
public onStartShouldSetPanResponder?: (
event: GestureResponderEvent,
gestureState: PanResponderGestureState
) => boolean = () => true;
/**
* Allows overriding the default onPanResponderTerminationRequest behavior.
* By default, doesn't terminate until the press ends
*/
public onPanResponderTerminationRequest?: (
event: GestureResponderEvent,
gestureState: PanResponderGestureState
) => boolean = () => false;
}
export class ImageZoomState {
/**
* 中心 x 坐标
*/
public centerX?: number = 0.5;
/**
* 中心 y 坐标
*/
public centerY?: number = 0.5;
}