This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Arved Baumgärtner
Posted Nov 22 - Read on Facebook

Hey Framers,

I'm having trouble to detect the touch coordinates of a click event on Framer Studio, as well as through Framers mirroring. For some reason the position where the event gets triggered is displayed totally wrong. Is there somehow a simpler way to do this?

16 Comments

Dennis Kerzig

This Module is doing the job you are looking for (http://jrdn.io/cEnw). I've added this to your example and now everything works as expected :)
http://share.framerjs.com/g1sr6mjmvzog/

Dennis Kerzig

Actually all the code you need is:

Jordan Robert Dobson

True. Depends on which position you want. You either want screen location or offset location.

Arved Baumgärtner

Thanks a lot Dennis Kerzig

Jordan Robert Dobson

Thanks for sharing out my code Dennis

Koen Bok

If you need the exact position on the entire screen (incl device) you can do layer.canvasFrame.

James Muirhead

This works just fine for normal, static layers, but none of the above seems to work if what I'm clicking on is a nested ScrollComponent. The cursor click position is then not calculated properly. How can I determine the absolute position of a click/touch event no matter which nested layer I happen to click/touch?

Jordan Robert Dobson

You'd have to convert the point to screen point. Subtract the y value of scroller.content and you should be good.

James Muirhead

Let me try that. Thanks!

Jordan Robert Dobson

Let me know if you have troubles. A code example would be good.

James Muirhead

It's not just the Y value that is off, also the X values. Here is an example.http://share.framerjs.com/ktwzyntmmbj0/

James Muirhead

It uses the Pointer module above.

James Muirhead

I think I could solve this without any special module if I knew how to convert the event.offset values to screen or canvas values.

James Muirhead

The event.offset value is based on the nested layer(s) and not on the layer that has the Click/Touch handler set.

James Muirhead

At least in the case of layers inside a ScrollComponent and possibly for inside a PageComponent as well.

James Muirhead

Actually, the above works great when viewing on an actual device as the screen size equals the Framer object size.

Read the entire post on Facebook