@@ -1,5 +1,5 @@
2− * Copyright (C) 2013-2014 Canonical, Ltd.
2+ * Copyright (C) 2013-2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -401,59 +401,102 @@ FocusScope {
403 if (item && item.hasOwnProperty("displayMarginBeginning")) {
403 if (item && item.hasOwnProperty("displayMarginBeginning")) {
404+ if (item.growsVertically) {
404− // A item view creates its delegates synchronously from
405+ // A item view creates its delegates synchronously from
405− // -displayMarginBeginning
406+ // -displayMarginBeginning
407− // height + displayMarginEnd
408+ // height + displayMarginEnd
408− // Around that area it adds the cacheBuffer area where delegates are created async
409+ // Around that area it adds the cacheBuffer area where delegates are created async
410− // We adjust displayMarginBeginning and displayMarginEnd so
411+ // We adjust displayMarginBeginning and displayMarginEnd so
411− // * In non visible scopes nothing is considered visible and we set cacheBuffer
412+ // * In non visible scopes nothing is considered visible and we set cacheBuffer
412− // so that creates the items that would be in the viewport asynchronously
413+ // so that creates the items that would be in the viewport asynchronously
413− // * For the current scope set the visible range to the viewport and then
414+ // * For the current scope set the visible range to the viewport and then
414− // use cacheBuffer to create extra items for categoryView.height * 1.5
415+ // use cacheBuffer to create extra items for categoryView.height * 1.5
415− // to make scrolling nicer by mantaining a higher number of
416+ // to make scrolling nicer by mantaining a higher number of
416− // cached items
417+ // cached items
417− // * For non current but visible scopes (i.e. when the user changes from one scope
418+ // * For non current but visible scopes (i.e. when the user changes from one scope
418− // to the next, we set the visible range to the viewport so
419+ // to the next, we set the visible range to the viewport so
419− // items are not culled (invisible) but still use no cacheBuffer
420+ // items are not culled (invisible) but still use no cacheBuffer
420− // (it will be set once the scope is the current one)
421+ // (it will be set once the scope is the current one)
421− var displayMarginBeginning = baseItem.y;
422+ var displayMarginBeginning = baseItem.y;
422− displayMarginBeginning = -Math.max(-displayMarginBeginning, 0);
423+ displayMarginBeginning = -Math.max(-displayMarginBeginning, 0);
423− displayMarginBeginning = -Math.min(-displayMarginBeginning, baseItem.height);
424+ displayMarginBeginning = -Math.min(-displayMarginBeginning, baseItem.height);
424− displayMarginBeginning = Math.round(displayMarginBeginning);
425+ displayMarginBeginning = Math.round(displayMarginBeginning);
425− var displayMarginEnd = -baseItem.height + seeAll.height + categoryView.height - baseItem.y;
426+ var displayMarginEnd = -baseItem.height + seeAll.height + categoryView.height - baseItem.y;
426− displayMarginEnd = -Math.max(-displayMarginEnd, 0);
427+ displayMarginEnd = -Math.max(-displayMarginEnd, 0);
427− displayMarginEnd = -Math.min(-displayMarginEnd, baseItem.height);
428+ displayMarginEnd = -Math.min(-displayMarginEnd, baseItem.height);
428− displayMarginEnd = Math.round(displayMarginEnd);
429+ displayMarginEnd = Math.round(displayMarginEnd);
429− if (scopeView.isCurrent || scopeView.visibleToParent) {
431+ if (scopeView.isCurrent || scopeView.visibleToParent) {
430− item.displayMarginBeginning = displayMarginBeginning;
432+ item.displayMarginBeginning = displayMarginBeginning;
431− item.displayMarginEnd = displayMarginEnd;
433+ item.displayMarginEnd = displayMarginEnd;
432− if (holdingList && holdingList.moving) {
434+ if (holdingList && holdingList.moving) {
433− // If we are moving we need to reset the cache buffer of the
435+ // If we are moving we need to reset the cache buffer of the
434− // view that was not visible (i.e. !wasCurrentOnMoveStart) to 0 since
436+ // view that was not visible (i.e. !wasCurrentOnMoveStart) to 0 since
435− // otherwise the cache buffer we had set to preload the items of the
437+ // otherwise the cache buffer we had set to preload the items of the
436− // visible range will trigger some item creations and we want move to
438+ // visible range will trigger some item creations and we want move to
437− // be as smooth as possible meaning no need creations
439+ // be as smooth as possible meaning no need creations
438− if (!wasCurrentOnMoveStart) {
440+ if (!wasCurrentOnMoveStart) {
441+ item.cacheBuffer = 0;
439− item.cacheBuffer = 0;
444+ item.cacheBuffer = categoryView.height * 1.5;
442− item.cacheBuffer = categoryView.height * 1.5;
447+ var visibleRange = baseItem.height + displayMarginEnd + displayMarginBeginning;
448+ if (visibleRange < 0) {
449+ item.displayMarginBeginning = displayMarginBeginning;
450+ item.displayMarginEnd = displayMarginEnd;
451+ item.cacheBuffer = 0;
453+ // This should be visibleRange/2 in each of the properties
454+ // but some item views still (like GridView) like creating sync delegates even if
455+ // the visible range is 0 so let's make sure the visible range is negative
456+ item.displayMarginBeginning = displayMarginBeginning - visibleRange;
457+ item.displayMarginEnd = displayMarginEnd - visibleRange;
458+ item.cacheBuffer = visibleRange;
445− var visibleRange = baseItem.height + displayMarginEnd + displayMarginBeginning;
462+ var buffer = wasCurrentOnMoveStart ? categoryView.height * 1.5 : 0;
446− if (visibleRange < 0) {
463+ var onViewport = baseItem.y + baseItem.height > 0 &&
464+ baseItem.y < categoryView.height;
465+ var onBufferViewport = baseItem.y + baseItem.height > -buffer &&
466+ baseItem.y < categoryView.height + buffer;
467+ if (!onBufferViewport) {
468+ // If not on the buffered viewport, don't load anything
447− item.displayMarginBeginning = displayMarginBeginning;
469+ item.displayMarginBeginning = 0;
448− item.displayMarginEnd = displayMarginEnd;
470+ item.displayMarginEnd = -item.innerWidth;
449 item.cacheBuffer = 0;
471 item.cacheBuffer = 0;
451− // This should be visibleRange/2 in each of the properties
473+ if (onViewport && (scopeView.isCurrent || scopeView.visibleToParent)) {
452− // but some item views still (like GridView) like creating sync delegates even if
474+ // If on the buffered viewport and the viewport and the on a visible scope
453− // the visible range is 0 so let's make sure the visible range is negative
475+ // Set displayMargin so that cards are rendered
476+ // And if not moving the parent list also give it some extra asynchronously
478+ item.displayMarginBeginning = 0;
479+ item.displayMarginEnd = 0;
480+ if (holdingList && holdingList.moving) {
481+ // If we are moving we need to reset the cache buffer of the
482+ // view that was not visible (i.e. !wasCurrentOnMoveStart) to 0 since
483+ // otherwise the cache buffer we had set to preload the items of the
484+ // visible range will trigger some item creations and we want move to
485+ // be as smooth as possible meaning no need creations
486+ if (!wasCurrentOnMoveStart) {
487+ item.cacheBuffer = 0;
490+ item.cacheBuffer = baseItem.width * 1.5;
493+ // If on the buffered viewport but either not in the real viewport
494+ // or in the viewport of the non current scope, use displayMargin + cacheBuffer
495+ // to render asynchronously the width of cards
454− item.displayMarginBeginning = displayMarginBeginning - visibleRange;
496+ item.displayMarginBeginning = 0;
455− item.displayMarginEnd = displayMarginEnd - visibleRange;
497+ item.displayMarginEnd = -item.innerWidth;
456− item.cacheBuffer = visibleRange;
498+ item.cacheBuffer = item.innerWidth;