From 2db42367610a99b8732e539067b002edeeb11689 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Mon, 12 Feb 2018 22:32:56 -0800 Subject: [PATCH] more refactoring --- .../pseudoVirtualList/PseudoVirtualList.html | 4 +- routes/_components/timeline/Timeline.html | 38 +++++++------------ .../_components/virtualList/VirtualList.html | 2 +- .../virtualList/VirtualListContainer.html | 4 +- 4 files changed, 18 insertions(+), 30 deletions(-) diff --git a/routes/_components/pseudoVirtualList/PseudoVirtualList.html b/routes/_components/pseudoVirtualList/PseudoVirtualList.html index e417b1ff..0b4fad4c 100644 --- a/routes/_components/pseudoVirtualList/PseudoVirtualList.html +++ b/routes/_components/pseudoVirtualList/PseudoVirtualList.html @@ -43,7 +43,7 @@ this.store.setForRealm({intersectionStates: intersectionStates}) this.set({intersectionObserver: new IntersectionObserver(this.onIntersection.bind(this), { - root: document.querySelector('.container'), + root: document.querySelector(this.get('containerQuery')), rootMargin: '300% 0px' })}) this.observe('allItemsHaveHeight', allItemsHaveHeight => { @@ -80,7 +80,7 @@ } this.set({scrolledToPosition: true}) console.log('scrollToPosition', rect.top) - let container = document.querySelector('.container') + let container = document.querySelector(this.get('containerQuery')) if (!container) { return } diff --git a/routes/_components/timeline/Timeline.html b/routes/_components/timeline/Timeline.html index 08b100b7..162634a5 100644 --- a/routes/_components/timeline/Timeline.html +++ b/routes/_components/timeline/Timeline.html @@ -7,46 +7,33 @@ {{#if !$initialized}} {{/if}} - {{#if timelineType === 'notifications'}} - - {{elseif virtual}} - {{else}} - {{/if}} @@ -90,13 +77,14 @@ this.teardownFocus() }, data: () => ({ - StatusVirtualListItem, - NotificationVirtualListItem, LoadingFooter, MoreHeaderVirtualWrapper, Status }), computed: { + VirtualListComponent: (timelineType) => { + return timelineType === 'notifications' ? NotificationVirtualListItem : StatusVirtualListItem + }, makeProps: ($currentInstance, timelineType, timelineValue) => async (itemId) => { let res = { timelineType, timelineValue } if (timelineType === 'notifications') { diff --git a/routes/_components/virtualList/VirtualList.html b/routes/_components/virtualList/VirtualList.html index b0582755..954f48c9 100644 --- a/routes/_components/virtualList/VirtualList.html +++ b/routes/_components/virtualList/VirtualList.html @@ -1,4 +1,4 @@ - +
{{#if $visibleItems}} diff --git a/routes/_components/virtualList/VirtualListContainer.html b/routes/_components/virtualList/VirtualListContainer.html index 11128624..cd4450a0 100644 --- a/routes/_components/virtualList/VirtualListContainer.html +++ b/routes/_components/virtualList/VirtualListContainer.html @@ -10,7 +10,7 @@ export default { oncreate() { mark('onCreate VirtualListContainer') - let node = document.querySelector('.container') + let node = document.querySelector(this.get('containerQuery')) this.setupScroll(node) this.setupFullscreen() this.store.setCurrentRealm(this.get('realm')) @@ -58,7 +58,7 @@ node.addEventListener('scroll', this.scrollListener) }, teardownScroll() { - let node = document.querySelector('.container') + let node = document.querySelector(this.get('containerQuery')) if (node) { node.removeEventListener('scroll', this.scrollListener) }