trackpad-scroll-emulator icon indicating copy to clipboard operation
trackpad-scroll-emulator copied to clipboard

fire fox not returning $el.width() correctly

Open tobiasdemaine opened this issue 10 years ago • 2 comments

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());

tobiasdemaine avatar Feb 18 '15 04:02 tobiasdemaine

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

jnicol avatar Mar 03 '15 10:03 jnicol

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

r3wt avatar Feb 07 '17 18:02 r3wt