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

What is Framer? Join the Community
Return to index
Ola Laurin
Posted Nov 12 - Read on Facebook

Hello everyone! I've been trying to get a way to retrieve the x and y values of a click event (something like getCursorPosition). I thought I was on the right track for a while but as this video shows it's clearly not. Does anyone know:

1) A way to retrieve those values?
2) What's going on with the values in the attached video?


Ed Chao

the standard values are wonky because it doesn't take into account the scale and offset of your device. But this should work:

myLayer.on Events.Click, (event) ->
print event.offsetX

Ola Laurin

That worked. Thanks Ed!

Ola Laurin

Any idea why it's only working on desktop, Ed?

Ed Chao

Ola Laurin same reason as above, except in the case of emulating on an actual phone, it's the opposite since there is no offset. :P

So, event.offsetX is the value you use when viewing it in Framer Studio's Device, and event.clientX is what you use if you want to actually play with it on a real device.

Ola Laurin

Gotcha! Thanks a bunch!

Johannes Eckert

Ed Chao's answer should be documented somehwere, very helpful!

Read the entire post on Facebook