Scroller not triggering row renders when using keyboard

Scroller not triggering row renders when using keyboard

rewenrewen Posts: 74Questions: 2Answers: 0
edited August 2012 in Bug reports
Hi Allan,

I just noticed a potential bug in Scroller where if you do not first use the mouse to scroll the table and instead use the keyboard arrows or manual setting of scrollTop on the scrollBody then as the scroll coordinates seem to be allowed to surpass the boundary without triggering a redraw.

Once I scroll with the mouse then everything (including keyboard scrolling and setting scrollTop) starts to trigger rendering properly as the boundary is obeyed as expected.

Looking at the trace log I see lines like this:

Scroll: 1668px - boundaries: 0 / 990.5. Showing rows 52 to 77 in the viewport, with rows 0 to 80 rendered by the DataTable

Scroller seems aware that it should have re-rendered once the scroll value passed 990.5, but has ignored it.

I'm using Scroller 1.1.0 with DataTables 1.9.4.dev (also tested with 1.9.3 and 1.9.2).

Cheers,

Ryan

Replies

  • rewenrewen Posts: 74Questions: 2Answers: 0
    Actually upon further investigation it seems like the boundary is always ignored for the first set of rows drawn and you must be waiting for the viewport to run out of rows before triggering a redraw.

    After the first redraw the boundary is enforced properly.
  • rewenrewen Posts: 74Questions: 2Answers: 0
    I just found that if I call fnDraw(false) then things work as expected. It lengthens page load slightly since I have a large datatset but it works.

    I should also mention that I have sScrollY set to 500px but I am immediately changing that via JS to a size that fits the page better. I am doing this after I add my data (local JS array) like so:

    // update datatables internal var
    dom.table.fnSettings().oScroll.sY = h + 'px';

    // adjust table css to match
    scrollbody.height(h);

    // ask scroller plugin to re-measure
    dom.table.fnSettings().oScroller.fnMeasure(false);
  • rewenrewen Posts: 74Questions: 2Answers: 0
    Scratch that. Forcing a redraw doesn't seem to do anything.
  • rewenrewen Posts: 74Questions: 2Answers: 0
    Forgot to mention - the reason that this is an issue is that I've run into times where scrolling stops at the bottom of the first set causing the user to think they're at the end of the table. Only when they start using their mouse instead of the keyboard will they see the rest of the data begin to load.

    I'm not sure why this sometimes happens.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    How do you use the keyboard to navigate the scrolling element? I wasn't aware you could do that :-)

    Allan
  • rewenrewen Posts: 74Questions: 2Answers: 0
    edited September 2012
    Keyboard scrolling works just by clicking within the scrollable area and using the arrow keys. :)

    In fact, this same thing happens in your example here, too: http://datatables.net/release-datatables/extras/Scroller/index.html

    If you click on a row (anywhere in any visible row) and then hold the down arrow key, you will find that sometimes scrolling stops prematurely.

    The first time it stopped at row 69 for me. After reloading it was row 46. Then 10, then 46 again. I'm not sure why the differences.
  • rewenrewen Posts: 74Questions: 2Answers: 0
    Sorry to keep spamming!

    I just noticed that in your example, scrolling with the mouse doesn't fix keyboard scrolling like it does for mine.

    In the example I have to keep clicking the table every so often as it gets stuck in order to continue keyboard scrolling.

    In mine I only have to scroll or click once after it gets stuck and then it doesn't seem to get stuck again.

    Not sure if that helps at all, lol, but it's an observation.
This discussion has been closed.