1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-03-15 16:29:16 +01:00

Fix: The scrollbar width calculation could sometimes be wrong when trying to calculate the size of the bar due to CSS styles. The inner P element could be given padding for example which would result in the scrollbar width being wrong and thus any calculations later on witht he scrollbar width would be incorrect.

This commit is contained in:
Allan Jardine 2011-08-07 14:57:06 +01:00
parent 1c8f1e3465
commit 88932adb92

View File

@ -6508,32 +6508,34 @@
*/
function _fnScrollBarWidth ()
{
var inner = document.createElement('p');
var inner = document.createElement('p');
var style = inner.style;
style.width = "100%";
style.height = "200px";
style.width = "100%";
style.height = "200px";
style.padding = "0px";
var outer = document.createElement('div');
var outer = document.createElement('div');
style = outer.style;
style.position = "absolute";
style.top = "0px";
style.left = "0px";
style.visibility = "hidden";
style.width = "200px";
style.height = "150px";
style.overflow = "hidden";
outer.appendChild(inner);
style.position = "absolute";
style.top = "0px";
style.left = "0px";
style.visibility = "hidden";
style.width = "200px";
style.height = "150px";
style.padding = "0px";
style.overflow = "hidden";
outer.appendChild(inner);
document.body.appendChild(outer);
var w1 = inner.offsetWidth;
outer.style.overflow = 'scroll';
var w2 = inner.offsetWidth;
document.body.appendChild(outer);
var w1 = inner.offsetWidth;
outer.style.overflow = 'scroll';
var w2 = inner.offsetWidth;
if ( w1 == w2 )
{
w2 = outer.clientWidth;
w2 = outer.clientWidth;
}
document.body.removeChild(outer);
document.body.removeChild(outer);
return (w1 - w2);
}