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

What is Framer? Join the Community
Return to index
Peter Ng
Posted Dec 26 - Read on Facebook

Any advice on disambig between a touchstart and dragstart? Essentially canceling the touchStart and touchEnd events when a dragstart begins?


Min-Sang Choi

Basically i check the delta value by logging x pos(y pos) on TouchStart and TouchEnd. If delta value is lower than n pixel, it's a touch, otherwise it's drag.

Jordan Robert Dobson

^ yes this. I've been working on a sideways pivot VS list control and that's how I did it as well.

Ed Chao

koen bok has an example project somewhere here that demos this.

John Anthony Evans

You also have dragStart vs. touchStart. I think you can tie your behaviors to the relevant one and they won't collide with each other.

Junu Joseph Yang

Hi, I'm trying to log a variable on TouchStart and then get the difference on TouchEnd. Do you know why I get this error? Is this a variable scope issue?

'ReferenceError: Can't find variable: ystart'?


layerB.on Events.TouchStart, ->
ystart = layerB.y

layerB.on Events.TouchEnd, ->
if layerB.y > 0
Diffy = layerB.y - ystart
print "Diffy" + Diffy

Min-Sang Choi

you have to declare ystart first. put something like this above Event codeblock. "ystart = 0"

Junu Joseph Yang

Oh that works! Thank you!!

Peter Ng

More lines than i wanted but thanks for the advice guys. I tried using calculatevelocity but that obviously didn't give me what i wanted and then tried watching for change:x on the drag panel but then that was limiting also so i went back to what was suggested. Here it is:

containerStart = 0
numpadContainer.on Events.TouchStart, ->
containerStart = numpadContainer.x

numpadContainer.on Events.DragMove, ->
containerEnd = numpadContainer.x
xDelta = Math.abs(containerEnd - containerStart)
disambig = if xDelta > 15 then "drag" else "touch"

Peter Ng

John Anthony Evans yea couldn't dragstart vs touchstart because of the nature of the button firing on touchEnd, so i need to tell touchEnd not to fire if dragStart/Move occurs

Jordan Robert Dobson

I would also suggest deactivating the touch action as soon as a drag is qualified.

Read the entire post on Facebook