Change how current entry is indicated
This commit is contained in:
parent
3ca84e3a85
commit
8db830b468
@ -230,3 +230,7 @@ div.glossary-item.compact-glossary {
|
|||||||
.info-output td {
|
.info-output td {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.entry:not(.entry-current) .current {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
@ -412,16 +412,23 @@ class Display {
|
|||||||
index = Math.min(index, this.definitions.length - 1);
|
index = Math.min(index, this.definitions.length - 1);
|
||||||
index = Math.max(index, 0);
|
index = Math.max(index, 0);
|
||||||
|
|
||||||
$('.current').hide().eq(index).show();
|
const entryPre = this.getEntry(this.index);
|
||||||
|
if (entryPre !== null) {
|
||||||
|
entryPre.classList.remove('entry-current');
|
||||||
|
}
|
||||||
|
|
||||||
|
const entry = this.getEntry(index);
|
||||||
|
if (entry !== null) {
|
||||||
|
entry.classList.add('entry-current');
|
||||||
|
}
|
||||||
|
|
||||||
this.windowScroll.stop();
|
this.windowScroll.stop();
|
||||||
const entry = $('.entry').eq(index);
|
|
||||||
let target;
|
let target;
|
||||||
|
|
||||||
if (scroll) {
|
if (scroll) {
|
||||||
target = scroll;
|
target = scroll;
|
||||||
} else {
|
} else {
|
||||||
target = index === 0 ? 0 : entry.offset().top;
|
target = index === 0 || entry === null ? 0 : Display.getElementTop(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smooth) {
|
if (smooth) {
|
||||||
@ -606,4 +613,10 @@ class Display {
|
|||||||
addEventListeners(selector, ...args) {
|
addEventListeners(selector, ...args) {
|
||||||
this.container.querySelectorAll(selector).forEach((node) => node.addEventListener(...args));
|
this.container.querySelectorAll(selector).forEach((node) => node.addEventListener(...args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getElementTop(element) {
|
||||||
|
const elementRect = element.getBoundingClientRect();
|
||||||
|
const documentRect = document.documentElement.getBoundingClientRect();
|
||||||
|
return elementRect.top - documentRect.top;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user