Skip to content
Permalink
Browse files

Make the top and bottom of the scrolling area, when virtual scrolling…

…, linear for a better interface
  • Loading branch information...
Allan Jardine
Allan Jardine committed Jul 28, 2018
1 parent 2f55821 commit 58f0bbc8aafbea3f0777916e915cb5387380f7b3
Showing with 14 additions and 3 deletions.
  1. +1 −1 examples/initialisation/server-side_processing.xml
  2. +13 −2 js/dataTables.scroller.js
@@ -29,7 +29,7 @@ $(document).ready(function() {
scroller: {
loadingIndicator: true
},
stateSave: true
//stateSave: true
} );
} );
]]>
@@ -789,15 +789,26 @@ $.extend( Scroller.prototype, {
return val;
}

// In the first 10k pixels and the last 10k pixels, we want the scrolling
// to be linear. After that it can be non-linear. It would be unusual for
// anyone to mouse wheel through that much.
if ( val < 10000 ) {
return val;
}
else if ( val > heights.scroll - 10000 ) {
var diff = heights.scroll - val;
return heights.virtual - diff;
}

// Otherwise, we want a non-linear scrollbar to take account of the
// redrawing regions at the start and end of the table, otherwise these
// can stutter badly - on large tables 30px (for example) scroll might
// be hundreds of rows, so the table would be redrawing every few px at
// the start and end. Use a simple quadratic to stop this. It does mean
// the scrollbar is non-linear, but with such massive data sets, the
// scrollbar is going to be a best guess anyway
var xMax = (heights.scroll - heights.viewport) / 2;
var yMax = (heights.virtual - heights.viewport) / 2;
var xMax = (heights.scroll - heights.viewport - 10000) / 2;
var yMax = (heights.virtual - heights.viewport - 10000) / 2;

coeff = yMax / ( xMax * xMax );

0 comments on commit 58f0bbc

Please sign in to comment.
You can’t perform that action at this time.