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

What is Framer? Join the Community
Return to index
Johannes Eckert
Posted May 29 - Read on Facebook

Today I wanted to find an easy fix for the absolute point position, which has been discussed a couple of times, but I cannot find the solutions people posted.

I was able to easily calculate the absolute pointer position by subtracting Framer.Device.screen.screenScaledFrame().x and then dividing by Framer.Device.screen.canvasScaleX().

So far the results are satisfying: http://share.framerjs.com/d4r932kftiro/

However, I have two problems:

1) When adding another layer from sketch, my values are suddenly off: http://share.framerjs.com/e4ur7llzg02r/ (see the comparison between box.screenScaledFrame() and event.client

2) in the print output above you see Framer.Device.screen.screenscaledFrame() and an imported layer that has the same size as the screen, however, sketch.background.screenScaledFrame() still reports the un-scaled with and height. Is screenScaledFrame() supposed to only work on Framer.Device.screen?

Is there a bug that causes the values to be off, Koen Bok?
What do you think of adding a snippet or a blob in the docs about calculating the absolute pointer position for events Benjamin Den Boer?

2 Comments

Tisho Georgiev

Can't take a deeper look at the potential screenScaledFrame bug right now, but this is what I've used before for getting the absolute position of the pointer: https://github.com/tisho/framer-hints/blob/master/src/framer-hints.coffee#L82. See if it works for you.

Johannes Eckert

that is helpful. I think we get the same result, just approaching it with different math. Maybe one of us has more rounding errors ,)

Read the entire post on Facebook