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:
Jakub Grzywacz
2024-08-19 09:11:07 +02:00
committed by GitHub
parent 7cf90f2f10
commit ca1c35caa9
13 changed files with 113 additions and 23 deletions
+1
View File
@@ -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.
+11 -1
View File
@@ -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