summaryrefslogtreecommitdiff
path: root/includes/js/dojox/dtl/demos/demo_Animation.html
blob: 1a5e278e2e5f6691d3495ccdbaed0778bacc8a56 (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
<html>
	<head>
		<title>Testing dojox.dtl using animation to change attributes</title>
		<script src="../../../dojo/dojo.js" djConfig="parseOnLoad: true, usePlainJson: true"></script>
		<script>
			dojo.require("dijit._Widget");
			dojo.require("dojox.dtl._HtmlTemplated");

			dojo.declare("demo.Animation", [dijit._Widget, dojox.dtl._HtmlTemplated],
			{
				buffer: 0, // Note: Sensitivity is 0 by default, but this is to emphasize we're not doing any buffering
				templatePath: dojo.moduleUrl("dojox.dtl.demos.templates", "animation.html"),
				constructor: function(props, node){
					console.debug("constructor");
					this.x = 0;
					this.y = 0;
				},
				postCreate: function(){
					var anim = new dojo._Animation({
						curve: [0, 300],
						rate: 10,
						duration: 5000,
						easing: dojo._defaultEasing
					});
					dojo.connect(anim, "onAnimate", this, "_reDraw");
					anim.play();
				},
				_reDraw: function(obj){
					this.x = obj;
					this.y = Math.sqrt(obj) * 10;

					dojo.style(this.blue, "left", this.x);
					dojo.style(this.blue, "top", this.y + 10);

					this.render();
				}
			});

			dojo.require("dojo.parser");
		</script>
	</head>
	<body>
		<div dojoType="demo.Animation" />
	</body>
</html>