enyojs/enyo — pull request #966 by graynorton (2014-12-15 16:30:28+00:00)
Title: ENYO-655: DataList page-positioning issue after adding models

In some circumstances, the vertical delegate's page-positioning
logic was failing after adding models to a DataList's collection.

Specifically, there is an optimization in modelsAdded() to avoid
regenerating list pages in the case where the models added are all
later in the list than the currently rendered pages. In this case,
we skip page generation and merely adjust page positions, using
cached metrics to calculate the position of each page.

It turns out that this approach has recently been positioning pages
inaccurately, due to a fix we made for another page-positioning
issue. To address ENYO-476, we started invalidating our cached page
metrics whenever we update our controlsPerPage calculation to
ensure that pages are positioned properly during / after a list
resize. While this fixed the resize issue, it ended up causing the
problem observed in ENYO-655.

We now move our cache-invalidation logic from controlsPerPage() to
didResize(), preserving the fix for the resizing issue while fixing
the modelsAdded() issue.

It's possible that this change is swinging too far back in the
other direction; in theory, the cached page size metrics should be
flushed whenever controlsPerPage changes, since they can no longer
be valid. However, it looks like we would need to do some more
significant reworking of the fairly complicated measurement and
page generation logic in vertical delegate to flush the cache at
this point in time without unwanted effects. The fix I'm submitting
addresses known issues and should be relatively low-risk.

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