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

What is Framer? Join the Community
Return to index
Delphia Pijpler
Posted Aug 03 - Read on Facebook

What is the framerJS method to know if a finger is being held down anywhere on the screen? Like a scroll event, but just for the finger touching the screen.

8 Comments

Joshua Miller

# Detect a long press
layer.on Events.LongPress, (event) ->
print "Long press"

docs here: https://framer.com/docs/
under "LongPress Events"

Delphia Pijpler

can you do this to the whole screen, instead of a layer?

Delphia Pijpler

basically, if the finger is held down in the top 3rd I want to trigger one thing, and in the bottom third, another

Delphia Pijpler

Joshua Miller I was hoping it could be done with Canvas:
```
Canvas.backgroundColor = "#28affa"
Canvas.onLongPress ->
print 'pressing'
```
but doesn't appear to work

Delphia Pijpler

Also, i'm looking for an event that continuously triggers, while the finger is down, not just a one time trigger.

Ian McClure

Layer.on Events.touchStart(Events, Layer)
Layer.on Events.touchMoved(Events, Layer)
Layer.on Events.touchEnd(Events, Layer)
I think there are what you are looking for. touchStart fires when you put your finger down. touchMoved fires when you move your finger. touchEnd fires when you lift your finger.

You can create an invisible layer that covers the screen to act as a handler for touches

Delphia Pijpler

My current solution is to start an interval during "layerA.onMouseDown ->" but then how would i cancel it?

Ian McClure

If you assign your interval to a variable you can the interval.invalidate()

myInterval = utils.interval 60 ->
//Do Stuff

layerA.onMouseUp ->
myInterval.invalidate()

Read the entire post on Facebook