mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed instant loading indicator in Chrome when serving gzipped (#6322)
* bypass chrome event.total 0 when content gzipped by getting total off of Content-Length header * styling; NaN should be replaced with 0 as well, so no nullish coalescing won't work
This commit is contained in:
parent
86c76c4461
commit
436ed8b8c2
@ -85,7 +85,12 @@ export function request(
|
||||
// Handle download progress
|
||||
if (typeof options?.progress$ !== "undefined") {
|
||||
req.addEventListener("progress", event => {
|
||||
options.progress$!.next((event.loaded / event.total) * 100)
|
||||
if (event.lengthComputable) {
|
||||
options.progress$!.next((event.loaded / event.total) * 100)
|
||||
} else { // https://bugs.chromium.org/p/chromium/issues/detail?id=463622
|
||||
const totalFromHeader = Number(req.getResponseHeader("Content-Length")) || 0
|
||||
options.progress$!.next((event.loaded / totalFromHeader) * 100)
|
||||
}
|
||||
})
|
||||
|
||||
// Immediately set progress to 5% to indicate that we're loading
|
||||
|
Loading…
Reference in New Issue
Block a user