git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8d1efee
)
Make sure that width or height don't animate to a negative value. Fixes #3881.
author
John Resig
<jeresig@gmail.com>
Sat, 5 Dec 2009 05:10:19 +0000
(
00:10
-0500)
committer
John Resig
<jeresig@gmail.com>
Sat, 5 Dec 2009 05:10:19 +0000
(
00:10
-0500)
src/fx.js
patch
|
blob
|
history
test/unit/fx.js
patch
|
blob
|
history
diff --git
a/src/fx.js
b/src/fx.js
index
d3a7ad4
..
15fce5c
100644
(file)
--- a/
src/fx.js
+++ b/
src/fx.js
@@
-432,7
+432,7
@@
jQuery.extend( jQuery.fx, {
_default: function(fx){
if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
_default: function(fx){
if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
- fx.elem.style[ fx.prop ] = fx.now + fx.unit;
+ fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
} else {
fx.elem[ fx.prop ] = fx.now;
}
} else {
fx.elem[ fx.prop ] = fx.now;
}
diff --git
a/test/unit/fx.js
b/test/unit/fx.js
index
c259a38
..
5b97dc3
100644
(file)
--- a/
test/unit/fx.js
+++ b/
test/unit/fx.js
@@
-52,6
+52,15
@@
test("animate(Hash, Object, Function)", function() {
});
});
});
});
+test("animate negative height", function() {
+ expect(1);
+ stop();
+ jQuery("#foo").animate({ height: -100 }, 100, function() {
+ equals( this.offsetHeight, 0, "Verify height." );
+ start();
+ });
+});
+
/* // This test ends up being flaky depending upon the CPU load
test("animate option (queue === false)", function () {
expect(1);
/* // This test ends up being flaky depending upon the CPU load
test("animate option (queue === false)", function () {
expect(1);