Last active
August 29, 2015 14:15
-
-
Save mrrocks/8bc1ce7c2070c69a650e to your computer and use it in GitHub Desktop.
Draggable layer with inertia and boundaries in FramerJS
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
ACCELERATION = 180 | |
INERTIA_CURVE = "spring(140, 30, 0, 0)" | |
Layer::inertia = -> | |
calculateFinalY = => | |
newY = @y + @draggable.calculateVelocity().y * ACCELERATION | |
switch | |
when newY > 0 then return 0 | |
when newY + @height < Framer.Device.screen.height then return -@height + Framer.Device.screen.height | |
else return newY | |
@animate | |
properties: y: calculateFinalY() | |
curve: INERTIA_CURVE | |
# layerName.on Events.DragEnd, -> @inertia() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment