This repository has been archived by the owner on Apr 29, 2019. It is now read-only.
forked from mojs/mojs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f2da04
commit 0541c7f
Showing
10 changed files
with
128 additions
and
107 deletions.
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,36 @@ | ||
### istanbul ignore next ### | ||
# raf polyfill | ||
(-> | ||
lastTime = 0; x = 0 | ||
vendors = ["ms", "moz", "webkit", "o" ] | ||
# Adapted from https://gist.github.com/paulirish/1579671 which derived from | ||
# http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | ||
# http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | ||
# requestAnimationFrame polyfill by Erik Möller. | ||
# Fixes from Paul Irish, Tino Zijdel, Andrew Mao, Klemen Slavič, Darius Bacon | ||
# MIT license | ||
|
||
while x < vendors.length and not window.requestAnimationFrame | ||
window.requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"] | ||
k = window[vendors[x] + "CancelRequestAnimationFrame"] | ||
window.cancelAnimationFrame = window[vendors[x]+"CancelAnimationFrame"] or k | ||
++x | ||
unless window.requestAnimationFrame | ||
window.requestAnimationFrame = (callback, element) -> | ||
currTime = new Date().getTime() | ||
timeToCall = Math.max(0, 16 - (currTime - lastTime)) | ||
id = window.setTimeout(-> | ||
callback currTime + timeToCall | ||
do -> | ||
'use strict' | ||
vendors = [ | ||
'webkit' | ||
'moz' | ||
] | ||
i = 0 | ||
w = window | ||
while i < vendors.length and !w.requestAnimationFrame | ||
vp = vendors[i] | ||
w.requestAnimationFrame = w[vp + 'RequestAnimationFrame'] | ||
cancel = w[vp + 'CancelAnimationFrame'] | ||
w.cancelAnimationFrame = cancel or w[vp + 'CancelRequestAnimationFrame'] | ||
++i | ||
isOldBrowser = !w.requestAnimationFrame or !w.cancelAnimationFrame | ||
if /iP(ad|hone|od).*OS 6/.test(w.navigator.userAgent) or isOldBrowser | ||
lastTime = 0 | ||
|
||
w.requestAnimationFrame = (callback) -> | ||
now = Date.now() | ||
nextTime = Math.max(lastTime + 16, now) | ||
setTimeout (-> | ||
callback lastTime = nextTime | ||
return | ||
, timeToCall) | ||
lastTime = currTime + timeToCall | ||
id | ||
unless window.cancelAnimationFrame | ||
window.cancelAnimationFrame = (id) -> | ||
clearTimeout id | ||
return | ||
return | ||
)() | ||
), nextTime - now | ||
|
||
w.cancelAnimationFrame = clearTimeout | ||
return |
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
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
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