jnicol / trackpad-scroll-emulator

A jQuery plugin that emulates OSX trackpad-style scrollbars in any browser or platform.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fire fox not returning $el.width() correctly

tobiasdemaine opened this issue · 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());

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

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