-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accordion: fixes #9264 #1287
Accordion: fixes #9264 #1287
Conversation
Fixes #9264 Using .show method and outerHeight property to force height calculation when heightStyle='auto'
…accordion-heightStyle-auto-has-problems
.each(function() { | ||
maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() ); | ||
maxHeight = Math.max( maxHeight, $( this ).outerHeight() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using .outerHeight()
here makes the panels too large since we're setting the value via .height()
. The two methods have to match; since both methods account for box-sizing
, there shouldn't be a need to change.
You can see the problem in the default demo; there's extra spacing below the content of panel 3 (the tallest content). Probably the easiest way to see the difference is to just visually compare it with http://view.jqueryui.com/master/demos/accordion/default.html.
We should make sure that there's a unit test that fails prior to the fix and passes after the fix. We already have unit tests for |
@scottgonzalez thanks, good points. I'll work on a test case and bear this in mind going forward. Should I close this for now? |
You can leave it open and just push more commits to the branch. Just add a comment when you're done because there's no notification when new commits are added. |
…accordion-heightStyle-auto-has-problems
reverted to original use of "height" instead of "outerHeight" ref #9264
Still working on the test case, and box-sizing "snap" issue, |
…accordion-heightStyle-auto-has-problems
removed stray whitespace ref #9264
fx.now = Math.round( total - toHide.outerHeight() - adjust ); | ||
adjust = 0; | ||
} else if ( that.options.heightStyle !== "content" && | ||
that.options.heightStyle !== "auto" ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This addresses the "snap" issue referenced in the ticket and works for all valid values of heightStyle. However, I haven't been able to generate an automated test case, since
fx.now = Math.round( total - toHide.outerHeight() - adjust);
seems to be calculating correctly. That would seem to indicate the problem is with the tween processing but I haven't been able to lock down precisely where - I can only confirm that omitting the tween processing solves the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're excluding two options, we should just explicitly check for the one case we do want to handle. However, I have a feeling this causes jittery animations by excluding "auto"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've confirmed that this breaks the "auto"
animations.
…accordion-heightStyle-auto-has-problems
…accordion-heightStyle-auto-has-problems
@JacquesPerrault How's this going? Do you need some help? |
Scott, thanks for checking in. Some help would be appreciated, I've been hesitant to bug you in IRC about it. You said that you "confirmed that this breaks the 'auto' animations", but I have been unable to reproduce that breakage using either the bug's jsfiddle example or by updating the "default" accordion demo. I've been testing on PC using chrome 36, firefox 31, and IE 10. |
I'll add this to my todo list. To see the broken animations, just open the default demo (unchanged) and look at the description text or the Section 4 header as you toggle sections 1, 2, and 3. They shouldn't move at all, but they're bouncing around because of subpixel errors in the animation. |
…accordion-heightStyle-auto-has-problems
…accordion-heightStyle-auto-has-problems
The irregular animation occurs when the element has a style of |
Updated _animate to account for box-sizing: border-box. Minor formatting changes. ref #9264
…accordion-heightStyle-auto-has-problems
Cleaned up some linting issues Ref #9264
@@ -547,8 +550,12 @@ return $.widget( "ui.accordion", { | |||
fx.now = Math.round( now ); | |||
if ( fx.prop !== "height" ) { | |||
adjust += fx.now; | |||
} else if ( that.options.heightStyle === "auto" && | |||
toHide.css( "box-sizing" ) === "border-box") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should only be checked once and cached. See
Lines 641 to 648 in 8eca7b8
jQuery.fx.step[ hook ] = function( fx ) { | |
if ( !fx.colorInit ) { | |
fx.start = color( fx.elem, hook ); | |
fx.end = color( fx.end ); | |
fx.colorInit = true; | |
} | |
jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); | |
}; |
Correct; this is what I said in the meeting last month. You still need to handle |
Anyone using |
…accordion-heightStyle-auto-has-problems
…accordion-heightStyle-auto-has-problems
Added test for padding-box Ref #9264
} else if ( that.options.heightStyle !== "content" && | ||
( toHide.css( "box-sizing" ) === "border-box" || | ||
toHide.css( "box-sizing" ) === "padding-box" ) ) { | ||
fx.now = Math.round( total - toHide.outerHeight() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
border-box
and padding-box
need different adjustments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I separated padding-box
, but only Firefox recognizes it, and it still causes text below the accordion to jump. I know that I need to exclude padding, but I can't seem to get it right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I might be on board with @mikesherov now; let's just handle border-box
and content-box
.
…accordion-heightStyle-auto-has-problems
…accordion-heightStyle-auto-has-problems
…accordion-heightStyle-auto-has-problems
…accordion-heightStyle-auto-has-problems
Removed test for padding-box and added testcase default_9264.html to visual dir Ref #9264
Added code to resolve race condition Ref #9264
@JacquesPerrault Are you still working on this? |
There's a race condition that I was trying to address with my last commit, but it didn't do the trick. The whole point is to force the recompute of outerHeight so that the section collapses smoothly. |
Fixes #9264 Closes jquerygh-1287
Using .show method and outerHeight property to force height calculation when
heightStyle='auto'