[BUG] when Animations with a callback is Paused, does not pause the callback
elinfante opened this issue · comments
Hi guys,
I have some Position animations that can be paused. All the animations have a callback when the animation is finished. When I pause the animation the callback is not paused meaning that triggers _sendComponentWordFinished before the animation is completed:
this.BZNO_FA_COMP_POSITION.set(0, 100, 0, {duration: 1000, curve: 'easeOut'}, function () {
_sendComponentWordFinished.call(this);
}.bind(this));
The above animation can be paused like this:
this.BZNO_FA_COMP_POSITION._x.pause();
this.BZNO_FA_COMP_POSITION._y.pause();
Thanks!
When I pause the animation the callback is not paused meaning that triggers _sendComponentWordFinished before the animation is completed:
I'm not sure I understand this. The Position component doesn't provide a pause
method in the first place. I couldn't reproduce the described behavior if pausing _x
, _y
and _z
manually.
That being said,
this.BZNO_FA_COMP_POSITION._x.pause();
this.BZNO_FA_COMP_POSITION._y.pause();
won't work. You would have to add
this.BZNO_FA_COMP_POSITION._z.pause();
since 0 != null
, therefore the callback function will be invoked by the z
transitionable. The issue is that you are no pausing the z
transitionable.
The problem basically lies in Position#set
:
Position.prototype.set = function set(x, y, z, transition, callback) {
if (!this._requestingUpdate) {
this._node.requestUpdate(this._id);
this._requestingUpdate = true;
}
var xCallback;
var yCallback;
var zCallback;
if (z != null) {
zCallback = callback; // z != null, therefore the callback will be invoked by the transitionable that you are not pausing
}
else if (y != null) {
yCallback = callback;
}
else if (x != null) {
xCallback = callback;
}
if (x != null) this._x.set(x, transition, xCallback);
if (y != null) this._y.set(y, transition, yCallback);
if (z != null) this._z.set(z, transition, zCallback);
return this;
};
Feel free to reopen.
Thanks Alex, that worked!