diff options
author | Chocobozzz <me@florianbigard.com> | 2022-03-01 11:11:12 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-03-01 13:37:40 +0100 |
commit | 19e7a90045345b531a489289dc8d4e032fa15d6c (patch) | |
tree | 45778fcedfa107062c553c170806946a1735d07a /client/src/app/helpers/utils/ui.ts | |
parent | 7bde625050cb661f51db20992f9f3912a582fcee (diff) | |
download | PeerTube-19e7a90045345b531a489289dc8d4e032fa15d6c.tar.gz PeerTube-19e7a90045345b531a489289dc8d4e032fa15d6c.tar.zst PeerTube-19e7a90045345b531a489289dc8d4e032fa15d6c.zip |
Fix playlist element scrolling
Diffstat (limited to 'client/src/app/helpers/utils/ui.ts')
-rw-r--r-- | client/src/app/helpers/utils/ui.ts | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/client/src/app/helpers/utils/ui.ts b/client/src/app/helpers/utils/ui.ts deleted file mode 100644 index ac8298926..000000000 --- a/client/src/app/helpers/utils/ui.ts +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | function scrollToTop (behavior: 'auto' | 'smooth' = 'auto') { | ||
2 | window.scrollTo({ | ||
3 | left: 0, | ||
4 | top: 0, | ||
5 | behavior | ||
6 | }) | ||
7 | } | ||
8 | |||
9 | function isInViewport (el: HTMLElement) { | ||
10 | const bounding = el.getBoundingClientRect() | ||
11 | return ( | ||
12 | bounding.top >= 0 && | ||
13 | bounding.left >= 0 && | ||
14 | bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) && | ||
15 | bounding.right <= (window.innerWidth || document.documentElement.clientWidth) | ||
16 | ) | ||
17 | } | ||
18 | |||
19 | function isXPercentInViewport (el: HTMLElement, percentVisible: number) { | ||
20 | const rect = el.getBoundingClientRect() | ||
21 | const windowHeight = (window.innerHeight || document.documentElement.clientHeight) | ||
22 | |||
23 | return !( | ||
24 | Math.floor(100 - (((rect.top >= 0 ? 0 : rect.top) / +-(rect.height / 1)) * 100)) < percentVisible || | ||
25 | Math.floor(100 - ((rect.bottom - windowHeight) / rect.height) * 100) < percentVisible | ||
26 | ) | ||
27 | } | ||
28 | |||
29 | export { | ||
30 | scrollToTop, | ||
31 | isInViewport, | ||
32 | isXPercentInViewport | ||
33 | } | ||