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

What is Framer? Join the Community
Return to index
Ed Nepomuceno
Posted Jun 26 - Read on Facebook

I'm trying to animate a layer to the position of a touch/click on another layer. How can I derive the coordinates of that last touch/click?

layerA.on(Events.TouchEnd, function(e){
var touchPos = e.touches[0].screenX;


Tisho Georgiev

You can use the clientX and clientY properties of the event object:

layerA.on(Events.TouchEnd, function(event) {
// this will normalize the event object, so that it has the same clientX and clientY properties, regardless of whether you're on mobile or desktop
event = Events.touchEvent(event);

var touchPos = event.clientX;
layerB.animate({ x: touchPos });

Read the entire post on Facebook