-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimation.js
More file actions
38 lines (31 loc) · 1021 Bytes
/
animation.js
File metadata and controls
38 lines (31 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// HTML5 Canvas animation library
// http://edmoremoyo.com
// Credits : Paul Irish for shim layer
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback){
window.setTimeout(callback, 1000 / 60);
};
}());
var animation = function(spec){
var that = Object.create(null),
d = document,
canvas = d.body.appendChild(d.createElement('canvas'));
canvas.id = spec.canvasID || "";
canvas.width = spec.width || 300;
canvas.height = spec.height || 150;
that.getCanvasID = function(){
return spec.canvasID
};
that.getCanvas = function(){
return document.getElementById(spec.canvasID);
};
that.getContext = function(){
return that.getCanvas().getContext(spec.context);
};
return that;
};