Skip to content

Commit

Permalink
Port virtual list perf improvements from F2V
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Nov 20, 2023
1 parent b4b5950 commit 0b99a22
Show file tree
Hide file tree
Showing 22 changed files with 49 additions and 43 deletions.
4 changes: 2 additions & 2 deletions js/photos-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-main.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-public.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-src_views_FaceContent_vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-src_views_FaceContent_vue.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/components/File.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@
<span class="input-label">{{ t('photos', 'Select image {imageName}', {imageName: file.basename}) }}</span>
</NcCheckboxRadioSwitch>

<Star v-if="file.favorite === 1" class="favorite-state" :aria-label="t('photos', 'The file is in the favorites')" />
<Star v-if="file.favorite === 1"
v-once
class="favorite-state"
:aria-label="t('photos', 'The file is in the favorites')" />
</div>
</template>

Expand Down Expand Up @@ -223,6 +226,7 @@ export default {

<style lang="scss" scoped>
.file-container {
contain: strict;
background: var(--color-primary-element-light);
position: relative;
height: 100%;
Expand Down
26 changes: 14 additions & 12 deletions src/components/VirtualScrolling.vue
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,14 @@ export default {
})

if (this.useWindow) {
window.addEventListener('resize', this.updateContainerSize)
window.addEventListener('resize', this.updateContainerSize, { passive: true })
this.containerHeight = window.innerHeight
} else {
this.resizeObserver.observe(this.container)
}

this.resizeObserver.observe(this.$refs.rowsContainer)
this.container.addEventListener('scroll', this.updateScrollPosition)
this.container.addEventListener('scroll', this.updateScrollPosition, { passive: true })
},

beforeDestroy() {
Expand All @@ -342,16 +342,16 @@ export default {
},

methods: {
// Debouncing by a tiny amount helps a bit to reduce computation cycles.
// From a quick tests, 6 cycle are triggered on a big scroll without debounce.
// This is reduce to 4 with this tiny debounce.
updateScrollPosition: debounce(function() {
if (this.useWindow) {
this.scrollPosition = this.container.scrollY
} else {
this.scrollPosition = this.container.scrollTop
}
}, 5),
updateScrollPosition() {
this._onScrollHandle ??= requestAnimationFrame(() => {
this._onScrollHandle = null
if (this.useWindow) {
this.scrollPosition = this.container.scrollY
} else {
this.scrollPosition = this.container.scrollTop
}
})
},

updateContainerSize() {
this.containerHeight = window.innerHeight
Expand All @@ -368,5 +368,7 @@ export default {

.vs-rows-container {
box-sizing: border-box;
will-change: scroll-position, padding;
contain: layout paint style;
}
</style>

0 comments on commit 0b99a22

Please sign in to comment.