mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-08 09:10:44 +00:00
fix(ios): #1290 pointerEvents="none" gesture handling
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#import <React/UIView+React.h>
|
||||
#import <React/RCTPointerEvents.h>
|
||||
#import "RNSVGCGFCRule.h"
|
||||
#import "RNSVGSvgView.h"
|
||||
@class RNSVGGroup;
|
||||
@@ -35,7 +36,13 @@ extern CGFloat const RNSVG_DEFAULT_FONT_SIZE;
|
||||
@property (nonatomic, strong) NSString *markerStart;
|
||||
@property (nonatomic, strong) NSString *markerMid;
|
||||
@property (nonatomic, strong) NSString *markerEnd;
|
||||
|
||||
/**
|
||||
* Used to control how touch events are processed.
|
||||
*/
|
||||
@property (nonatomic, assign) RCTPointerEvents pointerEvents;
|
||||
@property (nonatomic, assign) BOOL responsible;
|
||||
|
||||
@property (nonatomic, assign) CGAffineTransform ctm;
|
||||
@property (nonatomic, assign) CGAffineTransform screenCTM;
|
||||
@property (nonatomic, assign) CGAffineTransform matrix;
|
||||
|
||||
@@ -165,6 +165,15 @@ CGFloat const RNSVG_DEFAULT_FONT_SIZE = 12;
|
||||
self.backgroundColor = inheritedBackgroundColor;
|
||||
}
|
||||
|
||||
- (void)setPointerEvents:(RCTPointerEvents)pointerEvents
|
||||
{
|
||||
_pointerEvents = pointerEvents;
|
||||
self.userInteractionEnabled = (pointerEvents != RCTPointerEventsNone);
|
||||
if (pointerEvents == RCTPointerEventsBoxNone) {
|
||||
self.accessibilityViewIsModal = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setName:(NSString *)name
|
||||
{
|
||||
if ([name isEqualToString:_name]) {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <React/RCTPointerEvents.h>
|
||||
#import "RNSVGRenderable.h"
|
||||
#import "RNSVGClipPath.h"
|
||||
#import "RNSVGMask.h"
|
||||
@@ -518,7 +519,7 @@ UInt32 saturate(CGFloat value) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
BOOL canReceiveTouchEvents = (([self isUserInteractionEnabled] || self.responsible) && ![self isHidden]);
|
||||
BOOL canReceiveTouchEvents = (self.pointerEvents != RCTPointerEventsNone && ![self isHidden]);
|
||||
if(!canReceiveTouchEvents) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -238,28 +238,7 @@ RCT_CUSTOM_SHADOW_PROPERTY(direction, id, RNSVGNode) {}
|
||||
|
||||
RCT_CUSTOM_VIEW_PROPERTY(pointerEvents, RCTPointerEvents, RNSVGNode)
|
||||
{
|
||||
if (!json) {
|
||||
view.userInteractionEnabled = defaultView.userInteractionEnabled;
|
||||
return;
|
||||
}
|
||||
|
||||
switch ([RCTConvert RCTPointerEvents:json]) {
|
||||
case RCTPointerEventsBoxNone:
|
||||
case RCTPointerEventsBoxOnly:
|
||||
case RCTPointerEventsUnspecified:
|
||||
// Pointer events "unspecified" acts as if a stylesheet had not specified,
|
||||
// which is different than "auto" in CSS (which cannot and will not be
|
||||
// supported in `React`. "auto" may override a parent's "none".
|
||||
// Unspecified values do not.
|
||||
// This wouldn't override a container view's `userInteractionEnabled = NO`
|
||||
view.userInteractionEnabled = YES;
|
||||
break;
|
||||
case RCTPointerEventsNone:
|
||||
view.userInteractionEnabled = NO;
|
||||
break;
|
||||
default:
|
||||
view.userInteractionEnabled = NO;
|
||||
RCTLogError(@"UIView base class does not support pointerEvent value: %@", json);
|
||||
}
|
||||
view.pointerEvents = json ? [RCTConvert RCTPointerEvents:json] : defaultView.pointerEvents;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user