diff --git a/src/fx.js b/src/fx.js index fd86ce35b..575449a24 100644 --- a/src/fx.js +++ b/src/fx.js @@ -86,11 +86,13 @@ } if (duration > 0) this.bind(endEvent, wrappedCallback) - setTimeout(function() { - that.css(cssValues) - if (duration <= 0) setTimeout(function() { - that.each(function(){ wrappedCallback.call(this) }) - }, 0) + // trigger page reflow so new elements can animate + this.size() && this.get(0).clientLeft + + this.css(cssValues) + + if (duration <= 0) setTimeout(function() { + that.each(function(){ wrappedCallback.call(this) }) }, 0) return this diff --git a/test/fx.html b/test/fx.html index 44a53e08c..a453a259a 100644 --- a/test/fx.html +++ b/test/fx.html @@ -239,6 +239,10 @@

Zepto effects tests

t.assertStyle('linear', el, 'animation-timing-function') }) }) + }, + + testEmptyCollection: function(t){ + t.assert($(null).animate({opacity:0})) } }) })()