File tree Expand file tree Collapse file tree 2 files changed +24
-11
lines changed Expand file tree Collapse file tree 2 files changed +24
-11
lines changed Original file line number Diff line number Diff line change @@ -5,43 +5,55 @@ class Animation {
5
5
this . nodes = nodes ;
6
6
this . info = info ;
7
7
8
- this . animationLoop = null ;
9
- this . requestId = null ;
10
-
11
- this . _init ( ) ;
8
+ this . _context = self ;
9
+ this . _animationLoop = null ;
10
+ this . _requestId = null ;
12
11
13
12
}
14
13
15
- _init ( ) {
14
+ start ( ) {
16
15
17
16
const update = ( time , frame ) => {
18
17
19
- this . requestId = self . requestAnimationFrame ( update ) ;
18
+ this . _requestId = this . _context . requestAnimationFrame ( update ) ;
20
19
21
20
if ( this . info . autoReset === true ) this . info . reset ( ) ;
22
21
23
22
this . nodes . nodeFrame . update ( ) ;
24
23
25
24
this . info . frame = this . nodes . nodeFrame . frameId ;
26
25
27
- if ( this . animationLoop !== null ) this . animationLoop ( time , frame ) ;
26
+ if ( this . _animationLoop !== null ) this . _animationLoop ( time , frame ) ;
28
27
29
28
} ;
30
29
31
30
update ( ) ;
32
31
33
32
}
34
33
35
- dispose ( ) {
34
+ stop ( ) {
35
+
36
+ this . _context . cancelAnimationFrame ( this . _requestId ) ;
36
37
37
- self . cancelAnimationFrame ( this . requestId ) ;
38
- this . requestId = null ;
38
+ this . _requestId = null ;
39
39
40
40
}
41
41
42
42
setAnimationLoop ( callback ) {
43
43
44
- this . animationLoop = callback ;
44
+ this . _animationLoop = callback ;
45
+
46
+ }
47
+
48
+ setContext ( context ) {
49
+
50
+ this . _context = context ;
51
+
52
+ }
53
+
54
+ dispose ( ) {
55
+
56
+ this . stop ( ) ;
45
57
46
58
}
47
59
Original file line number Diff line number Diff line change @@ -248,6 +248,7 @@ class Renderer {
248
248
249
249
//
250
250
251
+ this . _animation . start ( ) ;
251
252
this . _initialized = true ;
252
253
253
254
resolve ( ) ;
You can’t perform that action at this time.
0 commit comments