Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.animation.AnimationSequence");
14
dojo.require("dojo.animation.AnimationEvent");
15
dojo.require("dojo.animation.Animation");
16
dojo.deprecated("dojo.animation.AnimationSequence is slated for removal in 0.5; use dojo.lfx.* instead.", "0.5");
17
dojo.animation.AnimationSequence = function (repeatCount) {
18
	this._anims = [];
19
	this.repeatCount = repeatCount || 0;
20
};
21
dojo.lang.extend(dojo.animation.AnimationSequence, {repeatCount:0, _anims:[], _currAnim:-1, onBegin:null, onEnd:null, onNext:null, handler:null, add:function () {
22
	for (var i = 0; i < arguments.length; i++) {
23
		this._anims.push(arguments[i]);
24
		arguments[i]._animSequence = this;
25
	}
26
}, remove:function (anim) {
27
	for (var i = 0; i < this._anims.length; i++) {
28
		if (this._anims[i] == anim) {
29
			this._anims[i]._animSequence = null;
30
			this._anims.splice(i, 1);
31
			break;
32
		}
33
	}
34
}, removeAll:function () {
35
	for (var i = 0; i < this._anims.length; i++) {
36
		this._anims[i]._animSequence = null;
37
	}
38
	this._anims = [];
39
	this._currAnim = -1;
40
}, clear:function () {
41
	this.removeAll();
42
}, play:function (gotoStart) {
43
	if (this._anims.length == 0) {
44
		return;
45
	}
46
	if (gotoStart || !this._anims[this._currAnim]) {
47
		this._currAnim = 0;
48
	}
49
	if (this._anims[this._currAnim]) {
50
		if (this._currAnim == 0) {
51
			var e = {type:"begin", animation:this._anims[this._currAnim]};
52
			if (typeof this.handler == "function") {
53
				this.handler(e);
54
			}
55
			if (typeof this.onBegin == "function") {
56
				this.onBegin(e);
57
			}
58
		}
59
		this._anims[this._currAnim].play(gotoStart);
60
	}
61
}, pause:function () {
62
	if (this._anims[this._currAnim]) {
63
		this._anims[this._currAnim].pause();
64
	}
65
}, playPause:function () {
66
	if (this._anims.length == 0) {
67
		return;
68
	}
69
	if (this._currAnim == -1) {
70
		this._currAnim = 0;
71
	}
72
	if (this._anims[this._currAnim]) {
73
		this._anims[this._currAnim].playPause();
74
	}
75
}, stop:function () {
76
	if (this._anims[this._currAnim]) {
77
		this._anims[this._currAnim].stop();
78
	}
79
}, status:function () {
80
	if (this._anims[this._currAnim]) {
81
		return this._anims[this._currAnim].status();
82
	} else {
83
		return "stopped";
84
	}
85
}, _setCurrent:function (anim) {
86
	for (var i = 0; i < this._anims.length; i++) {
87
		if (this._anims[i] == anim) {
88
			this._currAnim = i;
89
			break;
90
		}
91
	}
92
}, _playNext:function () {
93
	if (this._currAnim == -1 || this._anims.length == 0) {
94
		return;
95
	}
96
	this._currAnim++;
97
	if (this._anims[this._currAnim]) {
98
		var e = {type:"next", animation:this._anims[this._currAnim]};
99
		if (typeof this.handler == "function") {
100
			this.handler(e);
101
		}
102
		if (typeof this.onNext == "function") {
103
			this.onNext(e);
104
		}
105
		this._anims[this._currAnim].play(true);
106
	} else {
107
		var e = {type:"end", animation:this._anims[this._anims.length - 1]};
108
		if (typeof this.handler == "function") {
109
			this.handler(e);
110
		}
111
		if (typeof this.onEnd == "function") {
112
			this.onEnd(e);
113
		}
114
		if (this.repeatCount > 0) {
115
			this._currAnim = 0;
116
			this.repeatCount--;
117
			this._anims[this._currAnim].play(true);
118
		} else {
119
			if (this.repeatCount == -1) {
120
				this._currAnim = 0;
121
				this._anims[this._currAnim].play(true);
122
			} else {
123
				this._currAnim = -1;
124
			}
125
		}
126
	}
127
}});
128