tree: Improve logic around rendering child levels

* Don't bother creating a preload node when not using OnDemandList
* Create preload nodes at both ends of the child level and improve code flow
* Simplify OnDemandList#renderQuery arguments (preloadNode no longer needed)
OnDemandList: Improve scroll-direction-detecting logic

When tree is used, its top preload node will also have a rowIndex of 0, so
this check wrongly assumed that it is above, even if it isn't.

We still check rowIndex first because it's cheaper than checking offsetTop,
and this is still not a 100% accurate fix if the user scrolls very fast.
Fix typos in JsonRest test page