I am going insane on this one. All I want to do is inherit from StackContainer and add a simple effect. PLEASE NOTE: I know there are overcomplicated, experimental widgets out there that do do transitions. However, their code is a total overkill. What I am after, is the simplest, working way for a stack container to do transitions.
This is a NON-working example:
declare('app.StackFade', [ StackContainer], {
_transition:function(newWidget, oldWidget){
// this.inherited(arguments); // This breaks things, obviously
console.log("Transition called");
html.style(oldWidget.domNode, "opacity", 1);// Random attempt
baseFx.fadeOut({
node:oldWidget.domNode,
duration: 500,
onEnd: function(){
console.log("First animation finished");
baseFx.fadeIn({
node:newWidget.domNode,
duration:500,
onEnd: function(){
html.style(newWidget.domNode, "opacity", 0);
lang.hitch(this,"inherited", arguments, arguments); // this doesn't work
console.log("Second animation finished");
},
}).play();
}
}).play();
}
}
How do I turn this non-working example into a working one? Again, I am after something very simple, plain, a few lines of code to change _transition and that's it!
My favourite activity, answering my own question... There seem to be problems with Dojo, lang.hitch and this.inherited(arguments).
The solution is to get
this
intothat
, and alsoarguments
intoa
(wherea
andthat
are variable local to the function).I ended up creating a mixin which can be mixed in to any stack container (also works with tab containers) giving it a "fade" effect...
Enjoy.
}); // Define