mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fix initialization logic of toc blurring
This commit is contained in:
parent
96ae06f25c
commit
113ba5fd8b
File diff suppressed because one or more lines are too long
@ -109,7 +109,7 @@
|
|||||||
<script src="https://cdn.mathjax.org/{{ path }}"></script>
|
<script src="https://cdn.mathjax.org/{{ path }}"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<script src="{{ base_url }}/assets/javascripts/application-e4e6991dc0.js"></script>
|
<script src="{{ base_url }}/assets/javascripts/application-cd89c74ae5.js"></script>
|
||||||
<script>
|
<script>
|
||||||
/* Configuration for application */
|
/* Configuration for application */
|
||||||
var config = {
|
var config = {
|
||||||
|
@ -41,10 +41,9 @@ export default class Blur {
|
|||||||
this.index_ = 0
|
this.index_ = 0
|
||||||
this.offset_ = window.pageYOffset
|
this.offset_ = window.pageYOffset
|
||||||
|
|
||||||
/* Index anchor node offsets for fast lookup, and deduct the static offset
|
/* Index anchor node offsets for fast lookup */
|
||||||
of the header (56px) and sidebar offset (24px), see _permalinks.scss */
|
|
||||||
this.anchors_ = [].map.call(this.els_, el => {
|
this.anchors_ = [].map.call(this.els_, el => {
|
||||||
return document.querySelector(el.hash).offsetTop - (56 + 24)
|
return document.querySelector(el.hash)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +56,9 @@ export default class Blur {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update anchor states
|
* Update anchor states
|
||||||
|
*
|
||||||
|
* Deduct the static offset of the header (56px) and sidebar offset (24px),
|
||||||
|
* see _permalinks.scss for more information.
|
||||||
*/
|
*/
|
||||||
update() {
|
update() {
|
||||||
const offset = window.pageYOffset
|
const offset = window.pageYOffset
|
||||||
@ -68,7 +70,7 @@ export default class Blur {
|
|||||||
/* Scroll direction is down */
|
/* Scroll direction is down */
|
||||||
if (this.offset_ <= offset) {
|
if (this.offset_ <= offset) {
|
||||||
for (let i = this.index_ + 1; i < this.els_.length; i++) {
|
for (let i = this.index_ + 1; i < this.els_.length; i++) {
|
||||||
if (this.anchors_[i] <= offset) {
|
if (this.anchors_[i].offsetTop - (56 + 24) <= offset) {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
this.els_[i - 1].dataset.mdState = "blur"
|
this.els_[i - 1].dataset.mdState = "blur"
|
||||||
this.index_ = i
|
this.index_ = i
|
||||||
@ -80,7 +82,7 @@ export default class Blur {
|
|||||||
/* Scroll direction is up */
|
/* Scroll direction is up */
|
||||||
} else {
|
} else {
|
||||||
for (let i = this.index_; i >= 0; i--) {
|
for (let i = this.index_; i >= 0; i--) {
|
||||||
if (this.anchors_[i] > offset) {
|
if (this.anchors_[i].offsetTop - (56 + 24) > offset) {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
this.els_[i - 1].dataset.mdState = ""
|
this.els_[i - 1].dataset.mdState = ""
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user