Skip to main content

Search and Top Navigation

#7238 closed bug (fixed)

Opened April 12, 2011 01:12AM UTC

Closed November 07, 2011 12:11PM UTC

Last modified November 07, 2011 12:14PM UTC

Problem with accordion slide animation fixed width calculation

Reported by: ts2do Owned by:
Priority: minor Milestone: 1.8.17
Component: ui.accordion Version: 1.8.11
Keywords: Cc:
Blocked by: Blocking:
Description

The affected code is as follows according to the master branch in github:

s.width( parseInt( s.parent().width(), 10 )
- parseInt( s.css( "paddingLeft" ), 10 )
- parseInt( s.css( "paddingRight" ), 10 )
- ( parseInt( s.css( "borderLeftWidth" ), 10 ) || 0 )
- ( parseInt( s.css( "borderRightWidth" ), 10) || 0 ) );

The problem lies in parsing the paddings and border widths as integers. Both of these elements can be defined using units other than px, allowing the call to .css() to return a floating value (e.g. 30.8px in my own project). Because of the truncation from parseInt, the width ends up being larger than the actual static width.

Here's the fix:

s.width( s.parent().width()
- parseFloat( s.css( "paddingLeft" ) )
- parseFloat( s.css( "paddingRight" ) )
- ( parseFloat( s.css( "borderLeftWidth" ) ) || 0 )
- ( parseFloat( s.css( "borderRightWidth" ) ) || 0 ) );

I also removed the first parseInt because .width() already returns a numeric value.

Attachments (0)
Change History (5)

Changed November 06, 2011 02:24PM UTC by M.Gaetan89 comment:1

I've submitted your fix as a pull request on GitHub : https://github.com/jquery/jquery-ui/pull/517

Changed November 07, 2011 12:11PM UTC by Gaëtan Muller comment:2

resolution: → fixed
status: newclosed

Accordion: Fixed #7238 - Problem with accordion slide animation fixed width calculation

Changeset: 124cf3cc6c9bf182563e2fe0663cdde497700f7b

Changed November 07, 2011 12:11PM UTC by Scott González comment:3

Merge pull request #517 from MGaetan89/bug_7238

Accordion: Fixed #7238 - Problem with accordion slide animation fixed wid

Changeset: 900514ad0f1d54291dcbd105df44d4c766e813bd

Changed November 07, 2011 12:14PM UTC by Gaëtan Muller comment:4

Accordion: Fixed #7238 - Problem with accordion slide animation fixed width calculation

(cherry picked from commit 124cf3cc6c9bf182563e2fe0663cdde497700f7b)

Changeset: 9a87c1a72ea298170f4b9bffcecdb4d80ee4b5cc

Changed November 07, 2011 12:14PM UTC by scottgonzalez comment:5

milestone: 1.91.8.17