cancelAnimFrame function

This commit is contained in:
mourner 2012-02-22 08:59:17 +02:00
parent 3ab1acbf56
commit dfdd363d2e

View File

@ -30,6 +30,9 @@ L.Util = {
};
}()),
// TODO refactor: remove repetition
requestAnimFrame: (function () {
function timeoutDefer(callback) {
window.setTimeout(callback, 1000 / 60);
@ -47,11 +50,24 @@ L.Util = {
if (immediate && requestFn === timeoutDefer) {
callback();
} else {
requestFn(callback, contextEl);
return requestFn.call(window, callback, contextEl);
}
};
}()),
cancelAnimFrame: (function () {
var requestFn = window.cancelAnimationFrame ||
window.webkitCancelRequestAnimationFrame ||
window.mozCancelRequestAnimationFrame ||
window.oCancelRequestAnimationFrame ||
window.msCancelRequestAnimationFrame ||
clearTimeout;
return function (handle) {
return requestFn.call(window, handle);
}
}()),
limitExecByInterval: function (fn, time, context) {
var lock, execOnUnlock, args;
function exec() {