mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-05-06 13:07:36 +00:00
fix(ios): initial render foreignObject / re-render on mount of sub views
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
|
||||
#import "RNSVGGroup.h"
|
||||
#import "RNSVGLength.h"
|
||||
#import "RCTEventDispatcher.h"
|
||||
|
||||
@interface RNSVGForeignObject : RNSVGGroup
|
||||
|
||||
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher;
|
||||
@property (nonatomic, strong) RNSVGLength *x;
|
||||
@property (nonatomic, strong) RNSVGLength *y;
|
||||
@property (nonatomic, strong) RNSVGLength *foreignObjectwidth;
|
||||
|
||||
@@ -7,19 +7,45 @@
|
||||
*/
|
||||
#import "RNSVGForeignObject.h"
|
||||
#import "RNSVGNode.h"
|
||||
#import "RCTUIManager.h"
|
||||
#import "RCTUIManagerObserverCoordinator.h"
|
||||
|
||||
@implementation RNSVGForeignObject
|
||||
{
|
||||
RCTEventDispatcher *_eventDispatcher;
|
||||
bool _ready;
|
||||
}
|
||||
|
||||
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
|
||||
{
|
||||
RCTAssertParam(eventDispatcher);
|
||||
|
||||
if ((self = [super init])) {
|
||||
_eventDispatcher = eventDispatcher;
|
||||
[_eventDispatcher.bridge.uiManager.observerCoordinator addObserver:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)parseReference
|
||||
{
|
||||
self.dirty = false;
|
||||
}
|
||||
|
||||
- (void)uiManagerDidPerformMounting:(RCTUIManager *)manager
|
||||
{
|
||||
[manager addUIBlock:^(__unused RCTUIManager *uiManager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
if (!self->_ready && !self.dirty) {
|
||||
[self invalidate];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect
|
||||
{
|
||||
[self clip:context];
|
||||
|
||||
@@ -15,7 +15,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (RNSVGForeignObject *)node
|
||||
{
|
||||
return [RNSVGForeignObject new];
|
||||
return [[RNSVGForeignObject alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
|
||||
}
|
||||
|
||||
RCT_EXPORT_VIEW_PROPERTY(x, RNSVGLength*)
|
||||
|
||||
Reference in New Issue
Block a user