Skip to content

Commit

Permalink
[BUG #7015] Fixed stopping of js based animation which are delayed.
Browse files Browse the repository at this point in the history
  • Loading branch information
wittemann committed Nov 28, 2012
1 parent 3052f89 commit 3a98b7f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
8 changes: 7 additions & 1 deletion framework/source/class/qx/bom/element/AnimationJs.js
Expand Up @@ -129,7 +129,8 @@ qx.Bootstrap.define("qx.bom.element.AnimationJs",

var delay = desc.delay || 0;
var self = this;
window.setTimeout(function() {
handle.delayId = window.setTimeout(function() {
handle.delayId = null;
self.play(handle);
}, delay);
return handle;
Expand Down Expand Up @@ -336,6 +337,11 @@ qx.Bootstrap.define("qx.bom.element.AnimationJs",
window.clearInterval(handle.animationId);
}

// clear the delay if the animation has not been started
if (handle.delayId) {
window.clearTimeout(handle.delayId);
}

// check if animation is already stopped
if (el == undefined) {
return handle;
Expand Down
44 changes: 44 additions & 0 deletions framework/source/class/qx/test/bom/element/AnimationJs.js
@@ -0,0 +1,44 @@
/* ************************************************************************
qooxdoo - the new era of web development
http://qooxdoo.org
Copyright:
2004-2012 1&1 Internet AG, Germany, http://www.1und1.de
License:
LGPL: http://www.gnu.org/licenses/lgpl.html
EPL: http://www.eclipse.org/org/documents/epl-v10.php
See the LICENSE file in the project's top-level directory for details.
Authors:
* Martin Wittemann (wittemann)
************************************************************************ */
qx.Class.define("qx.test.bom.element.AnimationJs",
{
extend : qx.dev.unit.TestCase,
include : qx.dev.unit.MMock,

members :
{
testStop : function() {
var el = qx.dom.Element.create("div");
var handle = qx.bom.element.AnimationJs.animate(el, {
"duration": 100,
"keyFrames": {
0 : {"opacity": 1},
100 : {"opacity": 0}
},
"delay" : 200
});
var spy = this.spy();
handle.on("start", spy);
handle.stop();
this.wait(500, function() {
this.assertNotCalled(spy);
}, this);
}
}
});

0 comments on commit 3a98b7f

Please sign in to comment.