@nativescript-community/gesturehandler 2.0.25 → 2.0.26
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.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nativescript-community/gesturehandler",
|
3
|
-
"version": "2.0.
|
3
|
+
"version": "2.0.26",
|
4
4
|
"description": "Declarative API exposing platform native touch and gesture system to NativeScript.",
|
5
5
|
"main": "gesturehandler",
|
6
6
|
"sideEffects": false,
|
@@ -35,5 +35,5 @@
|
|
35
35
|
"dependencies": {
|
36
36
|
"@nativescript-community/observable": "^2.0.10"
|
37
37
|
},
|
38
|
-
"gitHead": "
|
38
|
+
"gitHead": "e8d059050bff972153044b540202e65854d6bb4e"
|
39
39
|
}
|
@@ -14,7 +14,7 @@
|
|
14
14
|
- (instancetype)initWithTag:(NSNumber *)tag
|
15
15
|
{
|
16
16
|
if ((self = [super initWithTag:tag])) {
|
17
|
-
|
17
|
+
_direction = UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionUp | UISwipeGestureRecognizerDirectionDown;
|
18
18
|
_recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
|
19
19
|
[(UISwipeGestureRecognizer*)_recognizer setDirection:UISwipeGestureRecognizerDirectionLeft];
|
20
20
|
_rightrecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
|
@@ -34,17 +34,17 @@
|
|
34
34
|
|
35
35
|
id prop = config[@"direction"];
|
36
36
|
if (prop != nil) {
|
37
|
-
|
38
|
-
if ((
|
37
|
+
_direction = [prop integerValue];
|
38
|
+
if ((_direction & UISwipeGestureRecognizerDirectionLeft) == 0) {
|
39
39
|
_recognizer.enabled = NO;
|
40
40
|
}
|
41
|
-
if ((
|
41
|
+
if ((_direction & UISwipeGestureRecognizerDirectionRight) == 0) {
|
42
42
|
_rightrecognizer.enabled = NO;
|
43
43
|
}
|
44
|
-
if ((
|
44
|
+
if ((_direction & UISwipeGestureRecognizerDirectionUp) == 0) {
|
45
45
|
_toprecognizer.enabled = NO;
|
46
46
|
}
|
47
|
-
if ((
|
47
|
+
if ((_direction & UISwipeGestureRecognizerDirectionDown) == 0) {
|
48
48
|
_bottomrecognizer.enabled = NO;
|
49
49
|
}
|
50
50
|
}
|
@@ -90,7 +90,11 @@
|
|
90
90
|
_bottomrecognizer.delegate = nil;
|
91
91
|
}
|
92
92
|
- (void) setDirection:(NSInteger) value {
|
93
|
-
|
93
|
+
_direction = value;
|
94
|
+
_recognizer.enabled = (_direction & UISwipeGestureRecognizerDirectionLeft) != 0;
|
95
|
+
_rightrecognizer.enabled = (_direction & UISwipeGestureRecognizerDirectionRight) != 0;
|
96
|
+
_toprecognizer.enabled = (_direction & UISwipeGestureRecognizerDirectionUp) != 0;
|
97
|
+
_bottomrecognizer.enabled = (_direction & UISwipeGestureRecognizerDirectionDown) != 0;
|
94
98
|
}
|
95
99
|
//
|
96
100
|
//- (NSNumber *) direction {
|
@@ -128,4 +132,3 @@
|
|
128
132
|
return result;
|
129
133
|
}
|
130
134
|
@end
|
131
|
-
|
@@ -78,6 +78,7 @@ if (value != nil) recognizer.prop = [value type]; \
|
|
78
78
|
//@property (nonatomic, weak, nullable) id<GestureHandlerEventEmitter> emitter;
|
79
79
|
@property (nonatomic, readonly, nullable) UIGestureRecognizer *recognizer;
|
80
80
|
@property (nonatomic) BOOL enabled;
|
81
|
+
@property (nonatomic) BOOL activateOnBegin;
|
81
82
|
@property(nonatomic) BOOL shouldCancelWhenOutside;
|
82
83
|
@property (nullable, nonatomic, weak) id<GestureHandlerDelegate> delegate;
|
83
84
|
|
@@ -70,6 +70,7 @@ CGRect GHHitSlopInsetRect(CGRect rect, RNGHHitSlop hitSlop) {
|
|
70
70
|
_tag = tag;
|
71
71
|
_lastState = GestureHandlerStateUndetermined;
|
72
72
|
_hitSlop = RNGHHitSlopEmpty;
|
73
|
+
_activateOnBegin = YES;
|
73
74
|
}
|
74
75
|
return self;
|
75
76
|
}
|
@@ -323,7 +324,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
|
|
323
324
|
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
|
324
325
|
{
|
325
326
|
[self reset];
|
326
|
-
if (self.delegate && [self.delegate respondsToSelector:@selector(gestureHandler:shouldActivateForEvent:)]) {
|
327
|
+
if (self.activateOnBegin && self.delegate && [self.delegate respondsToSelector:@selector(gestureHandler:shouldActivateForEvent:)]) {
|
327
328
|
if (![self.delegate gestureHandler:self shouldActivateForEvent:[self eventExtraData:gestureRecognizer]]) {
|
328
329
|
return FALSE;
|
329
330
|
}
|
@@ -79,6 +79,12 @@
|
|
79
79
|
}
|
80
80
|
#endif
|
81
81
|
[super touchesBegan:touches withEvent:event];
|
82
|
+
|
83
|
+
// we check for active before UIGestureRecognizerStateBegan because otherwise
|
84
|
+
// we dont behave as Android and activate on first touch
|
85
|
+
if (![_gestureHandler.delegate gestureHandler:_gestureHandler shouldActivateForEvent:[_gestureHandler eventExtraData:self]]) {
|
86
|
+
self.state = UIGestureRecognizerStateFailed;
|
87
|
+
}
|
82
88
|
}
|
83
89
|
|
84
90
|
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
|
@@ -187,6 +193,7 @@
|
|
187
193
|
{
|
188
194
|
if ((self = [super initWithTag:tag])) {
|
189
195
|
_recognizer = [[BetterPanGestureRecognizer alloc] initWithGestureHandler:self];
|
196
|
+
self.activateOnBegin = NO;
|
190
197
|
}
|
191
198
|
return self;
|
192
199
|
}
|
@@ -275,4 +282,3 @@
|
|
275
282
|
((BetterPanGestureRecognizer*)_recognizer).failOffsetYEnd = value;
|
276
283
|
}
|
277
284
|
@end
|
278
|
-
|