Page 1 of 1
[SOLVED] callback to execute something after slide...
Posted: 04 May 2013, 16:29
by Rudolf
Hi,
I did not see in the doc, if it's possible to use slideToObject like dojo and jquery functions, with a callback paramater?
(callback is executed when for example slide is finsihed).
this.slideToObject("pb_axe_0",zenode,1000, hereismycallbackfunction ).play();
Is this possible? If not how is it possible to manage it? with a chain? if possible is it possible to add the parameter?
thanks
Re: using callback function to execute something after slide
Posted: 04 May 2013, 17:10
by pikiou
Easiest way to check it to read its code:
Code: Select all
function slideToObject(_667, _668, _669, _66a) {
if (_667 === null) {
console.error("slideToObject: mobile obj is null");
}
if (_668 === null) {
console.error("slideToObject: target obj is null");
}
var tgt = dojo.position(_668);
var src = dojo.position(_667);
if (typeof _669 == "undefined") {
_669 = 500;
}
if (typeof _66a == "undefined") {
_66a = 0;
}
var left = dojo.style(_667, "left");
var top = dojo.style(_667, "top");
left = left + tgt.x - src.x + (tgt.w - src.w) / 2;
top = top + tgt.y - src.y + (tgt.h - src.h) / 2;
return dojo.fx.slideTo({node: _667, top: top, left: left, delay: _66a, duration: _669, unit: "px"});
}
Only 4 arguments, and no "arguments" in the function for a variable number of arguments. So no, it can't behave like dojo or jquery.
But slideToObject returns an animation, so you can dojo.connect its onEnd function with your callback!
Code: Select all
var anim = this.slideToObject("pb_axe_0",zenode,1000).play();
dojo.connect(anim, 'onEnd', this, hereismycallbackfunction);
Re: using callback function to execute something after slide
Posted: 04 May 2013, 17:38
by Rudolf
Thanks Pikiou!
I can now launch the callback...
But there is still a pb... the codes are running simultaneously...
I will check what Gregory propose.