enyojs/moonstone — pull request #1766 by aarontam (2014-11-15 01:22:20+00:00)
Title: ENYO-454: Update paging control state minimally during scrolling.

###. Issue
Before we streamlined the logic for displaying the paging controls for BHV-15753, the disabled state of the paging controls would be calculated in `_getScrollBounds` for each `onscroll` event. This allowed for an instance during scrolling where the top paging control became disabled with the bottom paging control enabled (due to overscrolling, which allows this to occur before `onScrollStop` normally fires), as once the top paging button is pressed, the bottom paging button will become enabled during scrolling. The opposite was also true (bottom paging control was disabled while the top paging control was still enabled). In Spotlight, when a control becomes disabled, we attempt to spot the last spotted control before spotting the first spottable control on the page. With the aforementioned fix, we eliminated the tight-coupling between the update of the paging control state and the logic in `_getScrollBounds`, as we are running this logic in response to {{onScrollMathStop}} and no longer for each {{onscroll}} event. Thus the setting of the disabled states is ordered in such a way that we always set the disabled state for the top paging control first, which triggers Spotlight logic to determine the last spotted control; at this point, we have not had a chance to update the bottom paging control yet (as it is still disabled), and so Spotlight spots the first child of the root. If we reverse the order of these calls, we have the opposite problem.

### Fix
The naïve approach might be to call `updatePagingControlState` in response to `onScroll` events from ScrollMath. Though this is technically what was occurring before the original fix, it seems very wasteful, especially because this is primarily an issue for controls where content requires one or fewer scroll "actions" to scroll the entirety of the content. Instead, we can take advantage of the fact that the scroll state we care about occurs when we are in overscroll, and thus we only make this call when overscrolling.

Enyo-DCO-1.1-Signed-off-by: Aaron Tam