blob: 80901ef3eb676c3df2f59608d0d75367b2182020 (
plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/**
* $Id: mxAnimation.js,v 1.2 2010-03-19 12:53:29 gaudenz Exp $
* Copyright (c) 2006-2010, JGraph Ltd
*/
/**
*
* Class: mxAnimation
*
* Implements a basic animation in JavaScript.
*
* Constructor: mxAnimation
*
* Constructs an animation.
*
* Parameters:
*
* graph - Reference to the enclosing <mxGraph>.
*/
function mxAnimation(delay)
{
this.delay = (delay != null) ? delay : 20;
};
/**
* Extends mxEventSource.
*/
mxAnimation.prototype = new mxEventSource();
mxAnimation.prototype.constructor = mxAnimation;
/**
* Variable: delay
*
* Specifies the delay between the animation steps. Defaul is 30ms.
*/
mxAnimation.prototype.delay = null;
/**
* Variable: thread
*
* Reference to the thread while the animation is running.
*/
mxAnimation.prototype.thread = null;
/**
* Function: startAnimation
*
* Starts the animation by repeatedly invoking updateAnimation.
*/
mxAnimation.prototype.startAnimation = function()
{
if (this.thread == null)
{
this.thread = window.setInterval(mxUtils.bind(this, this.updateAnimation), this.delay);
}
};
/**
* Function: updateAnimation
*
* Hook for subclassers to implement the animation. Invoke stopAnimation
* when finished, startAnimation to resume. This is called whenever the
* timer fires and fires an mxEvent.EXECUTE event with no properties.
*/
mxAnimation.prototype.updateAnimation = function()
{
this.fireEvent(new mxEventObject(mxEvent.EXECUTE));
};
/**
* Function: stopAnimation
*
* Stops the animation by deleting the timer and fires an <mxEvent.DONE>.
*/
mxAnimation.prototype.stopAnimation = function()
{
if (this.thread != null)
{
window.clearInterval(this.thread);
this.thread = null;
this.fireEvent(new mxEventObject(mxEvent.DONE));
}
};
|