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>
|
||||
{% endblock %}
|
||||
{% 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"] %}
|
||||
<script src="{{ path | url }}"></script>
|
||||
{% endfor %}
|
||||
|
@ -28,10 +28,12 @@ import {
|
||||
defer,
|
||||
distinctUntilChanged,
|
||||
distinctUntilKeyChanged,
|
||||
filter,
|
||||
finalize,
|
||||
map,
|
||||
mergeWith,
|
||||
switchMap,
|
||||
take,
|
||||
takeLast,
|
||||
takeUntil,
|
||||
tap
|
||||
@ -40,7 +42,8 @@ import {
|
||||
import { feature } from "~/_"
|
||||
import {
|
||||
getElementContentSize,
|
||||
watchElementSize
|
||||
watchElementSize,
|
||||
watchElementVisibility
|
||||
} from "~/browser"
|
||||
import { renderClipboardButton } from "~/templates"
|
||||
|
||||
@ -153,7 +156,9 @@ export function mountCodeBlock(
|
||||
el: HTMLElement, options: MountOptions
|
||||
): Observable<Component<CodeBlock | Annotation>> {
|
||||
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>()
|
||||
push$.subscribe(({ scrollable }) => {
|
||||
if (scrollable && hover)
|
||||
@ -213,4 +218,12 @@ export function mountCodeBlock(
|
||||
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