react-native-svg-parser icon indicating copy to clipboard operation
react-native-svg-parser copied to clipboard

onPress handler on nodes

Open egunsoma opened this issue 7 years ago • 3 comments

Can I somehow attach onPress handlers to the svg tags? I want to change the color of the objects when the user touches it. (Some kind of coloring book). Is this possible?

egunsoma avatar Apr 02 '18 11:04 egunsoma

Currently not possible, but I will take a PR if you want to add it!

a-r-d avatar Apr 05 '18 04:04 a-r-d

I managed to solve it by traversing the parsed svgNode once. Since it's not change heavy component, this won't effect the performance of the rendering.

I'll see if I can come up with a solution for that. A good approach would be to add an extra config object, where you can specify several Predicate and Prop pairs, and if the Predicate returns truthy, the prop will be set for the given SVG node.

@a-r-d what do you think?

egunsoma avatar Apr 05 '18 09:04 egunsoma

@egunsoma yes please make a PR

a-r-d avatar Aug 22 '18 16:08 a-r-d