diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-22 16:41:02 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-22 16:41:02 +0100 |
commit | a9ca764e7e23c0c14949c308a9ce54d4fdb9a361 (patch) | |
tree | a40adf5c1c73a547e64095ad9f479fb65f791283 /client/src/app/shared/misc | |
parent | 1f30a1853e38c20a45722dbd6d38aaaec63839e8 (diff) | |
download | PeerTube-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.ts | 20 |
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 | ||
62 | function isInSmallView () { | ||
63 | return window.innerWidth < 600 | ||
64 | } | ||
65 | |||
66 | function isInMobileView () { | ||
67 | return window.innerWidth < 500 | ||
68 | } | ||
69 | |||
70 | // Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34 | 62 | // Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34 |
71 | function objectToFormData (obj: any, form?: FormData, namespace?: string) { | 63 | function 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 | ||
90 | let windowInnerWidth = window.innerWidth | ||
91 | setInterval(() => windowInnerWidth = window.innerWidth, 500) | ||
92 | |||
93 | function isInSmallView () { | ||
94 | return windowInnerWidth < 600 | ||
95 | } | ||
96 | |||
97 | function isInMobileView () { | ||
98 | return windowInnerWidth < 500 | ||
99 | } | ||
100 | |||
97 | export { | 101 | export { |
98 | viewportHeight, | 102 | viewportHeight, |
99 | getParameterByName, | 103 | getParameterByName, |