1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-08-07 14:35:26 +02:00

optimization

This commit is contained in:
Peter Savchenko 2022-07-21 01:00:46 +03:00
parent 7b737209df
commit 8bc5ae06ed
No known key found for this signature in database
GPG key ID: E68306B1AB0F727C

View file

@ -288,6 +288,18 @@ export default class TableOfContent {
* @returns {void}
*/
scrollToActiveItemIfNeeded() {
/**
* Do nothing if the Table of Content has no internal scroll at this page
*
* @todo compute it once
*/
const hasScroll = this.nodes.wrapper.scrollHeight > this.nodes.wrapper.clientHeight;
if (!hasScroll) {
return;
}
/**
* If some item is highlighted, check whether we need to scroll to it or not
*/