Last active
April 10, 2018 04:27
-
-
Save kysely/1d3053c8daf8c3eee0f51d26cb929c70 to your computer and use it in GitHub Desktop.
Alternative to MouseOver event that works on touch devices in Framer prototypes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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