Created
July 9, 2012 05:04
-
-
Save island205/3074299 to your computer and use it in GitHub Desktop.
time animate function
This file contains hidden or 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
| animate=do -> | |
| requestAnimationFrame = window.requestAnimationFrame || | |
| window.mozRequestAnimationFrame || | |
| window.webkitRequestAnimationFrame || | |
| window.msRequestAnimationFrame || | |
| window.oRequestAnimationFrame || | |
| (callback)-> | |
| setTimeout(-> | |
| callback(new Date()) | |
| return | |
| , | |
| 1000 / 60) | |
| return | |
| animate=(duration,callback)-> | |
| startTime=new Date() | |
| finished=-1 | |
| step=(timestemp)-> | |
| progress=timestemp-startTime | |
| if progress >= duration | |
| callback(finished) | |
| return | |
| callback(progress) | |
| requestAnimationFrame(step) | |
| requestAnimationFrame(step) | |
| return animate | |
| animate 1000,(pro)-> | |
| if pro > 0 | |
| document.body.setAttribute "style","padding-top:"+pro/1000*100+"px" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment