aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/misc
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2019-12-20 17:49:57 +0100
committerRigel Kent <sendmemail@rigelk.eu>2019-12-20 17:49:57 +0100
commit223b24e618146f85b20b5bf365bc18d14a5964cd (patch)
tree236fde34d190fa5d0d9a44c6760c0161594dd872 /client/src/app/shared/misc
parent1dc240a9488c66ad38205d08fcfdb32d35efceaa (diff)
downloadPeerTube-223b24e618146f85b20b5bf365bc18d14a5964cd.tar.gz
PeerTube-223b24e618146f85b20b5bf365bc18d14a5964cd.tar.zst
PeerTube-223b24e618146f85b20b5bf365bc18d14a5964cd.zip
Fix upnext, refactor avatar menu, add to playlist overflow
Diffstat (limited to 'client/src/app/shared/misc')
-rw-r--r--client/src/app/shared/misc/utils.ts24
1 files changed, 23 insertions, 1 deletions
diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts
index f26240d21..b1d1fc0b5 100644
--- a/client/src/app/shared/misc/utils.ts
+++ b/client/src/app/shared/misc/utils.ts
@@ -169,6 +169,26 @@ function importModule (path: string) {
169 }) 169 })
170} 170}
171 171
172function isInViewport (el: HTMLElement) {
173 const bounding = el.getBoundingClientRect()
174 return (
175 bounding.top >= 0 &&
176 bounding.left >= 0 &&
177 bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
178 bounding.right <= (window.innerWidth || document.documentElement.clientWidth)
179 )
180}
181
182function isXPercentInViewport (el: HTMLElement, percentVisible: number) {
183 const rect = el.getBoundingClientRect()
184 const windowHeight = (window.innerHeight || document.documentElement.clientHeight)
185
186 return !(
187 Math.floor(100 - (((rect.top >= 0 ? 0 : rect.top) / +-(rect.height / 1)) * 100)) < percentVisible ||
188 Math.floor(100 - ((rect.bottom - windowHeight) / rect.height) * 100) < percentVisible
189 )
190}
191
172export { 192export {
173 sortBy, 193 sortBy,
174 durationToString, 194 durationToString,
@@ -183,5 +203,7 @@ export {
183 objectLineFeedToHtml, 203 objectLineFeedToHtml,
184 removeElementFromArray, 204 removeElementFromArray,
185 importModule, 205 importModule,
186 scrollToTop 206 scrollToTop,
207 isInViewport,
208 isXPercentInViewport
187} 209}