I am trying to make a sticky header + first column table. Works well on desktop browsers.
However, when I scroll the x axis of the table on the mobile device, the position update moves, that is, not fast enough.
I read various SO streams that iScroll offer. I am not sure how to use it correctly in this case. Should you catch the tbody scroll event, execute the default behavior, and update the position based on the values โโof the iScroll event? Please point me in the right direction :)
$(function() { var $tbody = $('tbody'); $tbody.on('scroll', function(e) { var left = $tbody.scrollLeft(); $('thead').css('left', -left); $('tbody td:nth-child(1), thead th:nth-child(1)').css('left', left); }); var iScroll = new IScroll($tbody[0], { probeType: 3 }); iScroll.on('scroll', function(){ console.log('not fired?'); }); });
https://jsfiddle.net/97r799gr/
To reproduce the problem, it is probably easiest for you to visit https://jsfiddle.net/97r799gr/show on your mobile phone. I use the edge of SGS7, so I think it will play on almost any mobile device.
javascript jquery iscroll
Johan
source share