1 | import define from '../../define';
|
2 | import * as util from '../../util';
|
3 | import stepAll from './step-all';
|
4 |
|
5 | let corefn = ({
|
6 |
|
7 |
|
8 | animate: define.animate(),
|
9 | animation: define.animation(),
|
10 | animated: define.animated(),
|
11 | clearQueue: define.clearQueue(),
|
12 | delay: define.delay(),
|
13 | delayAnimation: define.delayAnimation(),
|
14 | stop: define.stop(),
|
15 |
|
16 | addToAnimationPool: function( eles ){
|
17 | let cy = this;
|
18 |
|
19 | if( !cy.styleEnabled() ){ return; }
|
20 |
|
21 | cy._private.aniEles.merge( eles );
|
22 | },
|
23 |
|
24 | stopAnimationLoop: function(){
|
25 | this._private.animationsRunning = false;
|
26 | },
|
27 |
|
28 | startAnimationLoop: function(){
|
29 | let cy = this;
|
30 |
|
31 | cy._private.animationsRunning = true;
|
32 |
|
33 | if( !cy.styleEnabled() ){ return; }
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | function headlessStep(){
|
39 | if( !cy._private.animationsRunning ){ return; }
|
40 |
|
41 | util.requestAnimationFrame( function animationStep( now ){
|
42 | stepAll( now, cy );
|
43 | headlessStep();
|
44 | } );
|
45 | }
|
46 |
|
47 | let renderer = cy.renderer();
|
48 |
|
49 | if( renderer && renderer.beforeRender ){
|
50 | renderer.beforeRender( function rendererAnimationStep( willDraw, now ){
|
51 | stepAll( now, cy );
|
52 | }, renderer.beforeRenderPriorities.animations );
|
53 | } else {
|
54 | headlessStep();
|
55 | }
|
56 | }
|
57 |
|
58 | });
|
59 |
|
60 | export default corefn;
|