From 924e803d167b5b4dd485a3e42ac944ea15eea8be Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sun, 21 Jan 2018 16:07:11 -0800 Subject: [PATCH] add loading footer --- routes/_components/LoadingFooter.html | 26 ++++++++++++++++++++++ routes/_components/LoadingSpinner.html | 6 ++--- routes/_components/Timeline.html | 6 ++++- routes/_components/VirtualList.html | 22 ++++++++++++------ routes/_components/VirtualListFooter.html | 27 +++++++++++++++++++++++ routes/_utils/virtualListStore.js | 13 ++++++++++- 6 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 routes/_components/LoadingFooter.html create mode 100644 routes/_components/VirtualListFooter.html diff --git a/routes/_components/LoadingFooter.html b/routes/_components/LoadingFooter.html new file mode 100644 index 00000000..c9c3e39b --- /dev/null +++ b/routes/_components/LoadingFooter.html @@ -0,0 +1,26 @@ + + + \ No newline at end of file diff --git a/routes/_components/LoadingSpinner.html b/routes/_components/LoadingSpinner.html index fb2e844e..c9ef9963 100644 --- a/routes/_components/LoadingSpinner.html +++ b/routes/_components/LoadingSpinner.html @@ -1,10 +1,10 @@ - +
{{#each $visibleItems as item @key}} - + {{/each}} + {{#if $showFooter}} + + {{/if}}
\ No newline at end of file diff --git a/routes/_utils/virtualListStore.js b/routes/_utils/virtualListStore.js index d0f18ee5..32b7ea72 100644 --- a/routes/_utils/virtualListStore.js +++ b/routes/_utils/virtualListStore.js @@ -42,6 +42,8 @@ class VirtualListStore extends Store { const virtualListStore = new VirtualListStore({ items: [], itemHeights: {}, + showFooter: false, + footerHeight: 0 }) virtualListStore.compute('visibleItems', @@ -79,7 +81,9 @@ virtualListStore.compute('visibleItems', return visibleItems }) -virtualListStore.compute('height', ['items', 'itemHeights'], (items, itemHeights) => { +virtualListStore.compute('heightWithoutFooter', + ['items', 'itemHeights'], + (items, itemHeights) => { let sum = 0 let i = -1 let len = items.length @@ -89,6 +93,13 @@ virtualListStore.compute('height', ['items', 'itemHeights'], (items, itemHeights return sum }) + +virtualListStore.compute('height', + ['heightWithoutFooter', 'showFooter', 'footerHeight'], + (heightWithoutFooter, showFooter, footerHeight) => { + return showFooter ? (heightWithoutFooter + footerHeight) : heightWithoutFooter +}) + virtualListStore.compute('numItems', ['items'], (items) => items.length) if (process.browser && process.env.NODE_ENV !== 'production') {