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

fire fox not returning $el.width() correctly #17

Open
tobiasdemaine opened this issue Feb 18, 2015 · 2 comments
Open

fire fox not returning $el.width() correctly #17

tobiasdemaine opened this issue Feb 18, 2015 · 2 comments

Comments

@tobiasdemaine
Copy link

sometimes with firefox : if .tse-content has a lot of nested elements and *{box-sizing: border-box;} jQuery will not return return the width correctly and ends up showing 10px of the hidden moz scrollbar.

work around in function resizeScrollContent()
change
$scrollContentEl.width($el.width() + scrollbarWidth());
to
$scrollContentEl.width(parseInt($el.css('width'))+scrollbarWidth());

@jnicol
Copy link
Owner

jnicol commented Mar 3, 2015

Do you have a demo I can use to reproduce this issue?

@r3wt
Copy link

r3wt commented Feb 7, 2017

@jnicol its a known limitation of jQuery. why they haven't fixed it yet is probably to avoid bc breaks for applications that may already work around this problem. i use instead:

$.fn.realWidth = function(){ return ~~$(this).css('width').replace(/px/,''); };
$.fn.realHeight = function(){ return ~~$(this).css('height').replace(/px/,''); };

which will force jQuery to calculate the width/height including padding, regardless of the value of box-sizing for the element. box-sizing is what causes this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants