diff --git a/routes/_components/pseudoVirtualList/PseudoVirtualList.html b/routes/_components/pseudoVirtualList/PseudoVirtualList.html index e783e42f..4f735c20 100644 --- a/routes/_components/pseudoVirtualList/PseudoVirtualList.html +++ b/routes/_components/pseudoVirtualList/PseudoVirtualList.html @@ -1,4 +1,6 @@ -
+
{{#if wrappedItems}} {{#each wrappedItems as wrappedItem, i @item}} \ No newline at end of file diff --git a/routes/_components/virtualList/virtualListStore.js b/routes/_components/virtualList/virtualListStore.js index 6c1a91e9..598ab186 100644 --- a/routes/_components/virtualList/virtualListStore.js +++ b/routes/_components/virtualList/virtualListStore.js @@ -20,16 +20,20 @@ virtualListStore.computeForRealm('headerHeight', 0) virtualListStore.computeForRealm('scrollTop', 0) virtualListStore.computeForRealm('scrollHeight', 0) virtualListStore.computeForRealm('offsetHeight', 0) +virtualListStore.computeForRealm('listOffset', 0) virtualListStore.computeForRealm('itemHeights', {}) virtualListStore.compute('rawVisibleItems', - ['items', 'scrollTop', 'itemHeights', 'offsetHeight', 'showHeader', 'headerHeight'], - (items, scrollTop, itemHeights, offsetHeight, showHeader, headerHeight) => { + ['items', 'scrollTop', 'itemHeights', 'offsetHeight', 'showHeader', 'headerHeight', 'listOffset'], + (items, scrollTop, itemHeights, offsetHeight, showHeader, headerHeight, listOffset) => { window.rawVisibleItemsComputed = (window.rawVisibleItemsComputed || 0) + 1 mark('compute visibleItems') if (!items) { return null } + // listOffset is the offset of the entire list within its scrollable container, + // so the effective scrollTop is what the "real" scrollTop is relative to the list. + let effectiveScrollTop = scrollTop - listOffset let renderBuffer = RENDER_BUFFER_FACTOR * offsetHeight let visibleItems = [] let totalOffset = showHeader ? headerHeight : 0 @@ -40,13 +44,13 @@ virtualListStore.compute('rawVisibleItems', let height = itemHeights[key] || 0 let currentOffset = totalOffset totalOffset += height - let isAboveViewport = (currentOffset < scrollTop) + let isAboveViewport = (currentOffset < effectiveScrollTop) if (isAboveViewport) { - if ((scrollTop - height - renderBuffer) > currentOffset) { + if ((effectiveScrollTop - height - renderBuffer) > currentOffset) { continue // above the area we want to render } } else { - if (currentOffset > (scrollTop + offsetHeight + renderBuffer)) { + if (currentOffset > (effectiveScrollTop + offsetHeight + renderBuffer)) { break // below the area we want to render } } diff --git a/routes/_pages/accounts/[accountId].html b/routes/_pages/accounts/[accountId].html index c11c481b..879a681b 100644 --- a/routes/_pages/accounts/[accountId].html +++ b/routes/_pages/accounts/[accountId].html @@ -30,7 +30,6 @@ export default { oncreate() { let accountId = this.get('params').accountId - let instanceName = this.store.get('currentInstance') updateProfileAndRelationship(accountId) }, store: () => store, diff --git a/routes/_utils/getRectFromEntry.js b/routes/_utils/getRectFromEntry.js index 8a0837a1..2d959e36 100644 --- a/routes/_utils/getRectFromEntry.js +++ b/routes/_utils/getRectFromEntry.js @@ -3,16 +3,29 @@ let hasBoundingRectBug +function rectsAreEqual(rectA, rectB) { + return rectA.height === rectB.height && + rectA.top === rectB.top && + rectA.width === rectB.width && + rectA.bottom === rectB.bottom && + rectA.left === rectB.left && + rectA.right === rectB.right +} + export function getRectFromEntry (entry) { if (typeof hasBoundingRectBug !== 'boolean') { const boundingRect = entry.target.getBoundingClientRect() const observerRect = entry.boundingClientRect - hasBoundingRectBug = boundingRect.height !== observerRect.height || - boundingRect.top !== observerRect.top || - boundingRect.width !== observerRect.width || - boundingRect.bottom !== observerRect.bottom || - boundingRect.left !== observerRect.left || - boundingRect.right !== observerRect.right + hasBoundingRectBug = !rectsAreEqual(boundingRect, observerRect) } return hasBoundingRectBug ? entry.target.getBoundingClientRect() : entry.boundingClientRect } + +export function getRootRectFromEntry (entry, root) { + if (typeof hasBoundingRectBug !== 'boolean') { + const boundingRect = root.getBoundingClientRect() + const rootRect = entry.rootBounds + hasBoundingRectBug = !rectsAreEqual(boundingRect, rootRect) + } + return hasBoundingRectBug ? root.getBoundingClientRect() : entry.rootBounds +} \ No newline at end of file