mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-01 22:25:12 +00:00
feat: introduce hitSlop prop (#2407)
# Summary Explain the **motivation** for making this change: here are some points to help you: * What issues does the pull request solve? Please tag them so that they will get automatically closed once the PR is merged * What is the feature? (if applicable) * How did you implement the solution? * What areas of the library does it impact? ## Test Plan Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. ### What's required for testing (prerequisites)? ### What are the steps to reproduce (after prerequisites)? ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ✅ | | MacOS | ✅❌ | | Android | ✅ | | Web | ✅❌ |
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
@property (nonatomic, assign) CGAffineTransform initialCTM;
|
||||
@property (nonatomic, assign) CGAffineTransform invInitialCTM;
|
||||
@property (nonatomic, assign) CGAffineTransform viewBoxTransform;
|
||||
@property (nonatomic, assign) UIEdgeInsets hitTestEdgeInsets;
|
||||
|
||||
/**
|
||||
* define <ClipPath></ClipPath> content as clipPath template.
|
||||
|
||||
@@ -317,6 +317,15 @@ using namespace facebook::react;
|
||||
[self drawToContext:context withRect:[self bounds]];
|
||||
}
|
||||
|
||||
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
|
||||
{
|
||||
if (UIEdgeInsetsEqualToEdgeInsets(self.hitTestEdgeInsets, UIEdgeInsetsZero)) {
|
||||
return [super pointInside:point withEvent:event];
|
||||
}
|
||||
CGRect hitFrame = UIEdgeInsetsInsetRect(self.bounds, self.hitTestEdgeInsets);
|
||||
return CGRectContainsPoint(hitFrame, point);
|
||||
}
|
||||
|
||||
- (RNSVGPlatformView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
||||
{
|
||||
CGPoint transformed = point;
|
||||
@@ -339,7 +348,8 @@ using namespace facebook::react;
|
||||
return (node.responsible || (node != hitChild)) ? hitChild : self;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
BOOL isPointInside = [self pointInside:point withEvent:event];
|
||||
return isPointInside ? self : nil;
|
||||
}
|
||||
|
||||
- (NSString *)getDataURLWithBounds:(CGRect)bounds
|
||||
|
||||
Reference in New Issue
Block a user