Scroller: Fix slow fixed column scrolling in Firefox. See #135

This commit is contained in:
Mottie 2015-05-21 12:42:42 -05:00
parent 0bfe3099da
commit 06d69c75b3

View File

@ -371,7 +371,10 @@ ts.scroller = {
$table = c.$table, $table = c.$table,
namespace = c.namespace + 'tsscrollerFixed', namespace = c.namespace + 'tsscrollerFixed',
$wrapper = wo.scroller_$container, $wrapper = wo.scroller_$container,
fixedColumns = wo.scroller_fixedColumns; fixedColumns = wo.scroller_fixedColumns,
$mainTableWrapper = c.$table.parent(),
fixedScroll = true,
tableScroll = true;
$fixedColumn = $wrapper $fixedColumn = $wrapper
.addClass( tscss.scrollerHasFix ) .addClass( tscss.scrollerHasFix )
@ -448,13 +451,25 @@ ts.scroller = {
// *** SCROLL *** scroll fixed column along with main // *** SCROLL *** scroll fixed column along with main
.off( 'scroll' + namespace ) .off( 'scroll' + namespace )
.on( 'scroll' + namespace, function() { .on( 'scroll' + namespace, function() {
$fixedTbody.scrollTop( $( this ).scrollTop() ); // using flags to prevent firing the scroll event excessively leading to slow scrolling in Firefox
var scrollPosition = $( this ).scrollTop();
if ( fixedScroll && $fixedTbody.scrollTop() !== scrollPosition ) {
tableScroll = false;
$fixedTbody[0].scrollTop = scrollPosition;
setTimeout(function(){ tableScroll = true; }, 20);
}
}); });
// scroll main along with fixed column // scroll main along with fixed column
$fixedTbody $fixedTbody
.off( 'scroll' + namespace ) .off( 'scroll' + namespace )
.on( 'scroll' + namespace, function() { .on( 'scroll' + namespace, function() {
c.$table.parent().scrollTop( $fixedTbody.scrollTop() ); // using flags to prevent firing the scroll event excessively leading to slow scrolling in Firefox
var scrollPosition = $fixedTbody.scrollTop();
if ( tableScroll && $mainTableWrapper.scrollTop !== scrollPosition ) {
fixedScroll = false;
$mainTableWrapper[0].scrollTop = scrollPosition;
setTimeout(function(){ fixedScroll = true; }, 20);
}
}) })
.scroll(); .scroll();