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