mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-24 07:30:12 +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>
|
||||
{% endblock %}
|
||||
{% 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"] %}
|
||||
<script src="{{ path | url }}"></script>
|
||||
{% endfor %}
|
||||
|
@ -58,7 +58,6 @@ import { Main } from "../../main"
|
||||
*/
|
||||
export interface Header {
|
||||
height: number /* Header visible height */
|
||||
sticky: boolean /* Header stickyness */
|
||||
hidden: boolean /* Header is hidden */
|
||||
}
|
||||
|
||||
@ -143,22 +142,16 @@ function isHidden({ viewport$ }: WatchOptions): Observable<boolean> {
|
||||
export function watchHeader(
|
||||
el: HTMLElement, options: WatchOptions
|
||||
): Observable<Header> {
|
||||
return defer(() => {
|
||||
const styles = getComputedStyle(el)
|
||||
return of(
|
||||
styles.position === "sticky" ||
|
||||
styles.position === "-webkit-sticky"
|
||||
)
|
||||
})
|
||||
return defer(() => combineLatest([
|
||||
watchElementSize(el),
|
||||
isHidden(options)
|
||||
]))
|
||||
.pipe(
|
||||
combineLatestWith(watchElementSize(el), isHidden(options)),
|
||||
map(([sticky, { height }, hidden]) => ({
|
||||
height: sticky ? height : 0,
|
||||
sticky,
|
||||
map(([{ height }, hidden]) => ({
|
||||
height,
|
||||
hidden
|
||||
})),
|
||||
distinctUntilChanged((a, b) => (
|
||||
a.sticky === b.sticky &&
|
||||
a.height === b.height &&
|
||||
a.hidden === b.hidden
|
||||
)),
|
||||
|
Loading…
Reference in New Issue
Block a user