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.
add vue-composition-api add feature to render table cells lazy
- Loading branch information
Showing
13 changed files
with
320 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Change: Remove implicit ODS registration | ||
|
||
Remove implicit registration of ODS, from now on applications using ODS must register it explicit via `Vue.use`. | ||
|
||
https://github.com/owncloud/owncloud-design-system/pull/1848 |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Enhancement: make Vue-Composition-API available | ||
|
||
To support upcoming Vue composition-api we`ve added the compatibility layer from the creators. | ||
From now on all features described here `https://github.com/vuejs/composition-api` can be used. | ||
|
||
https://github.com/owncloud/owncloud-design-system/pull/1848 |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Enhancement: Add option to render table cells lazy | ||
|
||
In cases where the table (`OcTable only`) has multiple child rows with many cells, it can be a bottleneck to rendered all of them immediately. | ||
With this in mind we've added the lazy option to the table fields object where the consuming app can decide how lazy rendering should behave. | ||
|
||
By default lazy cell rendering is disabled, to enable it add a lazy object to the field. | ||
|
||
following options are available: | ||
* `delay: 250` - when the cell visibility on screen is below given ms value rendering gets skipped. | ||
* `mode: show` - cell gets rendered and stays painted, no de-rendering happens. | ||
* `mode: showHide` - cell gets rendered when it enters the screen and de-rendered when its off. | ||
* `rootMargin: 100px` - given value will be added to the outer area of the element which then increases the visibility detection radius | ||
|
||
https://github.com/owncloud/owncloud-design-system/pull/1848 |
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./useIsVisible" |
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { onBeforeUnmount, ref, watch } from "@vue/composition-api" | ||
|
||
/** | ||
* once ODS has lodash this debounce implementation can be replaced with the one from lodash. | ||
* @param delay | ||
* @param callback | ||
* @returns {(function(...[*]=): void)|*} | ||
*/ | ||
const debounce = (delay = 0, callback) => { | ||
let id = null | ||
return (...args) => { | ||
window.clearTimeout(id) | ||
id = window.setTimeout(() => { | ||
callback.apply(null, args) | ||
}, delay) | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param {Ref<Element>} target - ref with element to be observed | ||
* @param {('show'|'showHide')} mode - showHide shows and hides the element on screen enter or leave, show only detects entering the screen and the keeps it rendered | ||
* @param {string} rootMargin - margin that will be added around the element to detect visibility | ||
* @param {number} delay - defines the debounce delay of the visibility detection | ||
* @returns {{isVisible: Ref<boolean>}} | ||
*/ | ||
export const useIsVisible = ({ target, mode = "show", rootMargin = "100px", delay = 0 }) => { | ||
const isSupported = window && "IntersectionObserver" in window | ||
if (!isSupported) { | ||
return { | ||
isVisible: ref(true), | ||
} | ||
} | ||
|
||
const isVisible = ref(false) | ||
const observer = new IntersectionObserver( | ||
debounce(delay, ([{ isIntersecting }]) => { | ||
isVisible.value = isIntersecting | ||
/** | ||
* if given mode is `showHide` we need to keep the observation alive. | ||
*/ | ||
if (mode === "showHide") { | ||
return | ||
} | ||
/** | ||
* if the mode is `show` which is the default, the implementation needs to unsubscribe the target from the observer | ||
*/ | ||
if (!isVisible.value) { | ||
return | ||
} | ||
|
||
observer.unobserve(target.value) | ||
}), | ||
{ | ||
rootMargin, | ||
} | ||
) | ||
|
||
watch(target, () => { | ||
observer.observe(target.value) | ||
}) | ||
|
||
onBeforeUnmount(() => observer.disconnect()) | ||
|
||
return { | ||
isVisible, | ||
} | ||
} |
Oops, something went wrong.