target / react-native-svg-parser

Parses SVG files and converts to 'react-native-svg' format objects. NOTE: This project has been archived.
MIT License
42 stars 16 forks source link

onPress handler on nodes #7

Open egunsoma opened 6 years ago

egunsoma commented 6 years ago

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?

a-r-d commented 6 years ago

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

egunsoma commented 6 years ago

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?

a-r-d commented 6 years ago

@egunsoma yes please make a PR