Vertical Scrolling Errors with Fixed Columns
Vertical Scrolling Errors with Fixed Columns
Good day, I was wondering if anyone else has encountered scrolling errors on android and iphone devices when using fixed columns. Here is a link to the site I am developing using Datatables.
magento.industrial-hardware.com/framing-channel-fittings-strut/channel-strut-nuts/channel-nuts.html
On Android there is a slight delay when scrolling on the left or right side. If I vertical scroll on the left the right side is a few milliseconds behind, the same goes when I vertical scroll on the left the right has a slight delay.
Here is a video of the error
https://www.youtube.com/watch?v=IRNeJqadcGc&feature=youtu.be
I received this error when I was debugging
On Iphone I'm having numerous errors but the one that concerns me is the vertical scroll at 25 seconds
https://www.youtube.com/watch?v=T1pyrirON4E&feature=youtu.be
Answers
I didn't find your Datatable init code but it looks like you are using fixedHeader and scrollX and scrollY. The docs states these features are incompatible:
https://datatables.net/extensions/fixedheader/
Not sure why you are seeing the delays or errors in scrolling but it could be in part due to these incompatibilities.
Kevin
Using a passive event listener as already been mentioned here.
You mention that there is a slight delay at the moment - but if I were to use a passive event listener, then the alignment would be delayed until the scrolling has stopped.
Allan
I'm a little confused here because the link that is shared directs me to Lighthouse (Google's audit tool). When I run the audit tool I get one suggestion for a passive listener line 4341 in jquery
This looks like it has nothing to do with the scrolling errors I am receiving.
From what I understand it looks like this piece of code in fixedcolumns.js is where the scrolling issue is occurring
// When the body is scrolled - scroll the left and right columns
$(this.dom.scroller)
.on( 'mouseover.DTFC touchstart.DTFC', function () {
if ( ! mouseDown ) {
mouseController = 'main';
}
} )
.on( 'scroll.DTFC', function (e) {
if ( ! mouseController && e.originalEvent ) {
mouseController = 'main';
}
However according to the instructions in the given google link there is nowhere to add the passive event listener
I think it boils down to basically the same thing - FixedColumns is updating the DOM inside the event listener. That action makes it not passive (active?). Looks like different tools just have different ways of reporting it.
To resolve the code needs to be updated to either not keep the fixed element's scrolling in sync while scrolling is happening (I can already see the bug reports coming in about that), or using a debounce / throttle, which might work - I'm a little concerned about how smooth it will be, but it is worth experimenting with.
Allan