#2185 closed bug (fixed)
animate does not work properly with non-block-level elements (table, tr, td, inline, etc.)
Reported by: | Johnath | Owned by: | snover |
---|---|---|---|
Priority: | high | Milestone: | 1.4.3 |
Component: | effects | Version: | 1.4.2 |
Keywords: | Cc: | snover | |
Blocked by: | Blocking: |
Description
Using slideToggle to hide/show a div styled with
display: inline-block;
Causes the display to go to "none" when hidden, and then "block" when restored. Ideally, the display should be set back to its original value.
It's simple to workaround by wrapping the styled div(s) in a normal block div, but obviously that's suboptimal. Obviously, testing this requires a browser that understands inline-block. I am seeing this behaviour in the Firefox 3 betas.
Change History (13)
comment:1 Changed 15 years ago by
comment:2 Changed 15 years ago by
I can confirm the same behavior that michaeltsmith85 is seeing. An inline css style of "display:none" set for a <tr> is being set with slideToggle to "display:block" which borks the table. It should be set to "table-row". I would opt for/maybe prefer setting the display parameter myself as it seems it could be complicated for jQuery to determine what sort of element needs what sort of display type.
comment:4 Changed 14 years ago by
Seems that there is two issues here.
- 1) height and width animations are always set to display: block
- 2) not all animations revert display back to the original
In jQuery.fx.update we need to check for inline-block or table-row.
// Set display property to block for height/width animations if ( ( this.prop == "height" || this.prop == "width" ) && this.elem.style ) this.elem.style.display = "block";
line 4022-4024 in jQuery 1.3.2
The second issue is solved in jQuery.fx.animate.
if ( ( p == "height" || p == "width" ) && this.style ) { // Store display property opt.display = jQuery.css(this, "display");
line 3878-3880 in jQuery 1.3.2
comment:5 Changed 14 years ago by
found a whole bunch of issues with this problem.
- http://dev.jquery.com/ticket/4313
- http://dev.jquery.com/ticket/4173
- http://dev.jquery.com/ticket/4096
- http://dev.jquery.com/ticket/2503
Will look into this now.. :)
comment:10 Changed 13 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
This was fixed a while back and there are tests for it.
comment:12 Changed 13 years ago by
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
Is this genuinely fixed? My test case at http://estel.uwcs.co.uk/jquery/inlineblock.html still shows this issue to persist, and it's fixed by an amalgamation of fixes in this and #2503.
comment:13 Changed 13 years ago by
Cc: | snover added |
---|---|
Milestone: | 1.2.3 → 1.4.3 |
need: | Review → Patch |
Owner: | set to snover |
Priority: | minor → high |
Status: | reopened → new |
Version: | 1.2.2 → 1.4.2 |
comment:14 Changed 13 years ago by
Status: | new → assigned |
---|---|
Summary: | slideToggle doesn't preserve "display" style → animate does not work properly with non-block-level elements (table, tr, td, inline, etc.) |
comment:16 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Just to clarify, this bug is also reproducible with slideUp and slideDown. show() & hide() don't reproduce the error. Further, this error also occurs for items with displays other than display: inline... table rows go from display: table-row to display: none (on hide) to display: block (on show again). Seems the patch would be either be for an option to add the display parameter or for jQuery to somehow remember the proper display type.