aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/misc
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-22 16:41:02 +0100
committerChocobozzz <me@florianbigard.com>2018-02-22 16:41:02 +0100
commita9ca764e7e23c0c14949c308a9ce54d4fdb9a361 (patch)
treea40adf5c1c73a547e64095ad9f479fb65f791283 /client/src/app/shared/misc
parent1f30a1853e38c20a45722dbd6d38aaaec63839e8 (diff)
downloadPeerTube-a9ca764e7e23c0c14949c308a9ce54d4fdb9a361.tar.gz
PeerTube-a9ca764e7e23c0c14949c308a9ce54d4fdb9a361.tar.zst
PeerTube-a9ca764e7e23c0c14949c308a9ce54d4fdb9a361.zip
Throttle infinite scroller
Diffstat (limited to 'client/src/app/shared/misc')
-rw-r--r--client/src/app/shared/misc/utils.ts20
1 files changed, 12 insertions, 8 deletions
diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts
index 64bc69b0d..d520b1a7b 100644
--- a/client/src/app/shared/misc/utils.ts
+++ b/client/src/app/shared/misc/utils.ts
@@ -59,14 +59,6 @@ function immutableAssign <A, B> (target: A, source: B) {
59 return Object.assign({}, target, source) 59 return Object.assign({}, target, source)
60} 60}
61 61
62function isInSmallView () {
63 return window.innerWidth < 600
64}
65
66function isInMobileView () {
67 return window.innerWidth < 500
68}
69
70// Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34 62// Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34
71function objectToFormData (obj: any, form?: FormData, namespace?: string) { 63function objectToFormData (obj: any, form?: FormData, namespace?: string) {
72 let fd = form || new FormData() 64 let fd = form || new FormData()
@@ -94,6 +86,18 @@ function lineFeedToHtml (obj: object, keyToNormalize: string) {
94 }) 86 })
95} 87}
96 88
89// Try to cache a little bit window.innerWidth
90let windowInnerWidth = window.innerWidth
91setInterval(() => windowInnerWidth = window.innerWidth, 500)
92
93function isInSmallView () {
94 return windowInnerWidth < 600
95}
96
97function isInMobileView () {
98 return windowInnerWidth < 500
99}
100
97export { 101export {
98 viewportHeight, 102 viewportHeight,
99 getParameterByName, 103 getParameterByName,