Opened 8 years ago

Last modified 3 years ago

#15034 new defect

baseFx.anim not emitting "end" event

Reported by: Kitson Kelly Owned by: Bryan Forbes
Priority: undecided Milestone: 1.15
Component: fx Version: 1.7.2
Keywords: Cc:
Blocked By: Blocking:

Description

While working on refactoring some of the documentation code, I noticed that dojo/_base/fx::anim() is not firing an "end" event that is being handled by on.

For example the following works:

require(["dojo/query", "dojo/_base/fx", "dojo/_base/connect", "dojo/domReady!"],
function(query, baseFx, conn){
  query("#showMe").onclick(function(e){
    var node = this,
        anim = baseFx.anim(node, {
          backgroundColor: "#363636",
          color: "#f7f7f7"
        }, 1000);
    
    conn.connect(anim, "onEnd", function(){
      baseFx.anim(node, { color: "#363636" }, null, null, function(){
        node.innerHTML = "wow, that was easy!";
        baseFx.anim(node, { color: "white" });
      });
    });
  });
});

But the following doesn't work in that the on never fires:

require(["dojo/query", "dojo/_base/fx", "dojo/on", "dojo/domReady!"],
function(query, baseFx, on){
  query("#showMe").onclick(function(e){
    var node = this,
        anim = baseFx.anim(node, {
          backgroundColor: "#363636",
          color: "#f7f7f7"
        }, 1000);
    
    on(anim, "end", function(){
      baseFx.anim(node, { color: "#363636" }, null, null, function(){
        node.innerHTML = "wow, that was easy!";
        baseFx.anim(node, { color: "white" });
      });
    });
  });
});

Change History (6)

comment:1 Changed 8 years ago by bill

Component: Corefx
Owner: set to Bryan Forbes

Sounds like fallout from how Kris programmed on("foo") to automatically connect to an onfoo() function if it exists, but not to connect to onFoo() (with a capital letter).

Probably for 2.0 will refactor the fx code to explicitly call on.emit("end"). Not sure if anything should be done in the meantime.

The workaround would be to call on("End", ...) but it doesn't seem like we want to promote that. And of course the other "workaround" is to keep calling dojo.connect(), like in your first code snippet.

comment:2 Changed 8 years ago by Kitson Kelly

Yeah, the only problem is that the example code is sitting right on the index of the reference-guide. We of course could use another example to show a more modern version of Dojo and we have updated the reference-guide to say "use on instead of connect" but can't widely promote using it. I didn't realise that "on" didn't pick up camelCased event handlers generically. Seems like something that should be considered for pre-2.0 compatibility for a period of time.

comment:3 Changed 4 years ago by dylan

#14641 is a duplicate of this ticket.

comment:4 Changed 4 years ago by dylan

Milestone: tbd1.12

Consider for 1.12.

comment:5 Changed 4 years ago by dylan

#16305 is a duplicate of this ticket.

comment:6 Changed 3 years ago by dylan

Milestone: 1.131.15

Ticket planning... move current 1.13 tickets out to 1.15 to make it easier to move tickets into the 1.13 milestone.

Note: See TracTickets for help on using tickets.