Search code examples
animationdojoamd

dojo AMD requestAnimationFrame


I'm trying to convert Dojo functions from non-AMD to AMD but am not sure how to convert the following function: previously it was Non-AMD like

function step11(timestamp){
   window.requestAnimationFrame(step11);
}

after converting to AMD

step11: function(timestamp) {
   window.requestAnimationFrame(step11);
 }

its been called from other method as

window.requestAnimationFrame(that.step11);

I tried:

var that = this;
window.requestAnimationFrame(function() {
    that.step11();
});

Which gives the error "that.step11 is not a function".


Solution

  • found the solution.

     define(["dojo/ready", "dojo/dom", "dojo/dom-construct","js/abc", "dojo/domReady!"], function(ready, dom, domConstruct,abc){
     var test={
    
            step11: function(timestamp) {
              window.requestAnimationFrame(test.step11);
            }
         };
         test.step11();
         return test;
      });