mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-28 01:10:58 +01:00
Fixed bug in scrollspy
This commit is contained in:
parent
9338045887
commit
2fd1740f3d
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -91,7 +91,7 @@
|
|||||||
var base_url = '{{ base_url }}';
|
var base_url = '{{ base_url }}';
|
||||||
var repo_url = '{{ repo_url }}';
|
var repo_url = '{{ repo_url }}';
|
||||||
</script>
|
</script>
|
||||||
<script src="{{ base_url }}/assets/javascripts/application-48691dba51.js"></script>
|
<script src="{{ base_url }}/assets/javascripts/application-409da39d08.js"></script>
|
||||||
{% for path in extra_javascript %}
|
{% for path in extra_javascript %}
|
||||||
<script src="{{ path }}"></script>
|
<script src="{{ path }}"></script>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -67,7 +67,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
var toc = new Sidebar('.md-sidebar--secondary');
|
var toc = new Sidebar('.md-sidebar--secondary');
|
||||||
toc.listen();
|
toc.listen();
|
||||||
|
|
||||||
var spy = new ScrollSpy('.md-nav--toc .md-nav__link');
|
var spy = new ScrollSpy('.md-sidebar--secondary .md-nav--secondary .md-nav__link');
|
||||||
spy.listen();
|
spy.listen();
|
||||||
|
|
||||||
window.addEventListener('resize', handler);
|
window.addEventListener('resize', handler);
|
||||||
|
@ -53,11 +53,10 @@ class ScrollSpy {
|
|||||||
* @param {Event} ev - Event
|
* @param {Event} ev - Event
|
||||||
*/
|
*/
|
||||||
update(ev) {
|
update(ev) {
|
||||||
let index = this.index_;
|
|
||||||
|
|
||||||
/* Scroll direction is down */
|
/* Scroll direction is down */
|
||||||
if (this.offset_ <= window.pageYOffset) {
|
if (this.offset_ <= window.pageYOffset) {
|
||||||
for (let i = this.index_; i < this.el_.length; i++) {
|
for (let i = this.index_ + 1; i < this.el_.length; i++) {
|
||||||
let anchor = document.querySelector(this.el_[i].hash);
|
let anchor = document.querySelector(this.el_[i].hash);
|
||||||
if (anchor.offsetTop <= window.pageYOffset) {
|
if (anchor.offsetTop <= window.pageYOffset) {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user