Julien Fouilhé
Julien Fouilhé

Reputation: 2658

How to get the dimensions and position of Native elements in React Native

I am using a framework called react-native-svg to draw SVG elements in a react native view.

My goal is that when I tap on the view (I use a PanResponder on the global view to get that), the element that is the closest to the tap changes.

I have everything that I need, except one thing: I need to be able to know the position of my svg elements, as well as their size, in order to find the one that was the closest to the tap event.

Now, I've tried most of the things available I'd say:

So I was wondering if there was any other solution or if I was doomed. :) Do I have to change something in react-native-svg that would allow me to find these values or is there any solution ready for me?

Thanks!

Upvotes: 5

Views: 1573

Answers (1)

Julien Fouilhé
Julien Fouilhé

Reputation: 2658

I finally had to add some functionalities to react-native-svg so I could get the size of the different elements.

It's not very well done, but I may come back to it for a cleaner solution and submit a PR then.

Thanks.

Upvotes: 1

Related Questions