@@ -38,6 +38,7 @@ FocusScope {
38 readonly property alias subPageShown: subPageLoader.subPageShown
38 readonly property alias subPageShown: subPageLoader.subPageShown
39 property int paginationCount: 0
39 property int paginationCount: 0
40 property int paginationIndex: 0
40 property int paginationIndex: 0
41+ property bool visibleToParent: false
41 property alias pageHeaderTotallyVisible: categoryView.pageHeaderTotallyVisible
42 property alias pageHeaderTotallyVisible: categoryView.pageHeaderTotallyVisible
42 property var holdingList: null
43 property var holdingList: null
@@ -357,6 +358,7 @@ FocusScope {
357 Connections {
358 Connections {
358 target: scopeView
359 target: scopeView
359 onIsCurrentChanged: rendererLoader.updateRanges();
360 onIsCurrentChanged: rendererLoader.updateRanges();
361+ onVisibleToParentChanged: rendererLoader.updateRanges();
361 Connections {
363 Connections {
362 target: holdingList
364 target: holdingList
@@ -364,7 +366,9 @@ FocusScope {
366 function updateRanges() {
368 function updateRanges() {
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
367− if (holdingList && holdingList.moving) {
371+ if (holdingList && holdingList.moving && !scopeView.visibleToParent) {
@@ -380,28 +384,50 @@ FocusScope {
382 if (item && item.hasOwnProperty("displayMarginBeginning")) {
386 if (item && item.hasOwnProperty("displayMarginBeginning")) {
383− // A item view is considered visible from
387+ // A item view creates its delegates synchronously from
384 // -displayMarginBeginning
388 // -displayMarginBeginning
386− // height + item.displayMarginEnd
390+ // height + displayMarginEnd
391+ // Around that area it adds the cacheBuffer area where delegates are created async
387 // We adjust displayMarginBeginning and displayMarginEnd so
393 // We adjust displayMarginBeginning and displayMarginEnd so
388− // * In non visible scopes only the viewport is considered visible
394+ // * In non visible scopes nothing is considered visible and we set cacheBuffer
389− // that way when you switch to it the visible items are there
395+ // so that creates the items that would be in the viewport asynchronously
390− // * For visible scopes we increase the visible range by categoryView.height * 1.5
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
391− // in both directions to make scrolling nicer by mantaining a higher number of
398+ // to make scrolling nicer by mantaining a higher number of
392 // cached items
399 // cached items
393− // TODO Improvements
400+ // * For non current but visible scopes (i.e. when the user changes from one scope
394− // - For non visible scopes we should always have a visible range of 0 and
401+ // to the next, we set the visible range to the viewport so
395− // make sure the items in the viewport are created with the cache buffer feature
402+ // items are not culled (invisible) but still use no cacheBuffer
396− // - For visible scopes we should always the have a visible range be exactly the
403+ // (it will be set once the scope is the current one)
397− // viewport and make sure the rest of items are created with the cache buffer feature
404+ var displayMarginBeginning = baseItem.y;
398− // To be able to implement that feature VerticalJournal/AbstractDashView needs to
405+ displayMarginBeginning = -Math.max(-displayMarginBeginning, 0);
399− // make the cache buffer value setable externally
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;
400− var extraMargins = scopeView.isCurrent ? categoryView.height * 1.5 : 0;
415+ item.cacheBuffer = scopeView.isCurrent ? categoryView.height * 1.5 : 0;
402− item.displayMarginBeginning = Math.round(-Math.max(-baseItem.y - extraMargins, 0));
417+ var visibleRange = baseItem.height + displayMarginEnd + displayMarginBeginning;
403− item.displayMarginEnd = -Math.round(Math.max(baseItem.height - extraMargins - seeAll.height -
418+ if (visibleRange < 0) {
404− categoryView.height + baseItem.y, 0));
419+ item.displayMarginBeginning = displayMarginBeginning;
420+ item.displayMarginEnd = displayMarginEnd;
421+ item.cacheBuffer = 0;
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;