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

What is Framer? Join the Community
Return to index
Ed Chao
Posted Oct 08 - Read on Facebook

anyone notice that hammerJS events seem off after the update? For some reason event.gesture.center.clientX returns a value that is a few pixels more than the actual.

14 Comments

Jordan Robert Dobson

Zooming?

Ed Chao

doesnt seem to fix it.

Koen Bok

Is there a difference between full screen and with device? Could I see an example to investigate?

Josh Puckett

This is why I roll my own gesture recognizers :)

Koen Bok
Johannes Eckert

need. this. for. framer.

Josh Puckett

Koen: I have shared some! Need to refactor and share some more. https://gist.github.com/joshpuckett/9216195

Koen Bok

Hey Ed (and others running into this). What is happening here is that hammer (or actually any event) gives you back the exact location on the screen in pixels. But because we draw a device that is centered and scaled we have to account for that and correct the actual position.

I'm working on a new layer.draggable that should be finished soon that has this built in with event.deviceX, event.deviceX. And a lot more cool stuff. I'll also add a method layer.scaledScreenFrame that allows you to easily calculate this for every layer.

But until then you can use this example project to calculate it yourself. Let me know if that makes it clear.

http://cl.ly/2D3e1Q3o473Z

Ed Chao

this is great, thanks Koen

Johannes Eckert

could you consider making the deviceX and Y the default? When you lay out your views in a device, all you do is working inside that device frame anways, right? Or am I not understanding what's going on here?

Koen Bok

Last thing I'll have to account for is rotation, but I'll add that too.

Koen Bok

Johannes maybe you are right. But often with js frameworks you add rather than override/change to avoid confusion. I'll think about it.

Arlo Jamrog

Yes, same thing I was looking for- thanks for posting the correction example.

Read the entire post on Facebook