mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-06 00:12:21 +00:00
feat: implement mask-type property (#2152)
# Summary "mask-type: alpha" is not supported. resolve issue: #1790 ## Explanation svg example: ``` <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100" fill="none"> <g clip-path="url(#clip0_8_3)"> <rect width="100" height="100" fill="white"/> <mask id="mask0_8_3" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="100" height="100"> <circle cx="50" cy="50" r="50" fill="#000000"/> </mask> <g mask="url(#mask0_8_3)"> <rect x="-26" y="-78" width="209" height="263" fill="#252E74"/> </g> </g> <defs> <clipPath id="clip0_8_3"> <rect width="100" height="100" fill="white"/> </clipPath> </defs> </svg> ``` Current behavior:  Expected behavior:  ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ✅ | | Android | ✅ | ## Checklist <!-- Check completed item, when applicable, via: [X] --> - [x] I have tested this on a device and a simulator - [ ] I added documentation in `README.md` - [x] I updated the typed files (typescript) - [ ] I added a test for the API in the `__tests__` folder --------- Co-authored-by: Sergey <s.yurkevich@logiclike.com> Co-authored-by: Jakub Grzywacz <jakub.grzywacz@swmansion.com>
This commit is contained in:
@@ -62,6 +62,7 @@ using namespace facebook::react;
|
||||
|
||||
self.maskUnits = newProps.maskUnits == 0 ? kRNSVGUnitsObjectBoundingBox : kRNSVGUnitsUserSpaceOnUse;
|
||||
self.maskContentUnits = newProps.maskUnits == 0 ? kRNSVGUnitsObjectBoundingBox : kRNSVGUnitsUserSpaceOnUse;
|
||||
self.maskType = newProps.maskType == 0 ? kRNSVGMaskTypeLuminance : kRNSVGMaskTypeAlpha;
|
||||
|
||||
setCommonGroupProps(newProps, self);
|
||||
_props = std::static_pointer_cast<RNSVGMaskProps const>(props);
|
||||
@@ -76,6 +77,7 @@ using namespace facebook::react;
|
||||
_maskwidth = nil;
|
||||
_maskUnits = kRNSVGUnitsObjectBoundingBox;
|
||||
_maskContentUnits = kRNSVGUnitsObjectBoundingBox;
|
||||
_maskType = kRNSVGMaskTypeLuminance;
|
||||
}
|
||||
#endif // RCT_NEW_ARCH_ENABLED
|
||||
|
||||
@@ -150,6 +152,15 @@ using namespace facebook::react;
|
||||
[self invalidate];
|
||||
}
|
||||
|
||||
- (void)setMaskType:(RNSVGMaskType)maskType
|
||||
{
|
||||
if (maskType == _maskType) {
|
||||
return;
|
||||
}
|
||||
_maskType = maskType;
|
||||
[self invalidate];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#ifdef RCT_NEW_ARCH_ENABLED
|
||||
|
||||
Reference in New Issue
Block a user