mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03: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.map": "assets/javascripts/bundle.e2cc5a44.min.js.map",
|
||||
"assets/javascripts/bundle.js": "assets/javascripts/bundle.95400cd1.min.js",
|
||||
"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.map": "assets/javascripts/worker/search.926ffd9e.min.js.map",
|
||||
"assets/stylesheets/app-palette.scss": "assets/stylesheets/app-palette.8adb38b9.min.css",
|
||||
|
@ -195,7 +195,7 @@
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% block scripts %}
|
||||
<script src="{{ 'assets/javascripts/bundle.e2cc5a44.min.js' | url }}"></script>
|
||||
<script src="{{ 'assets/javascripts/bundle.95400cd1.min.js' | url }}"></script>
|
||||
{%- set translations = {} -%}
|
||||
{%- for key in [
|
||||
"clipboard.copy",
|
||||
|
@ -20,7 +20,7 @@
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { difference, reverse } from "ramda"
|
||||
import { reverse } from "ramda"
|
||||
import {
|
||||
MonoTypeOperatorFunction,
|
||||
Observable,
|
||||
@ -29,12 +29,14 @@ import {
|
||||
pipe
|
||||
} from "rxjs"
|
||||
import {
|
||||
bufferCount,
|
||||
distinctUntilChanged,
|
||||
distinctUntilKeyChanged,
|
||||
finalize,
|
||||
map,
|
||||
observeOn,
|
||||
scan,
|
||||
startWith,
|
||||
switchMap,
|
||||
tap
|
||||
} from "rxjs/operators"
|
||||
@ -148,7 +150,7 @@ export function watchAnchorList(
|
||||
}),
|
||||
|
||||
/* Re-compute partition when viewport offset changes */
|
||||
switchMap(index => combineLatest(adjust$, viewport$)
|
||||
switchMap(index => combineLatest([adjust$, viewport$])
|
||||
.pipe(
|
||||
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$
|
||||
.pipe(
|
||||
map(([prev, next]) => ({
|
||||
@ -192,14 +194,25 @@ export function watchAnchorList(
|
||||
})),
|
||||
|
||||
/* Extract anchor list migrations */
|
||||
scan<AnchorList>((a, b) => {
|
||||
const begin = Math.max(0, Math.min(b.prev.length, a.prev.length) - 1)
|
||||
const end = Math.max(b.prev.length, a.prev.length)
|
||||
return {
|
||||
prev: b.prev.slice(begin, end + 1),
|
||||
next: difference(b.next, a.next)
|
||||
startWith({ prev: [], next: [] }),
|
||||
bufferCount(2, 1),
|
||||
map(([a, b]) => {
|
||||
|
||||
/* Moving down */
|
||||
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