Skip to content

Instantly share code, notes, and snippets.

@xcoderzach
Created July 21, 2014 20:11
Show Gist options
  • Save xcoderzach/26cf445e055fbd490e5b to your computer and use it in GitHub Desktop.
Save xcoderzach/26cf445e055fbd490e5b to your computer and use it in GitHub Desktop.
simulated scrolling that bounces once it reaches the edge, and damps if you pull it outside the boundry.
var boundry = Physics.Boundry(0, 0, height, width)
var draggable = drag({ boundryDamping: .2 }).bounds(boundry)
var decelerate = phys.decelerate({ deceleration: 1000 }).bounds(boundry).start
var spring = phys.spring({ deceleration: 1000 }).start
draggable.pipe(phys)
draggable.start()
.then(decelerate)
.then(spring)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment