mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-27 17:00:54 +01:00
Fixed incorrect calculation of anchors, huge performance gain
This commit is contained in:
parent
01f2e11410
commit
43f2a71f03
1
.browserslistrc
Normal file
1
.browserslistrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
last 4 years
|
24
material/assets/javascripts/bundle.95400cd1.min.js
vendored
Normal file
24
material/assets/javascripts/bundle.95400cd1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
material/assets/javascripts/bundle.95400cd1.min.js.map
Normal file
1
material/assets/javascripts/bundle.95400cd1.min.js.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
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"assets/javascripts/bundle.js": "assets/javascripts/bundle.e2cc5a44.min.js",
|
"assets/javascripts/bundle.js": "assets/javascripts/bundle.95400cd1.min.js",
|
||||||
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.e2cc5a44.min.js.map",
|
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.95400cd1.min.js.map",
|
||||||
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.926ffd9e.min.js",
|
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.926ffd9e.min.js",
|
||||||
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.926ffd9e.min.js.map",
|
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.926ffd9e.min.js.map",
|
||||||
"assets/stylesheets/app-palette.scss": "assets/stylesheets/app-palette.8adb38b9.min.css",
|
"assets/stylesheets/app-palette.scss": "assets/stylesheets/app-palette.8adb38b9.min.css",
|
||||||
|
@ -195,7 +195,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/bundle.e2cc5a44.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.95400cd1.min.js' | url }}"></script>
|
||||||
{%- set translations = {} -%}
|
{%- set translations = {} -%}
|
||||||
{%- for key in [
|
{%- for key in [
|
||||||
"clipboard.copy",
|
"clipboard.copy",
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { difference, reverse } from "ramda"
|
import { reverse } from "ramda"
|
||||||
import {
|
import {
|
||||||
MonoTypeOperatorFunction,
|
MonoTypeOperatorFunction,
|
||||||
Observable,
|
Observable,
|
||||||
@ -29,12 +29,14 @@ import {
|
|||||||
pipe
|
pipe
|
||||||
} from "rxjs"
|
} from "rxjs"
|
||||||
import {
|
import {
|
||||||
|
bufferCount,
|
||||||
distinctUntilChanged,
|
distinctUntilChanged,
|
||||||
distinctUntilKeyChanged,
|
distinctUntilKeyChanged,
|
||||||
finalize,
|
finalize,
|
||||||
map,
|
map,
|
||||||
observeOn,
|
observeOn,
|
||||||
scan,
|
scan,
|
||||||
|
startWith,
|
||||||
switchMap,
|
switchMap,
|
||||||
tap
|
tap
|
||||||
} from "rxjs/operators"
|
} from "rxjs/operators"
|
||||||
@ -148,7 +150,7 @@ export function watchAnchorList(
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
/* Re-compute partition when viewport offset changes */
|
/* Re-compute partition when viewport offset changes */
|
||||||
switchMap(index => combineLatest(adjust$, viewport$)
|
switchMap(index => combineLatest([adjust$, viewport$])
|
||||||
.pipe(
|
.pipe(
|
||||||
scan(([prev, next], [adjust, { offset: { y } }]) => {
|
scan(([prev, next], [adjust, { offset: { y } }]) => {
|
||||||
|
|
||||||
@ -183,7 +185,7 @@ export function watchAnchorList(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Compute and return anchor list migrations */
|
/* Compute and return anchor list migrations */
|
||||||
return partition$
|
return partition$
|
||||||
.pipe(
|
.pipe(
|
||||||
map(([prev, next]) => ({
|
map(([prev, next]) => ({
|
||||||
@ -192,14 +194,25 @@ export function watchAnchorList(
|
|||||||
})),
|
})),
|
||||||
|
|
||||||
/* Extract anchor list migrations */
|
/* Extract anchor list migrations */
|
||||||
scan<AnchorList>((a, b) => {
|
startWith({ prev: [], next: [] }),
|
||||||
const begin = Math.max(0, Math.min(b.prev.length, a.prev.length) - 1)
|
bufferCount(2, 1),
|
||||||
const end = Math.max(b.prev.length, a.prev.length)
|
map(([a, b]) => {
|
||||||
return {
|
|
||||||
prev: b.prev.slice(begin, end + 1),
|
/* Moving down */
|
||||||
next: difference(b.next, a.next)
|
if (a.prev.length < b.prev.length) {
|
||||||
|
return {
|
||||||
|
prev: b.prev.slice(Math.max(0, a.prev.length - 1), b.prev.length),
|
||||||
|
next: []
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Moving up */
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
prev: b.prev.slice(-1),
|
||||||
|
next: b.next.slice(0, b.next.length - a.next.length)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, { prev: [], next: [] })
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user