mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-05-29 13:21:50 +00:00
fix(ios): invalidate G / foreignObject on change in native children
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
|
||||
@interface RNSVGForeignObject : RNSVGGroup
|
||||
|
||||
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher;
|
||||
@property (nonatomic, strong) RNSVGLength *x;
|
||||
@property (nonatomic, strong) RNSVGLength *y;
|
||||
@property (nonatomic, strong) RNSVGLength *foreignObjectwidth;
|
||||
|
||||
@@ -7,53 +7,19 @@
|
||||
*/
|
||||
#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 invalidate];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)renderChildTo:(CGContextRef)context rect:(CGRect)rect node:(UIView*)node
|
||||
{
|
||||
node.hidden = false;
|
||||
self->_ready = [node drawViewHierarchyInRect:rect afterScreenUpdates:true];
|
||||
[node.layer renderInContext:context];
|
||||
node.hidden = true;
|
||||
}
|
||||
|
||||
- (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect
|
||||
{
|
||||
[self clip:context];
|
||||
|
||||
@@ -72,7 +72,9 @@
|
||||
CGContextClipToRect(context, rect);
|
||||
[svgView drawToContext:context withRect:rect];
|
||||
} else {
|
||||
[self renderChildTo:context rect:rect node:node];
|
||||
node.hidden = false;
|
||||
[node.layer renderInContext:context];
|
||||
node.hidden = true;
|
||||
}
|
||||
|
||||
return YES;
|
||||
@@ -105,11 +107,9 @@
|
||||
[self popGlyphContext];
|
||||
}
|
||||
|
||||
- (void)renderChildTo:(CGContextRef)context rect:(CGRect)rect node:(UIView*)node
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
node.hidden = false;
|
||||
[node.layer renderInContext:context];
|
||||
node.hidden = true;
|
||||
[self invalidate];
|
||||
}
|
||||
|
||||
- (void)setupGlyphContext:(CGContextRef)context
|
||||
|
||||
@@ -15,7 +15,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (RNSVGForeignObject *)node
|
||||
{
|
||||
return [[RNSVGForeignObject alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
|
||||
return [RNSVGForeignObject new];
|
||||
}
|
||||
|
||||
RCT_EXPORT_VIEW_PROPERTY(x, RNSVGLength*)
|
||||
|
||||
Reference in New Issue
Block a user