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 | |
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')
-rw-r--r-- | client/src/app/helpers/utils/dom.ts (renamed from client/src/app/helpers/utils/ui.ts) | 26 | ||||
-rw-r--r-- | client/src/app/helpers/utils/index.ts | 2 |
2 files changed, 19 insertions, 9 deletions
diff --git a/client/src/app/helpers/utils/ui.ts b/client/src/app/helpers/utils/dom.ts index ac8298926..f65e4d726 100644 --- a/client/src/app/helpers/utils/ui.ts +++ b/client/src/app/helpers/utils/dom.ts | |||
@@ -6,14 +6,24 @@ function scrollToTop (behavior: 'auto' | 'smooth' = 'auto') { | |||
6 | }) | 6 | }) |
7 | } | 7 | } |
8 | 8 | ||
9 | function isInViewport (el: HTMLElement) { | 9 | function isInViewport (el: HTMLElement, container: HTMLElement = document.documentElement) { |
10 | const bounding = el.getBoundingClientRect() | 10 | const boundingEl = el.getBoundingClientRect() |
11 | return ( | 11 | const boundingContainer = container.getBoundingClientRect() |
12 | bounding.top >= 0 && | 12 | |
13 | bounding.left >= 0 && | 13 | const relativePos = { |
14 | bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) && | 14 | top: 0, |
15 | bounding.right <= (window.innerWidth || document.documentElement.clientWidth) | 15 | left: 0, |
16 | ) | 16 | bottom: 0, |
17 | right: 0 | ||
18 | } | ||
19 | |||
20 | relativePos.top = boundingEl.top - boundingContainer.top | ||
21 | relativePos.left = boundingEl.left - boundingContainer.left | ||
22 | |||
23 | return relativePos.top >= 0 && | ||
24 | relativePos.left >= 0 && | ||
25 | boundingEl.bottom <= boundingContainer.bottom && | ||
26 | boundingEl.right <= boundingContainer.right | ||
17 | } | 27 | } |
18 | 28 | ||
19 | function isXPercentInViewport (el: HTMLElement, percentVisible: number) { | 29 | function isXPercentInViewport (el: HTMLElement, percentVisible: number) { |
diff --git a/client/src/app/helpers/utils/index.ts b/client/src/app/helpers/utils/index.ts index dc09c92ab..f821985c9 100644 --- a/client/src/app/helpers/utils/index.ts +++ b/client/src/app/helpers/utils/index.ts | |||
@@ -2,6 +2,6 @@ export * from './channel' | |||
2 | export * from './date' | 2 | export * from './date' |
3 | export * from './html' | 3 | export * from './html' |
4 | export * from './object' | 4 | export * from './object' |
5 | export * from './ui' | 5 | export * from './dom' |
6 | export * from './upload' | 6 | export * from './upload' |
7 | export * from './url' | 7 | export * from './url' |