mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed sidebar not focusing active item when navigation is huge
This commit is contained in:
parent
54b98b23e5
commit
26c08f1f38
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
material/assets/stylesheets/extra.e916454c.min.css
vendored
Normal file
1
material/assets/stylesheets/extra.e916454c.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
material/assets/stylesheets/extra.e916454c.min.css.map
Normal file
1
material/assets/stylesheets/extra.e916454c.min.css.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
File diff suppressed because one or more lines are too long
@ -234,13 +234,13 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/bundle.c45ce4b3.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.6d7e1051.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 %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% if page.meta and page.meta.ᴴₒᴴₒᴴₒ %}
|
{% if page.meta and page.meta.ᴴₒᴴₒᴴₒ %}
|
||||||
<link rel="stylesheet" href="{{ 'assets/stylesheets/extra.ef53c8a4.min.css' | url }}">
|
<link rel="stylesheet" href="{{ 'assets/stylesheets/extra.e916454c.min.css' | url }}">
|
||||||
<script src="{{ 'assets/javascripts/extra/bundle.cfb3feee.min.js' | url }}" defer></script>
|
<script src="{{ 'assets/javascripts/extra/bundle.cfb3feee.min.js' | url }}" defer></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</body>
|
</body>
|
||||||
|
@ -29,9 +29,8 @@ import {
|
|||||||
defer,
|
defer,
|
||||||
distinctUntilChanged,
|
distinctUntilChanged,
|
||||||
finalize,
|
finalize,
|
||||||
|
first,
|
||||||
map,
|
map,
|
||||||
observeOn,
|
|
||||||
take,
|
|
||||||
tap,
|
tap,
|
||||||
withLatestFrom
|
withLatestFrom
|
||||||
} from "rxjs"
|
} from "rxjs"
|
||||||
@ -154,44 +153,42 @@ export function mountSidebar(
|
|||||||
const { y } = getElementOffset(inner)
|
const { y } = getElementOffset(inner)
|
||||||
return defer(() => {
|
return defer(() => {
|
||||||
const push$ = new Subject<Sidebar>()
|
const push$ = new Subject<Sidebar>()
|
||||||
push$
|
const next$ = push$
|
||||||
.pipe(
|
.pipe(
|
||||||
auditTime(0, animationFrameScheduler),
|
auditTime(0, animationFrameScheduler)
|
||||||
withLatestFrom(header$)
|
|
||||||
)
|
)
|
||||||
.subscribe({
|
|
||||||
|
|
||||||
/* Handle emission */
|
/* Update sidebar height and offset */
|
||||||
next([{ height }, { height: offset }]) {
|
next$.pipe(withLatestFrom(header$))
|
||||||
inner.style.height = `${height - 2 * y}px`
|
.subscribe({
|
||||||
el.style.top = `${offset}px`
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Handle complete */
|
/* Handle emission */
|
||||||
complete() {
|
next([{ height }, { height: offset }]) {
|
||||||
inner.style.height = ""
|
inner.style.height = `${height - 2 * y}px`
|
||||||
el.style.top = ""
|
el.style.top = `${offset}px`
|
||||||
}
|
},
|
||||||
})
|
|
||||||
|
/* Handle complete */
|
||||||
|
complete() {
|
||||||
|
inner.style.height = ""
|
||||||
|
el.style.top = ""
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/* Bring active item into view on initial load */
|
/* Bring active item into view on initial load */
|
||||||
push$
|
next$.pipe(first())
|
||||||
.pipe(
|
.subscribe(() => {
|
||||||
observeOn(animationFrameScheduler),
|
for (const item of getElements(".md-nav__link--active[href]", el)) {
|
||||||
take(1)
|
const container = getElementContainer(item)
|
||||||
)
|
if (typeof container !== "undefined") {
|
||||||
.subscribe(() => {
|
const offset = item.offsetTop - container.offsetTop
|
||||||
for (const item of getElements(".md-nav__link--active[href]", el)) {
|
const { height } = getElementSize(container)
|
||||||
const container = getElementContainer(item)
|
container.scrollTo({
|
||||||
if (typeof container !== "undefined") {
|
top: offset - height / 2
|
||||||
const offset = item.offsetTop - container.offsetTop
|
})
|
||||||
const { height } = getElementSize(container)
|
|
||||||
container.scrollTo({
|
|
||||||
top: offset - height / 2
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/* Create and return component */
|
/* Create and return component */
|
||||||
return watchSidebar(el, options)
|
return watchSidebar(el, options)
|
||||||
|
Loading…
Reference in New Issue
Block a user