mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-20 05:55:10 +00:00
complete ClipPath refactor
This commit is contained in:
@@ -1,21 +1,11 @@
|
||||
import SerializablePath from 'react-native/Libraries/ART/ARTSerializablePath';
|
||||
import clipReg from './patternReg';
|
||||
|
||||
let clipPatterns = {};
|
||||
const clipRules = {
|
||||
evenodd: 0,
|
||||
nonzero: 1
|
||||
};
|
||||
|
||||
function set(id, pattern) {
|
||||
clipPatterns[id] = pattern;
|
||||
}
|
||||
|
||||
function remove(id) {
|
||||
delete clipPatterns[id];
|
||||
}
|
||||
|
||||
|
||||
export default function (props) {
|
||||
let {clipPath, clipRule} = props;
|
||||
let clippingProps = {};
|
||||
@@ -26,22 +16,11 @@ export default function (props) {
|
||||
let matched = clipPath.match(clipReg);
|
||||
|
||||
if (matched) {
|
||||
let patternName = `${matched[1]}:${props.svgId}`;
|
||||
let pattern = clipPatterns[patternName];
|
||||
if (pattern) {
|
||||
clippingProps.clipPathRef = pattern;
|
||||
} else {
|
||||
clippingProps = null;
|
||||
// TODO: warn
|
||||
}
|
||||
clippingProps.clipPathRef = matched[1];
|
||||
} else {
|
||||
clippingProps.clipPath = new SerializablePath(clipPath).toJSON();
|
||||
}
|
||||
}
|
||||
|
||||
return clippingProps;
|
||||
}
|
||||
|
||||
export {
|
||||
set,
|
||||
remove
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user