| 1 | <html> |
| 2 | <head> |
| 3 | <title>Testing dojox.dtl using animation to change attributes</title> |
| 4 | <script src="../../../dojo/dojo.js" data-dojo-config="parseOnLoad: true, usePlainJson: true, async:true"></script> |
| 5 | <script> |
| 6 | require(["dojo/_base/lang", |
| 7 | "dojo/_base/declare", |
| 8 | "dijit/_WidgetBase", |
| 9 | "dojox/dtl/_DomTemplated", |
| 10 | "dojo/text!./templates/animation.html", |
| 11 | "dojo/aspect", |
| 12 | "dojo/_base/fx", |
| 13 | "dojo/dom-style", |
| 14 | 'dojo/domReady!', |
| 15 | "dojo/parser", |
| 16 | "dojox/dtl/contrib/dom"], // the dtl deps used in animation.html. require it here so that it is loaded when dtl is processed. |
| 17 | function(lang, declare, _WidgetBase, _DomTemplated, template, aspect, fx, domstyle){ |
| 18 | |
| 19 | declare("demo.Animation", [_WidgetBase, _DomTemplated], { |
| 20 | buffer: 0, // Note: Sensitivity is 0 by default, but this is to emphasize we're not doing any buffering |
| 21 | templateString: template, |
| 22 | constructor: function(props, node){ |
| 23 | this.x = 0; |
| 24 | this.y = 0; |
| 25 | }, |
| 26 | postCreate: function(){ |
| 27 | var anim = new fx.Animation({ |
| 28 | curve: [0, 300], |
| 29 | rate: 10, |
| 30 | duration: 5000, |
| 31 | easing: fx._defaultEasing |
| 32 | }); |
| 33 | aspect.after(anim, "onAnimate", lang.hitch(this, this._reDraw), true); |
| 34 | anim.play(); |
| 35 | }, |
| 36 | _reDraw: function(obj){ |
| 37 | this.x = obj; |
| 38 | this.y = Math.sqrt(obj) * 10; |
| 39 | |
| 40 | domstyle.set(this.blue, "left", this.x); |
| 41 | domstyle.set(this.blue, "top", this.y + 10); |
| 42 | |
| 43 | this.render(); |
| 44 | } |
| 45 | }); |
| 46 | }); |
| 47 | |
| 48 | </script> |
| 49 | </head> |
| 50 | <body> |
| 51 | <div data-dojo-type="demo.Animation" ></div> |
| 52 | </body> |
| 53 | </html> |