mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2025-02-17 18:49:21 +01:00
Fixed incorrectly computed header height when using instant loading
This commit is contained in:
parent
d926bb4c27
commit
cc0f7a914a
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -214,7 +214,7 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/bundle.52fb055a.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.6e54b5cd.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 %}
|
||||||
|
@ -58,7 +58,6 @@ import { Main } from "../../main"
|
|||||||
*/
|
*/
|
||||||
export interface Header {
|
export interface Header {
|
||||||
height: number /* Header visible height */
|
height: number /* Header visible height */
|
||||||
sticky: boolean /* Header stickyness */
|
|
||||||
hidden: boolean /* Header is hidden */
|
hidden: boolean /* Header is hidden */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,22 +142,16 @@ function isHidden({ viewport$ }: WatchOptions): Observable<boolean> {
|
|||||||
export function watchHeader(
|
export function watchHeader(
|
||||||
el: HTMLElement, options: WatchOptions
|
el: HTMLElement, options: WatchOptions
|
||||||
): Observable<Header> {
|
): Observable<Header> {
|
||||||
return defer(() => {
|
return defer(() => combineLatest([
|
||||||
const styles = getComputedStyle(el)
|
watchElementSize(el),
|
||||||
return of(
|
isHidden(options)
|
||||||
styles.position === "sticky" ||
|
]))
|
||||||
styles.position === "-webkit-sticky"
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.pipe(
|
.pipe(
|
||||||
combineLatestWith(watchElementSize(el), isHidden(options)),
|
map(([{ height }, hidden]) => ({
|
||||||
map(([sticky, { height }, hidden]) => ({
|
height,
|
||||||
height: sticky ? height : 0,
|
|
||||||
sticky,
|
|
||||||
hidden
|
hidden
|
||||||
})),
|
})),
|
||||||
distinctUntilChanged((a, b) => (
|
distinctUntilChanged((a, b) => (
|
||||||
a.sticky === b.sticky &&
|
|
||||||
a.height === b.height &&
|
a.height === b.height &&
|
||||||
a.hidden === b.hidden
|
a.hidden === b.hidden
|
||||||
)),
|
)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user