demo_Animation.html 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <html>
  2. <head>
  3. <title>Testing dojox.dtl using animation to change attributes</title>
  4. <script src="../../../dojo/dojo.js" djConfig="parseOnLoad: true, usePlainJson: true"></script>
  5. <script>
  6. dojo.require("dojox.dtl.widget");
  7. dojo.provide("demo");
  8. dojo.declare("demo.Animation", dojox.dtl._Widget,
  9. {
  10. buffer: 0, // Note: Sensitivity is 0 by default, but this is to emphasize we're not doing any buffering
  11. constructor: function(props, node){
  12. this.context = new dojox.dtl.Context({ x: 0, y: 0 });
  13. this.template = new dojox.dtl.HtmlTemplate(dojo.moduleUrl("dojox.dtl.demos.templates", "animation.html"));
  14. },
  15. postCreate: function(){
  16. this.render(this.template, this.context);
  17. var anim = new dojo._Animation({
  18. curve: [0, 300],
  19. rate: 10,
  20. duration: 5000,
  21. easing: dojo._defaultEasing
  22. });
  23. dojo.connect(anim, "onAnimate", this, "_reDraw");
  24. anim.play();
  25. },
  26. _reDraw: function(obj){
  27. this.context.x = obj;
  28. this.context.y = Math.sqrt(obj) * 10;
  29. dojo.style(this.blue, "left", this.context.x);
  30. dojo.style(this.blue, "top", this.context.y + 10);
  31. this.render(this.template, this.context);
  32. }
  33. });
  34. dojo.require("dojo.parser");
  35. </script>
  36. </head>
  37. <body>
  38. <div dojoType="dojox.dtl.AttachPoint">
  39. <div dojoType="demo.Animation" />
  40. </div>
  41. </body>
  42. </html>