This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2266 from owncloud/move-lazy-loading-to-tr
Move table lazy loading from OcTd to OcTr
- Loading branch information
Showing
5 changed files
with
105 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
Bugfix: Lazy loading render performance | ||
|
||
The render performance of the lazy loading option in tables (OcTable, OcTableSimple) has been improved by removing the debounce option. | ||
The render performance of the lazy loading option in tables (OcTable, OcTableSimple) has been improved by removing the debounce option and by moving the lazy loading visualization from the OcTd to the OcTr component. For lazy loading, the colspan property has to be provided now. | ||
|
||
https://github.com/owncloud/owncloud-design-system/pull/2260 | ||
https://github.com/owncloud/owncloud-design-system/pull/2266 | ||
https://github.com/owncloud/web/issues/7038 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,99 @@ | ||
<template> | ||
<tr tabindex="-1"> | ||
<slot /> | ||
<tr ref="observerTarget" tabindex="-1"> | ||
<oc-td v-if="isHidden" :colspan="lazyColspan"> | ||
<span class="shimmer" /> | ||
</oc-td> | ||
<slot v-else /> | ||
</tr> | ||
</template> | ||
<script> | ||
import { customRef, computed, ref, unref } from "@vue/composition-api" | ||
import { useIsVisible } from "../../../composables" | ||
import OcTd from "../_OcTableCellData/_OcTableCellData.vue" | ||
export default { | ||
name: "OcTr", | ||
status: "ready", | ||
release: "1.0.0", | ||
components: { OcTd }, | ||
props: { | ||
lazy: { | ||
type: Object, | ||
required: false, | ||
default: null, | ||
}, | ||
}, | ||
setup(props) { | ||
const observerTarget = customRef((track, trigger) => { | ||
let $el | ||
return { | ||
get() { | ||
track() | ||
return $el | ||
}, | ||
set(value) { | ||
$el = value | ||
trigger() | ||
}, | ||
} | ||
}) | ||
const lazyColspan = ref(null) | ||
if (props.lazy) { | ||
lazyColspan.value = props.lazy.colspan | ||
} | ||
const { isVisible } = props.lazy | ||
? useIsVisible({ | ||
...props.lazy, | ||
target: observerTarget, | ||
}) | ||
: { isVisible: ref(true) } | ||
const isHidden = computed(() => !unref(isVisible)) | ||
return { | ||
observerTarget, | ||
isHidden, | ||
lazyColspan, | ||
} | ||
}, | ||
} | ||
</script> | ||
<style lang="scss"> | ||
.shimmer { | ||
background-color: var(--oc-color-input-text-muted); | ||
bottom: 12px; | ||
display: inline-block; | ||
left: var(--oc-space-small); | ||
opacity: 0.2; | ||
overflow: hidden; | ||
position: absolute; | ||
right: var(--oc-space-small); | ||
top: 12px; | ||
&::after { | ||
animation: shimmer 2s infinite; | ||
background-image: linear-gradient( | ||
90deg, | ||
rgba(#fff, 0) 0, | ||
rgba(#fff, 0.2) 20%, | ||
rgba(#fff, 0.5) 60%, | ||
rgba(#fff, 0) | ||
); | ||
bottom: 0; | ||
content: ""; | ||
left: 0; | ||
position: absolute; | ||
right: 0; | ||
top: 0; | ||
transform: translateX(-100%); | ||
} | ||
@keyframes shimmer { | ||
100% { | ||
transform: translateX(100%); | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters