react-native-gesture-handler 2.30.0 → 2.31.0-nightly-20260121-59a5311e3
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/apple/RNGestureHandler.h +1 -0
- package/apple/RNGestureHandlerButton.h +1 -0
- package/apple/RNGestureHandlerButton.mm +24 -0
- package/apple/RNGestureHandlerButtonComponentView.mm +43 -0
- package/apple/RNGestureHandlerButtonManager.mm +24 -0
- package/apple/RNGestureHandlerPointerEvents.h +8 -0
- package/package.json +1 -1
package/apple/RNGestureHandler.h
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#import "RNGestureHandlerActionType.h"
|
|
3
3
|
#import "RNGestureHandlerDirection.h"
|
|
4
4
|
#import "RNGestureHandlerEvents.h"
|
|
5
|
+
#import "RNGestureHandlerPointerEvents.h"
|
|
5
6
|
#import "RNGestureHandlerPointerTracker.h"
|
|
6
7
|
#import "RNGestureHandlerPointerType.h"
|
|
7
8
|
#import "RNGestureHandlerState.h"
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
@property (nonatomic, assign) UIEdgeInsets hitTestEdgeInsets;
|
|
29
29
|
@property (nonatomic, assign) CGFloat borderRadius;
|
|
30
30
|
@property (nonatomic) BOOL userEnabled;
|
|
31
|
+
@property (nonatomic, assign) RNGestureHandlerPointerEvents pointerEvents;
|
|
31
32
|
|
|
32
33
|
#if TARGET_OS_OSX && RCT_NEW_ARCH_ENABLED
|
|
33
34
|
- (void)mountChildComponentView:(RNGHUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index;
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
if (self) {
|
|
51
51
|
_hitTestEdgeInsets = UIEdgeInsetsZero;
|
|
52
52
|
_userEnabled = YES;
|
|
53
|
+
_pointerEvents = RNGestureHandlerPointerEventsAuto;
|
|
53
54
|
#if !TARGET_OS_TV && !TARGET_OS_OSX
|
|
54
55
|
[self setExclusiveTouch:YES];
|
|
55
56
|
#endif
|
|
@@ -93,6 +94,29 @@
|
|
|
93
94
|
|
|
94
95
|
- (RNGHUIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
|
95
96
|
{
|
|
97
|
+
RNGestureHandlerPointerEvents pointerEvents = _pointerEvents;
|
|
98
|
+
|
|
99
|
+
if (pointerEvents == RNGestureHandlerPointerEventsNone) {
|
|
100
|
+
return nil;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (pointerEvents == RNGestureHandlerPointerEventsBoxNone) {
|
|
104
|
+
for (UIView *subview in [self.subviews reverseObjectEnumerator]) {
|
|
105
|
+
if (!subview.isHidden && subview.alpha > 0) {
|
|
106
|
+
CGPoint convertedPoint = [subview convertPoint:point fromView:self];
|
|
107
|
+
UIView *hitView = [subview hitTest:convertedPoint withEvent:event];
|
|
108
|
+
if (hitView != nil && [self shouldHandleTouch:hitView]) {
|
|
109
|
+
return hitView;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return nil;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (pointerEvents == RNGestureHandlerPointerEventsBoxOnly) {
|
|
117
|
+
return [self pointInside:point withEvent:event] ? self : nil;
|
|
118
|
+
}
|
|
119
|
+
|
|
96
120
|
RNGHUIView *inner = [super hitTest:point withEvent:event];
|
|
97
121
|
while (inner && ![self shouldHandleTouch:inner]) {
|
|
98
122
|
inner = inner.superview;
|
|
@@ -9,11 +9,27 @@
|
|
|
9
9
|
#import <react/renderer/components/rngesturehandler_codegen/EventEmitters.h>
|
|
10
10
|
#import <react/renderer/components/rngesturehandler_codegen/Props.h>
|
|
11
11
|
#import <react/renderer/components/rngesturehandler_codegen/RCTComponentViewHelpers.h>
|
|
12
|
+
#import <react/renderer/components/view/ViewProps.h>
|
|
12
13
|
|
|
13
14
|
#import "RNGestureHandlerButton.h"
|
|
14
15
|
|
|
15
16
|
using namespace facebook::react;
|
|
16
17
|
|
|
18
|
+
static RNGestureHandlerPointerEvents RCTPointerEventsToEnum(facebook::react::PointerEventsMode pointerEvents)
|
|
19
|
+
{
|
|
20
|
+
switch (pointerEvents) {
|
|
21
|
+
case facebook::react::PointerEventsMode::None:
|
|
22
|
+
return RNGestureHandlerPointerEventsNone;
|
|
23
|
+
case facebook::react::PointerEventsMode::BoxNone:
|
|
24
|
+
return RNGestureHandlerPointerEventsBoxNone;
|
|
25
|
+
case facebook::react::PointerEventsMode::BoxOnly:
|
|
26
|
+
return RNGestureHandlerPointerEventsBoxOnly;
|
|
27
|
+
case facebook::react::PointerEventsMode::Auto:
|
|
28
|
+
default:
|
|
29
|
+
return RNGestureHandlerPointerEventsAuto;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
17
33
|
@interface RNGestureHandlerButtonComponentView () <RCTRNGestureHandlerButtonViewProtocol>
|
|
18
34
|
@end
|
|
19
35
|
|
|
@@ -207,8 +223,35 @@ using namespace facebook::react;
|
|
|
207
223
|
_buttonView.hitTestEdgeInsets = UIEdgeInsetsMake(
|
|
208
224
|
-newProps.hitSlop.top, -newProps.hitSlop.left, -newProps.hitSlop.bottom, -newProps.hitSlop.right);
|
|
209
225
|
|
|
226
|
+
if (!oldProps) {
|
|
227
|
+
_buttonView.pointerEvents = RCTPointerEventsToEnum(newProps.pointerEvents);
|
|
228
|
+
} else {
|
|
229
|
+
const auto &oldButtonProps = *std::static_pointer_cast<const RNGestureHandlerButtonProps>(oldProps);
|
|
230
|
+
if (oldButtonProps.pointerEvents != newProps.pointerEvents) {
|
|
231
|
+
_buttonView.pointerEvents = RCTPointerEventsToEnum(newProps.pointerEvents);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
210
235
|
[super updateProps:props oldProps:oldProps];
|
|
211
236
|
}
|
|
237
|
+
|
|
238
|
+
#if !TARGET_OS_OSX
|
|
239
|
+
// Override hitTest to forward touches to _buttonView
|
|
240
|
+
// This is necessary because RCTViewComponentView's hitTest might handle pointerEvents
|
|
241
|
+
// from ViewProps and prevent touches from reaching _buttonView (which is the contentView).
|
|
242
|
+
// Since _buttonView has its own pointerEvents handling, we always forward to it.
|
|
243
|
+
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
|
244
|
+
{
|
|
245
|
+
if (![self pointInside:point withEvent:event]) {
|
|
246
|
+
return nil;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
CGPoint buttonPoint = [self convertPoint:point toView:_buttonView];
|
|
250
|
+
|
|
251
|
+
return [_buttonView hitTest:buttonPoint withEvent:event];
|
|
252
|
+
}
|
|
253
|
+
#endif
|
|
254
|
+
|
|
212
255
|
@end
|
|
213
256
|
|
|
214
257
|
Class<RCTComponentViewProtocol> RNGestureHandlerButtonCls(void)
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
#import "RNGestureHandlerButtonManager.h"
|
|
2
2
|
#import "RNGestureHandlerButton.h"
|
|
3
3
|
|
|
4
|
+
static RNGestureHandlerPointerEvents RCTPointerEventsToEnum(RCTPointerEvents pointerEvents)
|
|
5
|
+
{
|
|
6
|
+
switch (pointerEvents) {
|
|
7
|
+
case RCTPointerEventsNone:
|
|
8
|
+
return RNGestureHandlerPointerEventsNone;
|
|
9
|
+
case RCTPointerEventsBoxNone:
|
|
10
|
+
return RNGestureHandlerPointerEventsBoxNone;
|
|
11
|
+
case RCTPointerEventsBoxOnly:
|
|
12
|
+
return RNGestureHandlerPointerEventsBoxOnly;
|
|
13
|
+
default:
|
|
14
|
+
return RNGestureHandlerPointerEventsAuto;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
4
18
|
@implementation RNGestureHandlerButtonManager
|
|
5
19
|
|
|
6
20
|
RCT_EXPORT_MODULE(RNGestureHandlerButton)
|
|
@@ -28,6 +42,16 @@ RCT_CUSTOM_VIEW_PROPERTY(hitSlop, UIEdgeInsets, RNGestureHandlerButton)
|
|
|
28
42
|
}
|
|
29
43
|
}
|
|
30
44
|
|
|
45
|
+
RCT_CUSTOM_VIEW_PROPERTY(pointerEvents, RCTPointerEvents, RNGestureHandlerButton)
|
|
46
|
+
{
|
|
47
|
+
if (json) {
|
|
48
|
+
RCTPointerEvents pointerEvents = [RCTConvert RCTPointerEvents:json];
|
|
49
|
+
view.pointerEvents = RCTPointerEventsToEnum(pointerEvents);
|
|
50
|
+
} else {
|
|
51
|
+
view.pointerEvents = RNGestureHandlerPointerEventsAuto;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
31
55
|
- (RNGHUIView *)view
|
|
32
56
|
{
|
|
33
57
|
return (RNGHUIView *)[RNGestureHandlerButton new];
|
package/package.json
CHANGED