@@ -379,32 +379,29 @@ FocusScope {
379379 }
380380 }
381381
382− if (item && item.hasOwnProperty("visibleRangeBegin")) {
383− item.visibleRangeBegin = Math.max(-baseItem.y, 0)
384− item.visibleRangeEnd = item.visibleRangeBegin + Math.min(categoryView.height, rendererLoader.height)
385− }
386−
387382 if (item && item.hasOwnProperty("displayMarginBeginning")) {
388− // TODO do we need item.originY here, test 1300302 once we have a silo
389− // and we can run it on the phone
390− if (scopeView.isCurrent) {
391− // 1073741823 is s^30 -1. A quite big number so that you have "infinite" display margin, but not so
392− // big so that if you add if with itself you're outside the 2^31 int range
393− item.displayMarginBeginning = 1073741823;
394− item.displayMarginEnd = 1073741823;
395− } else if (baseItem.y + baseItem.height <= 0) {
396− // Not visible (item at top of the list viewport)
397− item.displayMarginBeginning = -baseItem.height;
398− item.displayMarginEnd = 0;
399− } else if (baseItem.y >= categoryView.height) {
400− // Not visible (item at bottom of the list viewport)
401− item.displayMarginBeginning = 0;
402− item.displayMarginEnd = -baseItem.height;
403− } else {
404− item.displayMarginBeginning = Math.round(-Math.max(-baseItem.y, 0));
405− item.displayMarginEnd = -Math.round(Math.max(baseItem.height - seeAll.height -
406− categoryView.height + baseItem.y, 0));
407− }
383+ // A item view is considered visible from
384+ // -displayMarginBeginning
385+ // to
386+ // height + item.displayMarginEnd
387+ // 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
392+ // 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));
408405 }
409406 }
410407 }