我最喜欢的活动,回答我自己的问题...... Dojo、lang.hitch 和 this.inherited(arguments) 似乎存在问题。
解决方案是this
进入that
,也arguments
进入a
(wherea
和that
是函数的局部变量) 。
我最终创建了一个 mixin,它可以混入任何堆栈容器(也适用于选项卡容器),使其具有“淡化”效果......
享受。
define([
"dojo/_base/declare",
"dojo/_base/html",
"dojo/_base/fx",
"dojo/_base/lang",
"app/defaults",
"app/globals",
], function(
declare
, html
, baseFx
, lang
, BusyButton
, defaults
, g
){
return declare('app._StackFadingMixin', null, {
fadeInInProgress: null,
fadeOutInProgress: null,
_transition:function(newWidget, oldWidget){
// console.log("Transition called");
// Needed later for calling this.inherited(arguments);
that = this;
var a = arguments;
/*
console.log("Values:");
console.log("FadeInInProgress :" + this.fadeInInProgress);
console.log("FadeOutInProgress :" + this.fadeOutInProgress);
*/
// An animation was stopped: don't do the whole animation thing, reset everything,
// called this.inherited(arguments) as if nothing happened
if( this.fadeInInProgress || this.fadeOutInProgress ){
// Stop animations
if( this.fadeInInProgress ){ this.fadeInInProgress.stop(); }
if( this.fadeOutInProgress ){ this.fadeOutInProgress.stop(); }
// Reset opacity for everything
html.style(newWidget.domNode, "opacity", 1);
html.style(oldWidget.domNode, "opacity", 1);
// call inherited(arguments) as if nothing happened
this.inherited(arguments);
return;
}
// ////////////////////////////////////////
// // FADEOUT
// ////////////////////////////////////////
// console.log("Fade out starting");
that.fadeOutInProgress = baseFx.fadeOut({
node:oldWidget.domNode,
duration: 150,
onStop: function(){
that.fadeOutInProgress = null;
// console.log("Fadeout stopped");
},
// ////////////////////////////////////////
// // FADEIN
// ////////////////////////////////////////
onEnd: function(){
that.fadeOutInProgress = null;
// Make the widget transparent, and then call inherited -- which will do the actual switch.
html.style(newWidget.domNode, "opacity", 0);
that.inherited(a);
// console.log("Fadeout ended");
// At this point the widget is visible, selected but transparent.
// Let's fix that...
// console.log("Fade in starting");
that.fadeInInProgress = baseFx.fadeIn({
node:newWidget.domNode,
duration: 150,
onStop: function(){
that.fadeInInProgress = null;
// console.log("Fadein stopped");
},
onEnd: function(){
// console.log("Fadein ended");
that.fadeInInProgress = null;
},
}).play();
}
}).play();
}
}); // Declare
}); // 定义