Fixed observable completion semantics

This commit is contained in:
squidfunk
2021-11-28 14:54:14 +01:00
parent abe475e151
commit c30c3d196e
55 changed files with 493 additions and 1347 deletions

View File

@@ -52,8 +52,7 @@ import {
request,
requestXML,
setLocation,
setLocationHash,
setViewportOffset
setLocationHash
} from "~/browser"
import { getComponentElement } from "~/components"
import { h } from "~/utilities"
@@ -329,11 +328,11 @@ export function setupInstantLoading(
.pipe(
sample(document$),
)
.subscribe(({ url, offset }) => {
.subscribe(({ url, offset = { y: 0 } }) => {
if (url.hash && !offset) {
setLocationHash(url.hash)
} else {
setViewportOffset(offset || { y: 0 })
window.scrollTo(0, offset.y)
}
})
@@ -355,7 +354,7 @@ export function setupInstantLoading(
filter(([a, b]) => a.url.pathname === b.url.pathname),
map(([, state]) => state)
)
.subscribe(({ offset }) => {
setViewportOffset(offset || { y: 0 })
.subscribe(({ offset = { y: 0 } }) => {
window.scrollTo(0, offset.y)
})
}