mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Improved performance for very large pages
This commit is contained in:
parent
1d9d6782dd
commit
e71891f497
File diff suppressed because one or more lines are too long
29
material/assets/javascripts/bundle.467223ff.min.js
vendored
Normal file
29
material/assets/javascripts/bundle.467223ff.min.js
vendored
Normal file
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.3900859e.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.467223ff.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 %}
|
||||||
|
@ -28,10 +28,12 @@ import {
|
|||||||
defer,
|
defer,
|
||||||
distinctUntilChanged,
|
distinctUntilChanged,
|
||||||
distinctUntilKeyChanged,
|
distinctUntilKeyChanged,
|
||||||
|
filter,
|
||||||
finalize,
|
finalize,
|
||||||
map,
|
map,
|
||||||
mergeWith,
|
mergeWith,
|
||||||
switchMap,
|
switchMap,
|
||||||
|
take,
|
||||||
takeLast,
|
takeLast,
|
||||||
takeUntil,
|
takeUntil,
|
||||||
tap
|
tap
|
||||||
@ -40,7 +42,8 @@ import {
|
|||||||
import { feature } from "~/_"
|
import { feature } from "~/_"
|
||||||
import {
|
import {
|
||||||
getElementContentSize,
|
getElementContentSize,
|
||||||
watchElementSize
|
watchElementSize,
|
||||||
|
watchElementVisibility
|
||||||
} from "~/browser"
|
} from "~/browser"
|
||||||
import { renderClipboardButton } from "~/templates"
|
import { renderClipboardButton } from "~/templates"
|
||||||
|
|
||||||
@ -153,7 +156,9 @@ export function mountCodeBlock(
|
|||||||
el: HTMLElement, options: MountOptions
|
el: HTMLElement, options: MountOptions
|
||||||
): Observable<Component<CodeBlock | Annotation>> {
|
): Observable<Component<CodeBlock | Annotation>> {
|
||||||
const { matches: hover } = matchMedia("(hover)")
|
const { matches: hover } = matchMedia("(hover)")
|
||||||
return defer(() => {
|
|
||||||
|
/* Defer mounting of code block - see https://bit.ly/3vHVoVD */
|
||||||
|
const factory$ = defer(() => {
|
||||||
const push$ = new Subject<CodeBlock>()
|
const push$ = new Subject<CodeBlock>()
|
||||||
push$.subscribe(({ scrollable }) => {
|
push$.subscribe(({ scrollable }) => {
|
||||||
if (scrollable && hover)
|
if (scrollable && hover)
|
||||||
@ -213,4 +218,12 @@ export function mountCodeBlock(
|
|||||||
map(state => ({ ref: el, ...state }))
|
map(state => ({ ref: el, ...state }))
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/* Mount code block on first sight */
|
||||||
|
return watchElementVisibility(el)
|
||||||
|
.pipe(
|
||||||
|
filter(visible => visible),
|
||||||
|
take(1),
|
||||||
|
switchMap(() => factory$)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user