Skip to content

Instantly share code, notes, and snippets.

@psql
Created July 18, 2017 21:39
Show Gist options
  • Save psql/d9e0d773beafae2da3681ddcab36a9fc to your computer and use it in GitHub Desktop.
Save psql/d9e0d773beafae2da3681ddcab36a9fc to your computer and use it in GitHub Desktop.
Accumulative Delta
gesture = new Layer
height: Screen.height
width: Screen.width
resetX = 400
jiggler = new Layer
x: resetX
y: 527
height: 128
jigglerClamped = new Layer
x: resetX
y: 842
height: 128
gesture.onPan (event)->
offset = jiggler.x + event.delta.x
jiggler.x = offset
jigglerClamped.x =
jigglerClamped.x + Utils.modulate(event.delta.x,[-Screen.width,Screen.width],[-200,200],true)
# Reset
gesture.onPanEnd ->
jiggler.animate
properties:
x: resetX
time: 0.2
jigglerClamped.animate
properties:
x: resetX
time: 0.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment