enyojs/enyo — pull request #935 by graynorton (2014-11-19 23:20:08+00:00)
Title: ENYO-473, 485, 476, 477: More Scroller / DataList issues

This pull request addresses a number of scroller-related issues.
It contains quite a few changes so should be tested thoroughly
against a wide range of existing samples. I worked primarily with
the DataListScrollTestbed sample, but also did sanity checks
against most of the List samples in the Layout library and against
a wide variety of Moonstone samples (various scroll samples,
DataList, DataGridList, etc.). Issues:

* ENYO-473: With TranslateScrollStrategy, it was sometimes possible
to scroll to an invalid position (outside the actual boundaries
of the scrollable content) if the size of the content happened to
change during (perhaps as a result of) the scrolling action. This
situation could easily occur when using DataList, since DataList
constantly updates the size of the "buffer" it uses to represent
the list's full size. When this happened, the contents of the
scroller would disappear from view.

The easiest way to see this
was to use DataListScrollTestbed, choose the "Translate
(Optimized)" option, and tap "Scroll to Bottom" (as described in
ENYO-473). Although harder to reproduce, you could also make this
happen on a Mac with Magic Trackpad by choosing either of the two
Translate options and rapidly scrolling up and down by scrolling
with the trackpad.

The issue didn't occur for other scroll
strategies (including the non-optimized flavor of Translate)
because those strategies set the native scrollLeft / scrollTop
properties of a scrollable region, resulting in automatic
correction of out-of-bounds values. Because the optimized flavor
of Translate uses its own CSS-translation-based scrolling method,
it needs to manually call ScrollMath's stabilize() method at key
points to ensure that out-of-bounds values are corrected.

* ENYO-485: After a recent change to fix issues with setting and
restoring scroll position for a hidden scroller (ENYO-371),
the SmartShare app started taking longer to launch (specifically
to make its first paint). This regression appears to have been
indirectly caused by some additional calls to
ScrollMath.stabilize() introduced by the fix for ENYO-371. These
calls to stabilize in turn resulted in the firing of onScroll
events, which themselves triggered expensive layout and paint
operations in the app. To address this issue, I changed the way
that ScrollMath.stabilize() works. It now fires an explicit
onStabilize event instead of firing onScrollStart, onScroll and
onScrollStop in sequence, and Touch and TranslateScrollStrategy
have been updated accordingly. This should reduce extraneous
onScroll events in many circumstances.

* ENYO-476: DataList was not properly refreshing when resized. This
was because cached page-size metrics were not being invalidated
after a resize.

* ENYO-477: In TouchScrollStrategy and subkinds, the scroll thumbs
would often disappear unexpectedly while scrolling was still
in progress. This is a regression that occurred between 2.4.0 and
2.5.0, most likely due to changes in when onScrollStop events
fire. To ensure that this won't happen, we explicitly show the
thumbs (thus canceling any scheduled "hide" operations) in our
onScroll handler, not onScrollStart. Because we were already
adjusting the thumbs' position on every event and Thumb guards
against redundant DOM changes in its setShowing() method, there
seems to be little to no performance penalty for this change.

Enyo-DCO-1.1-Signed-Off-By: Gray Norton (gray.norton@lge.com)