Skip to content

Instantly share code, notes, and snippets.

@kysely
Last active April 10, 2018 04:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kysely/1d3053c8daf8c3eee0f51d26cb929c70 to your computer and use it in GitHub Desktop.
Save kysely/1d3053c8daf8c3eee0f51d26cb929c70 to your computer and use it in GitHub Desktop.
Alternative to MouseOver event that works on touch devices in Framer prototypes
Layer::isTouchOver = ( touchPoint = {x: 0, y: 0} ) ->
touchX = touchPoint.x
touchY = touchPoint.y
if touchX < @screenFrame.x || touchX > (@screenFrame.x+@width) || touchY < @screenFrame.y || touchY > (@screenFrame.y+@height)
false
else
true
# Listen to ›Pan‹ event on some parent and
# provide ›event.touchCenter‹ object as the argument
parentLayer.on Events.Pan, (event, layer) ->
if layer.isTouchOver(event.touchCenter)
print 'Stop it, I\'m ticklish'
else
print 'Layer is missing your touch'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment