mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed scrollfix being applied more than once for search
This commit is contained in:
parent
a1393fdbc3
commit
a17c30c3ac
@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Observable, fromEvent, merge } from "rxjs"
|
import { Observable, fromEvent, merge } from "rxjs"
|
||||||
import { map, mapTo, switchMap } from "rxjs/operators"
|
import { map, mapTo, shareReplay, switchMap } from "rxjs/operators"
|
||||||
|
|
||||||
import { getElements } from "observables"
|
import { getElements } from "observables"
|
||||||
|
|
||||||
@ -54,9 +54,21 @@ interface MountOptions {
|
|||||||
export function patchScrollfix(
|
export function patchScrollfix(
|
||||||
{ document$ }: MountOptions
|
{ document$ }: MountOptions
|
||||||
): void {
|
): void {
|
||||||
document$
|
const els$ = document$
|
||||||
.pipe(
|
.pipe(
|
||||||
map(() => getElements("[data-md-scrollfix]")),
|
map(() => getElements("[data-md-scrollfix]")),
|
||||||
|
shareReplay(1)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* Remove marker attribute, so we'll only add the fix once */
|
||||||
|
els$.subscribe(els => {
|
||||||
|
for (const el of els)
|
||||||
|
el.removeAttribute("data-md-scrollfix")
|
||||||
|
})
|
||||||
|
|
||||||
|
/* Patch overflow scrolling on touch start */
|
||||||
|
els$
|
||||||
|
.pipe(
|
||||||
switchMap(els => merge(...els.map(el => (
|
switchMap(els => merge(...els.map(el => (
|
||||||
fromEvent(el, "touchstart")
|
fromEvent(el, "touchstart")
|
||||||
.pipe(
|
.pipe(
|
||||||
|
Loading…
Reference in New Issue
Block a user