1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-03 15:24:10 +01:00

Performance: Width of scrollbars isn't going to change on a single page

between table's being reinitialised, so calculating the scrollbar width
every time is a real hit on performance since it needs to manipulate the
DOM. This change ensures that the calculation is performed only once.
This commit is contained in:
Allan Jardine 2013-04-06 09:36:44 +01:00
parent 182998a7c5
commit ad0e08585f

View File

@ -378,6 +378,8 @@ function _fnStringToCss( s )
*/ */
function _fnScrollBarWidth () function _fnScrollBarWidth ()
{ {
if ( ! DataTable.__scrollbarWidth )
{
var inner = $('<p/>').css( { var inner = $('<p/>').css( {
width: '100%', width: '100%',
height: 200, height: 200,
@ -408,6 +410,9 @@ function _fnScrollBarWidth ()
outer.remove(); outer.remove();
return w1 - w2; DataTable.__scrollbarWidth = w1 - w2;
}
return DataTable.__scrollbarWidth;
} }