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

@@ -36,6 +36,7 @@ import {
import {
ElementOffset,
getElement,
watchElementContentOffset,
watchElementFocus,
watchElementOffset
@@ -122,7 +123,7 @@ export function mountAnnotation(
})
/* Blur open annotation on click (= close) */
const index = el.lastElementChild!
const index = getElement(":scope > :last-child")
const blur$ = fromEvent(index, "mousedown", { once: true })
push$
.pipe(

View File

@@ -120,36 +120,36 @@ export function mountAnnotationList(
/* Create and return component */
return defer(() => {
const push$ = new Subject<Annotation>()
const done$ = new Subject<void>()
/* Handle print mode - see https://bit.ly/3rgPdpt */
print$
.pipe(
startWith(false),
takeUntil(push$.pipe(takeLast(1)))
takeUntil(done$.pipe(takeLast(1)))
)
.subscribe(active => {
el.hidden = !active
/* Move annotation contents back into list */
for (const [id, annotation] of annotations) {
const tooltip = getElement(".md-typeset", annotation)
const inner = getElement(".md-typeset", annotation)
const child = getElement(`li:nth-child(${id})`, el)
if (!active)
swap(child, tooltip)
swap(child, inner)
else
swap(tooltip, child)
swap(inner, child)
}
})
/* Create and return component */
return merge(
...[...annotations].map(([, annotation]) => (
return merge(...[...annotations]
.map(([, annotation]) => (
mountAnnotation(annotation, container)
))
)
.pipe(
finalize(() => push$.complete()),
finalize(() => done$.complete()),
share()
)
})