@@ -38,6 +38,7 @@ FocusScope {
3838 readonly property alias subPageShown: subPageLoader.subPageShown
3939 property int paginationCount: 0
4040 property int paginationIndex: 0
41+ property bool visibleToParent: false
4142 property alias pageHeaderTotallyVisible: categoryView.pageHeaderTotallyVisible
4243 property var holdingList: null
4344
@@ -357,6 +358,7 @@ FocusScope {
357358 Connections {
358359 target: scopeView
359360 onIsCurrentChanged: rendererLoader.updateRanges();
361+ onVisibleToParentChanged: rendererLoader.updateRanges();
360362 }
361363 Connections {
362364 target: holdingList
@@ -364,7 +366,9 @@ FocusScope {
364366 }
365367
366368 function updateRanges() {
367− if (holdingList && holdingList.moving) {
369+ // Don't want to create stress by requesting more items during scope
370+ // changes so unless you're not part of the visible scopes just return
371+ if (holdingList && holdingList.moving && !scopeView.visibleToParent) {
368372 return;
369373 }
370374
@@ -380,28 +384,50 @@ FocusScope {
380384 }
381385
382386 if (item && item.hasOwnProperty("displayMarginBeginning")) {
383− // A item view is considered visible from
387+ // A item view creates its delegates synchronously from
384388 // -displayMarginBeginning
385389 // to
386− // height + item.displayMarginEnd
390+ // height + displayMarginEnd
391+ // Around that area it adds the cacheBuffer area where delegates are created async
392+ //
387393 // We adjust displayMarginBeginning and displayMarginEnd so
388− // * In non visible scopes only the viewport is considered visible
389− // that way when you switch to it the visible items are there
390− // * For visible scopes we increase the visible range by categoryView.height * 1.5
391− // in both directions to make scrolling nicer by mantaining a higher number of
394+ // * In non visible scopes nothing is considered visible and we set cacheBuffer
395+ // so that creates the items that would be in the viewport asynchronously
396+ // * For the current scope set the visible range to the viewport and then
397+ // use cacheBuffer to create extra items for categoryView.height * 1.5
398+ // to make scrolling nicer by mantaining a higher number of
392399 // cached items
393− // TODO Improvements
394− // - For non visible scopes we should always have a visible range of 0 and
395− // make sure the items in the viewport are created with the cache buffer feature
396− // - For visible scopes we should always the have a visible range be exactly the
397− // viewport and make sure the rest of items are created with the cache buffer feature
398− // To be able to implement that feature VerticalJournal/AbstractDashView needs to
399− // make the cache buffer value setable externally
400− var extraMargins = scopeView.isCurrent ? categoryView.height * 1.5 : 0;
401−
402− item.displayMarginBeginning = Math.round(-Math.max(-baseItem.y - extraMargins, 0));
403− item.displayMarginEnd = -Math.round(Math.max(baseItem.height - extraMargins - seeAll.height -
404− categoryView.height + baseItem.y, 0));
400+ // * For non current but visible scopes (i.e. when the user changes from one scope
401+ // to the next, we set the visible range to the viewport so
402+ // items are not culled (invisible) but still use no cacheBuffer
403+ // (it will be set once the scope is the current one)
404+ var displayMarginBeginning = baseItem.y;
405+ displayMarginBeginning = -Math.max(-displayMarginBeginning, 0);
406+ displayMarginBeginning = -Math.min(-displayMarginBeginning, baseItem.height);
407+ displayMarginBeginning = Math.round(displayMarginBeginning);
408+ var displayMarginEnd = -baseItem.height + seeAll.height + categoryView.height - baseItem.y;
409+ displayMarginEnd = -Math.max(-displayMarginEnd, 0);
410+ displayMarginEnd = -Math.min(-displayMarginEnd, baseItem.height);
411+ displayMarginEnd = Math.round(displayMarginEnd);
412+ if (scopeView.isCurrent || scopeView.visibleToParent) {
413+ item.displayMarginBeginning = displayMarginBeginning;
414+ item.displayMarginEnd = displayMarginEnd;
415+ item.cacheBuffer = scopeView.isCurrent ? categoryView.height * 1.5 : 0;
416+ } else {
417+ var visibleRange = baseItem.height + displayMarginEnd + displayMarginBeginning;
418+ if (visibleRange < 0) {
419+ item.displayMarginBeginning = displayMarginBeginning;
420+ item.displayMarginEnd = displayMarginEnd;
421+ item.cacheBuffer = 0;
422+ } else {
423+ // This should be visibleRange/2 in each of the properties
424+ // but some item views still (like GridView) like creating sync delegates even if
425+ // the visible range is 0 so let's make sure the visible range is negative
426+ item.displayMarginBeginning = displayMarginBeginning - visibleRange;
427+ item.displayMarginEnd = displayMarginEnd - visibleRange;
428+ item.cacheBuffer = visibleRange;
429+ }
430+ }
405431 }
406432 }
407433 }