mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-04 23:54:53 +00:00
[ios] Improve native animated & svg transform interactions with gestures
This commit is contained in:
@@ -77,11 +77,10 @@
|
||||
CGAffineTransform matrix = self.matrix;
|
||||
CGPoint mid = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
|
||||
CGPoint center = CGPointApplyAffineTransform(mid, matrix);
|
||||
CGRect frame = CGRectApplyAffineTransform(bounds, matrix);
|
||||
|
||||
self.bounds = bounds;
|
||||
self.center = center;
|
||||
self.frame = frame;
|
||||
self.frame = bounds;
|
||||
|
||||
[self popGlyphContext];
|
||||
}
|
||||
@@ -89,7 +88,8 @@
|
||||
- (void)setupGlyphContext:(CGContextRef)context
|
||||
{
|
||||
CGRect clipBounds = CGContextGetClipBoundingBox(context);
|
||||
clipBounds = CGRectApplyAffineTransform(clipBounds, self.transform);
|
||||
clipBounds = CGRectApplyAffineTransform(clipBounds, self.matrix);
|
||||
clipBounds = CGRectApplyAffineTransform(clipBounds, self.transforms);
|
||||
CGFloat width = CGRectGetWidth(clipBounds);
|
||||
CGFloat height = CGRectGetHeight(clipBounds);
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
CGMutablePathRef __block path = CGPathCreateMutable();
|
||||
[self traverseSubviews:^(RNSVGNode *node) {
|
||||
if ([node isKindOfClass:[RNSVGNode class]]) {
|
||||
CGAffineTransform transform = node.transform;
|
||||
CGAffineTransform transform = CGAffineTransformConcat(node.matrix, node.transforms);
|
||||
CGPathAddPath(path, &transform, [node getPath:context]);
|
||||
}
|
||||
return YES;
|
||||
|
||||
@@ -166,7 +166,6 @@ CGFloat const RNSVG_DEFAULT_FONT_SIZE = 12;
|
||||
}
|
||||
_matrix = matrix;
|
||||
_invmatrix = CGAffineTransformInvert(matrix);
|
||||
self.transform = CGAffineTransformConcat(matrix, self.transforms);
|
||||
id<RNSVGContainer> container = (id<RNSVGContainer>)self.superview;
|
||||
[container invalidate];
|
||||
}
|
||||
|
||||
+10
-11
@@ -168,7 +168,8 @@ UInt32 saturate(CGFloat value) {
|
||||
{
|
||||
// This needs to be painted on a layer before being composited.
|
||||
CGContextSaveGState(context);
|
||||
CGContextConcatCTM(context, self.transform);
|
||||
CGContextConcatCTM(context, self.matrix);
|
||||
CGContextConcatCTM(context, self.transforms);
|
||||
CGContextSetAlpha(context, self.opacity);
|
||||
|
||||
[self beginTransparencyLayer:context];
|
||||
@@ -296,24 +297,22 @@ UInt32 saturate(CGFloat value) {
|
||||
|
||||
const CGRect pathBounding = CGPathGetBoundingBox(self.path);
|
||||
|
||||
const CGAffineTransform current = CGContextGetCTM(context);
|
||||
const CGAffineTransform svgToClientTransform = CGAffineTransformConcat(current, self.svgView.invInitialCTM);
|
||||
const CGRect clientRect = CGRectApplyAffineTransform(pathBounding, svgToClientTransform);
|
||||
CGAffineTransform current = CGContextGetCTM(context);
|
||||
CGAffineTransform svgToClientTransform = CGAffineTransformConcat(current, self.svgView.invInitialCTM);
|
||||
CGRect clientRect = CGRectApplyAffineTransform(pathBounding, svgToClientTransform);
|
||||
|
||||
self.clientRect = clientRect;
|
||||
|
||||
const CGAffineTransform vbmatrix = self.svgView.getViewBoxTransform;
|
||||
const CGAffineTransform matrix = CGAffineTransformConcat(self.transform, vbmatrix);
|
||||
CGAffineTransform vbmatrix = self.svgView.getViewBoxTransform;
|
||||
CGAffineTransform matrix = CGAffineTransformConcat(self.matrix, vbmatrix);
|
||||
|
||||
const CGRect bounds = CGRectMake(0, 0, CGRectGetWidth(clientRect), CGRectGetHeight(clientRect));
|
||||
const CGPoint mid = CGPointMake(CGRectGetMidX(pathBounding), CGRectGetMidY(pathBounding));
|
||||
CGRect bounds = CGRectMake(0, 0, CGRectGetWidth(clientRect), CGRectGetHeight(clientRect));
|
||||
CGPoint mid = CGPointMake(CGRectGetMidX(pathBounding), CGRectGetMidY(pathBounding));
|
||||
CGPoint center = CGPointApplyAffineTransform(mid, matrix);
|
||||
|
||||
const CGRect frame = CGRectApplyAffineTransform(pathBounding, matrix);
|
||||
|
||||
self.bounds = bounds;
|
||||
self.center = center;
|
||||
self.frame = frame;
|
||||
self.frame = clientRect;
|
||||
|
||||
CGPathDrawingMode mode = kCGPathStroke;
|
||||
BOOL fillColor = NO;
|
||||
|
||||
@@ -160,7 +160,6 @@ RCT_CUSTOM_VIEW_PROPERTY(transform, CATransform3D, RNSVGNode)
|
||||
CGAffineTransform transform = CATransform3DGetAffineTransform(transform3d);
|
||||
view.invTransform = CGAffineTransformInvert(transform);
|
||||
view.transforms = transform;
|
||||
view.transform = CGAffineTransformConcat(view.matrix, transform);
|
||||
[view invalidate];
|
||||
}
|
||||
RCT_EXPORT_VIEW_PROPERTY(mask, NSString)
|
||||
|
||||
Reference in New Issue
Block a user