mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Added protoypiical implementation of header title swap
This commit is contained in:
parent
b26edc05a4
commit
b883f212a7
@ -39,10 +39,12 @@ import {
|
|||||||
switchMap,
|
switchMap,
|
||||||
tap,
|
tap,
|
||||||
skip,
|
skip,
|
||||||
|
filter,
|
||||||
take,
|
take,
|
||||||
bufferCount,
|
bufferCount,
|
||||||
startWith,
|
startWith,
|
||||||
pluck
|
pluck,
|
||||||
|
withLatestFrom
|
||||||
} from "rxjs/operators"
|
} from "rxjs/operators"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -56,7 +58,9 @@ import {
|
|||||||
watchKeyboard,
|
watchKeyboard,
|
||||||
watchToggleMap,
|
watchToggleMap,
|
||||||
useToggle,
|
useToggle,
|
||||||
setViewportOffset
|
setViewportOffset,
|
||||||
|
watchViewportFrom,
|
||||||
|
getElementOrThrow
|
||||||
} from "./observables"
|
} from "./observables"
|
||||||
import { setupSearchWorker } from "./workers"
|
import { setupSearchWorker } from "./workers"
|
||||||
import { renderSource } from "templates"
|
import { renderSource } from "templates"
|
||||||
@ -229,9 +233,26 @@ export function initialize(config: unknown) {
|
|||||||
|
|
||||||
const hero$ = useComponent("hero")
|
const hero$ = useComponent("hero")
|
||||||
.pipe(
|
.pipe(
|
||||||
mountHero({ header$, viewport$, screen$ })
|
mountHero({ header$, viewport$ })
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/* Create header title toggle */
|
||||||
|
useComponent("main")
|
||||||
|
.pipe(
|
||||||
|
map(el => getElementOrThrow("h1", el)), // catch error? just ignore?
|
||||||
|
switchMap(el => {
|
||||||
|
return watchViewportFrom(el, { header$, viewport$ })
|
||||||
|
.pipe(
|
||||||
|
map(({ offset: { y } }) => y >= el.offsetHeight),
|
||||||
|
withLatestFrom(useComponent("header-title")),
|
||||||
|
tap(([active, title]) => {
|
||||||
|
title.dataset.mdState = active ? "active" : ""
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe(console.log)
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
// TODO: general keyboard handler...
|
// TODO: general keyboard handler...
|
||||||
|
Loading…
Reference in New Issue
Block a user