mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Always close drawer on navigation
This commit is contained in:
parent
e7850ca184
commit
ed61f60970
File diff suppressed because one or more lines are too long
1
material/assets/javascripts/bundle.6b6cf576.min.js.map
Normal file
1
material/assets/javascripts/bundle.6b6cf576.min.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"assets/javascripts/bundle.js": "assets/javascripts/bundle.d8c6976f.min.js",
|
"assets/javascripts/bundle.js": "assets/javascripts/bundle.6b6cf576.min.js",
|
||||||
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.d8c6976f.min.js.map",
|
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.6b6cf576.min.js.map",
|
||||||
"assets/javascripts/vendor.js": "assets/javascripts/vendor.e32ed4d0.min.js",
|
"assets/javascripts/vendor.js": "assets/javascripts/vendor.e32ed4d0.min.js",
|
||||||
"assets/javascripts/vendor.js.map": "assets/javascripts/vendor.e32ed4d0.min.js.map",
|
"assets/javascripts/vendor.js.map": "assets/javascripts/vendor.e32ed4d0.min.js.map",
|
||||||
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.b9424174.min.js",
|
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.b9424174.min.js",
|
||||||
|
@ -217,7 +217,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/vendor.e32ed4d0.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/vendor.e32ed4d0.min.js' | url }}"></script>
|
||||||
<script src="{{ 'assets/javascripts/bundle.d8c6976f.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.6b6cf576.min.js' | url }}"></script>
|
||||||
{% for path in config["extra_javascript"] %}
|
{% for path in config["extra_javascript"] %}
|
||||||
<script src="{{ path | url }}"></script>
|
<script src="{{ path | url }}"></script>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -51,7 +51,7 @@ theme:
|
|||||||
# Default values, taken from mkdocs_theme.yml
|
# Default values, taken from mkdocs_theme.yml
|
||||||
language: en
|
language: en
|
||||||
features:
|
features:
|
||||||
- navigation.instant
|
# - navigation.instant
|
||||||
- navigation.sections
|
- navigation.sections
|
||||||
- navigation.tabs
|
- navigation.tabs
|
||||||
palette:
|
palette:
|
||||||
|
@ -36,6 +36,7 @@ import {
|
|||||||
getElement,
|
getElement,
|
||||||
getElementOrThrow,
|
getElementOrThrow,
|
||||||
getElements,
|
getElements,
|
||||||
|
setToggle,
|
||||||
watchDocument,
|
watchDocument,
|
||||||
watchKeyboard,
|
watchKeyboard,
|
||||||
watchLocation,
|
watchLocation,
|
||||||
@ -94,6 +95,10 @@ setupClipboardJS({ alert$ })
|
|||||||
if (feature("navigation.instant"))
|
if (feature("navigation.instant"))
|
||||||
setupInstantLoading({ document$, location$, viewport$ })
|
setupInstantLoading({ document$, location$, viewport$ })
|
||||||
|
|
||||||
|
/* Always close drawer on navigation */
|
||||||
|
merge(location$, target$)
|
||||||
|
.subscribe(() => setToggle("drawer", false))
|
||||||
|
|
||||||
/* Set up global keyboard handlers */
|
/* Set up global keyboard handlers */
|
||||||
keyboard$
|
keyboard$
|
||||||
.pipe(
|
.pipe(
|
||||||
|
@ -21,7 +21,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Observable, fromEvent, of } from "rxjs"
|
import { Observable, fromEvent, of } from "rxjs"
|
||||||
import { mapTo, mergeMap, switchMap, tap } from "rxjs/operators"
|
import {
|
||||||
|
filter,
|
||||||
|
mapTo,
|
||||||
|
mergeMap,
|
||||||
|
switchMap,
|
||||||
|
tap
|
||||||
|
} from "rxjs/operators"
|
||||||
|
|
||||||
import { getElements } from "~/browser"
|
import { getElements } from "~/browser"
|
||||||
|
|
||||||
@ -67,28 +73,27 @@ function isAppleDevice(): boolean {
|
|||||||
export function patchScrollfix(
|
export function patchScrollfix(
|
||||||
{ document$ }: PatchOptions
|
{ document$ }: PatchOptions
|
||||||
): void {
|
): void {
|
||||||
if (isAppleDevice()) {
|
document$
|
||||||
document$
|
.pipe(
|
||||||
.pipe(
|
switchMap(() => of(...getElements("[data-md-scrollfix]"))),
|
||||||
switchMap(() => of(...getElements("[data-md-scrollfix]"))),
|
tap(el => el.removeAttribute("data-md-scrollfix")),
|
||||||
tap(el => el.removeAttribute("data-md-scrollfix")),
|
filter(isAppleDevice),
|
||||||
mergeMap(el => fromEvent(el, "touchstart")
|
mergeMap(el => fromEvent(el, "touchstart")
|
||||||
.pipe(
|
.pipe(
|
||||||
mapTo(el)
|
mapTo(el)
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.subscribe(el => {
|
)
|
||||||
const top = el.scrollTop
|
.subscribe(el => {
|
||||||
|
const top = el.scrollTop
|
||||||
|
|
||||||
/* We're at the top of the container */
|
/* We're at the top of the container */
|
||||||
if (top === 0) {
|
if (top === 0) {
|
||||||
el.scrollTop = 1
|
el.scrollTop = 1
|
||||||
|
|
||||||
/* We're at the bottom of the container */
|
/* We're at the bottom of the container */
|
||||||
} else if (top + el.offsetHeight === el.scrollHeight) {
|
} else if (top + el.offsetHeight === el.scrollHeight) {
|
||||||
el.scrollTop = top - 1
|
el.scrollTop = top - 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user