on xenial help sign in
More sane way of setting the displayMargin[Begin,End]
commit02cbc37ab78c04f025bfae7a67733746a9823fe5 authorAlbert Astals <albert.astals@canonical.com> dateThu 6 Nov 2014, 16:25 (12 years ago) parent1fc197c
1 file changed+22−19
qml/Dash/GenericScopeView.qml+22−19
qml/Dash/GenericScopeView.qml+22−19
@@ -380,25 +380,28 @@ FocusScope {
380380 }
381381
382382 if (item && item.hasOwnProperty("displayMarginBeginning")) {
383− // TODO do we need item.originY here, test 1300302 once we have a silo
384− // and we can run it on the phone
385− if (baseItem.y + baseItem.height <= 0) {
386− // Not visible (item at top of the list viewport)
387− item.displayMarginBeginning = -baseItem.height;
388− item.displayMarginEnd = 0;
389− } else if (baseItem.y >= categoryView.height) {
390− // Not visible (item at bottom of the list viewport)
391− item.displayMarginBeginning = 0;
392− item.displayMarginEnd = -baseItem.height;
393− } else {
394− item.displayMarginBeginning = Math.round(-Math.max(-baseItem.y, 0));
395− item.displayMarginEnd = -Math.round(Math.max(baseItem.height - seeAll.height -
396− categoryView.height + baseItem.y, 0));
397− if (scopeView.isCurrent) {
398− item.displayMarginBeginning += categoryView.height * 1.5;
399− item.displayMarginEnd += categoryView.height * 1.5;
400− }
401− }
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));
402405 }
403406 }
404407 }