-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppFrame_Draw.ts
More file actions
33 lines (28 loc) · 846 Bytes
/
AppFrame_Draw.ts
File metadata and controls
33 lines (28 loc) · 846 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
/// <reference path="AppFrame.ts" />
// APPFRAME DRAW EXTENSION BY SUNMOCK YANG
/*
USES REQUEST ANIMATION FRAME TO RUN MAIN LOOP.
RECOMMENDED USE OF rAF.js BY PAUL IRISH TO SUPPLEMENT YOUR requestAnimationFrame USE
*/
class DrawFrame extends AppFrame {
private sleep: number;
private element: HTMLElement = document.body;
//USER DEFINED RUN METHODS
public initialize() { };
public update() { };
public draw() { };
public exit() { };
public setElement(element: HTMLElement){
this.element = element;
}
private run(that:DrawFrame){
if (that.running) {
that.update();
setTimeout(function () {
requestAnimationFrame(function () { that.run(that); });
that.draw();
}, this.sleep);
}
else this.exit();
}
}