mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-08-02 10:48:49 -04:00
Reverted addEventListener for media query (hello iOS Safari, I'm looking at you)
This commit is contained in:
@@ -20,8 +20,8 @@
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { Observable, fromEvent } from "rxjs"
|
||||
import { map, shareReplay, startWith } from "rxjs/operators"
|
||||
import { Observable } from "rxjs"
|
||||
import { shareReplay, startWith } from "rxjs/operators"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Functions
|
||||
@@ -36,9 +36,10 @@ import { map, shareReplay, startWith } from "rxjs/operators"
|
||||
*/
|
||||
export function watchMedia(query: string): Observable<boolean> {
|
||||
const media = matchMedia(query)
|
||||
return fromEvent<MediaQueryListEvent>(media, "change")
|
||||
return new Observable<boolean>(subscriber => {
|
||||
media.addListener(ev => subscriber.next(ev.matches))
|
||||
})
|
||||
.pipe(
|
||||
map(ev => ev.matches),
|
||||
startWith(media.matches),
|
||||
shareReplay({ bufferSize: 1, refCount: true })
|
||||
)
|
||||
|
||||
@@ -83,7 +83,7 @@ export function patchScrollfix(
|
||||
iif(isAppleDevice, els$, NEVER)
|
||||
.pipe(
|
||||
switchMap(els => merge(...els.map(el => (
|
||||
fromEvent(el, "touchstart", { passive: true })
|
||||
fromEvent(el, "touchstart")
|
||||
.pipe(
|
||||
mapTo(el)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user