diff --git a/framework/source/class/qx/bom/element/AnimationJs.js b/framework/source/class/qx/bom/element/AnimationJs.js index 82e4e354afc..61f4d0f5a4d 100644 --- a/framework/source/class/qx/bom/element/AnimationJs.js +++ b/framework/source/class/qx/bom/element/AnimationJs.js @@ -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; @@ -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; diff --git a/framework/source/class/qx/test/bom/element/AnimationJs.js b/framework/source/class/qx/test/bom/element/AnimationJs.js new file mode 100644 index 00000000000..0f3d6aab342 --- /dev/null +++ b/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); + } + } +});