Skip to content
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

Closed
wants to merge 22 commits into from
Closed

Accordion: fixes #9264 #1287

wants to merge 22 commits into from

Conversation

JacquesPerrault
Copy link
Contributor

Using .show method and outerHeight property to force height calculation when
heightStyle='auto'

Fixes #9264

Using .show method and outerHeight property to force height calculation when
heightStyle='auto'
.each(function() {
maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
maxHeight = Math.max( maxHeight, $( this ).outerHeight() );
Copy link
Member

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.

@scottgonzalez
Copy link
Member

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 heightStyle, but perhaps we need to limit the width in the test fixture so the bug occurs.

@JacquesPerrault
Copy link
Contributor Author

@scottgonzalez thanks, good points. I'll work on a test case and bear this in mind going forward. Should I close this for now?

@scottgonzalez
Copy link
Member

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.

reverted to original use of "height" instead of "outerHeight"

ref #9264
@JacquesPerrault
Copy link
Contributor Author

Still working on the test case, and box-sizing "snap" issue,

fx.now = Math.round( total - toHide.outerHeight() - adjust );
adjust = 0;
} else if ( that.options.heightStyle !== "content" &&
that.options.heightStyle !== "auto" ) {
Copy link
Contributor Author

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.

Copy link
Member

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".

Copy link
Member

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.

@scottgonzalez
Copy link
Member

@JacquesPerrault How's this going? Do you need some help?

@JacquesPerrault
Copy link
Contributor Author

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.

@scottgonzalez
Copy link
Member

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.

@JacquesPerrault
Copy link
Contributor Author

The irregular animation occurs when the element has a style of box-sizing: 'border-box'.
I'd bet this is because padding and border values negate adjust. Adding a condition such as } else if ( that.options.heightStyle == "auto" && toHide.css( "box-sizing" ) == "border-box") {...} and removing the adjust parameter seems to do the trick.

Updated _animate to account for box-sizing: border-box.
Minor formatting changes.

ref #9264
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") {
Copy link
Member

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

jquery-ui/ui/effect.js

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 ) );
};
for an example.

@scottgonzalez
Copy link
Member

I'd bet this is because padding and border values negate adjust.

Correct; this is what I said in the meeting last month. You still need to handle padding-box as well.

@mikesherov
Copy link
Member

Anyone using padding-box deserves to be punished.

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() );
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Removed test for padding-box and added testcase default_9264.html to visual dir

Ref #9264
Added code to resolve race condition

Ref #9264
@scottgonzalez
Copy link
Member

@JacquesPerrault Are you still working on this?

@JacquesPerrault
Copy link
Contributor Author

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.

scottgonzalez added a commit to scottgonzalez/jquery-ui that referenced this pull request Mar 2, 2015
scottgonzalez added a commit that referenced this pull request Mar 10, 2015
Fixes #9264
Closes gh-1287
Closes gh-1459
(cherry picked from commit 4b017b4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants