mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-20 22:05:14 +00:00
clipPathId => clipPathRef
This commit is contained in:
@@ -87,16 +87,16 @@ public class RNSVGSvgViewShadowNode extends LayoutShadowNode {
|
||||
return viewTag;
|
||||
}
|
||||
|
||||
public void defineClipPath(Path clipPath, String clipPathId) {
|
||||
mDefinedClipPaths.put(clipPathId, clipPath);
|
||||
public void defineClipPath(Path clipPath, String clipPathRef) {
|
||||
mDefinedClipPaths.put(clipPathRef, clipPath);
|
||||
}
|
||||
|
||||
// TODO: remove unmounted clipPath
|
||||
public void removeClipPath(String clipPathId) {
|
||||
mDefinedClipPaths.remove(clipPathId);
|
||||
public void removeClipPath(String clipPathRef) {
|
||||
mDefinedClipPaths.remove(clipPathRef);
|
||||
}
|
||||
|
||||
public Path getDefinedClipPath(String clipPathId) {
|
||||
return mDefinedClipPaths.get(clipPathId);
|
||||
public Path getDefinedClipPath(String clipPathRef) {
|
||||
return mDefinedClipPaths.get(clipPathRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,9 +111,9 @@ public abstract class RNSVGVirtualNode extends LayoutShadowNode {
|
||||
markUpdated();
|
||||
}
|
||||
|
||||
@ReactProp(name = "clipPathId")
|
||||
public void setClipPathId(String clipPathId) {
|
||||
mClipPathId = clipPathId;
|
||||
@ReactProp(name = "clipPathRef")
|
||||
public void setClipPathId(String clipPathRef) {
|
||||
mClipPathId = clipPathRef;
|
||||
markUpdated();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
- (void)renderLayerTo:(CGContextRef)context
|
||||
{
|
||||
[[self getSvgView] defineClipPath:[self getPath:context] clipPathId:self.name];
|
||||
[[self getSvgView] defineClipPath:[self getPath:context] clipPathRef:self.name];
|
||||
}
|
||||
|
||||
// hitTest delagate
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
/**
|
||||
* define <ClipPath></ClipPath> content as clipPath template.
|
||||
*/
|
||||
- (void)defineClipPath:(CGPathRef)clipPath clipPathId:(NSString *)clipPathId;
|
||||
- (void)defineClipPath:(CGPathRef)clipPath clipPathRef:(NSString *)clipPathId;
|
||||
|
||||
- (void)removeClipPath:(NSString *)clipPathId;
|
||||
- (void)removeClipPath:(NSString *)clipPathRef;
|
||||
|
||||
- (CGPathRef)getDefinedClipPath:(NSString *)clipPathId;
|
||||
- (CGPathRef)getDefinedClipPath:(NSString *)clipPathRef;
|
||||
|
||||
@end
|
||||
|
||||
@@ -62,24 +62,24 @@
|
||||
return self.responsible ? [super hitTest:point withEvent:event] : nil;
|
||||
}
|
||||
|
||||
- (void)defineClipPath:(CGPathRef)clipPath clipPathId:(NSString *)clipPathId
|
||||
- (void)defineClipPath:(CGPathRef)clipPath clipPathRef:(NSString *)clipPathRef
|
||||
{
|
||||
if (clipPaths == NULL) {
|
||||
clipPaths = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
[clipPaths setValue:[NSValue valueWithPointer:clipPath] forKey:clipPathId];
|
||||
[clipPaths setValue:[NSValue valueWithPointer:clipPath] forKey:clipPathRef];
|
||||
}
|
||||
|
||||
- (void)removeClipPath:(NSString *)clipPathId
|
||||
- (void)removeClipPath:(NSString *)clipPathRef
|
||||
{
|
||||
if (clipPaths != NULL) {
|
||||
[clipPaths removeObjectForKey:clipPathId];
|
||||
[clipPaths removeObjectForKey:clipPathRef];
|
||||
}
|
||||
}
|
||||
|
||||
- (CGPathRef)getDefinedClipPath:(NSString *)clipPathId
|
||||
- (CGPathRef)getDefinedClipPath:(NSString *)clipPathRef
|
||||
{
|
||||
return [[clipPaths valueForKey:clipPathId] pointerValue];
|
||||
return [[clipPaths valueForKey:clipPathRef] pointerValue];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
@property (nonatomic, assign) CGFloat opacity;
|
||||
@property (nonatomic, assign) RNSVGCGFCRule clipRule;
|
||||
@property (nonatomic, assign) CGPathRef clipPath; // convert clipPath="M0,0 L0,10 L10,10z" into path
|
||||
@property (nonatomic, strong) NSString *clipPathId; // use clipPath="url(#clip)" as ClipPath
|
||||
@property (nonatomic, strong) NSString *clipPathRef; // use clipPath="url(#clip)" as ClipPath
|
||||
@property (nonatomic, assign) BOOL responsible;
|
||||
|
||||
- (void)invalidate;
|
||||
|
||||
@@ -100,8 +100,8 @@
|
||||
|
||||
if (self.clipPath) {
|
||||
clipPath = self.clipPath;
|
||||
} else if (self.clipPathId) {
|
||||
clipPath = [[self getSvgView] getDefinedClipPath:self.clipPathId];
|
||||
} else if (self.clipPathRef) {
|
||||
clipPath = [[self getSvgView] getDefinedClipPath:self.clipPathRef];
|
||||
}
|
||||
|
||||
return clipPath;
|
||||
|
||||
@@ -31,7 +31,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
RCT_EXPORT_VIEW_PROPERTY(opacity, CGFloat)
|
||||
RCT_EXPORT_VIEW_PROPERTY(trans, CGAffineTransform)
|
||||
RCT_EXPORT_VIEW_PROPERTY(clipPathId, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(clipPathRef, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(responsible, BOOL)
|
||||
|
||||
@end
|
||||
|
||||
@@ -46,7 +46,7 @@ const NodeAttributes = {
|
||||
diff: arrayDiffer
|
||||
},
|
||||
opacity: true,
|
||||
clipPathId: true,
|
||||
clipPathRef: true,
|
||||
responsible: true
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ export default function (props) {
|
||||
let patternName = `${matched[1]}:${props.svgId}`;
|
||||
let pattern = clipPatterns[patternName];
|
||||
if (pattern) {
|
||||
clippingProps.clipPathId = pattern;
|
||||
clippingProps.clipPathRef = pattern;
|
||||
} else {
|
||||
clippingProps = null;
|
||||
// TODO: warn
|
||||
|
||||
Reference in New Issue
Block a user