From 8bc5ae06ed802e83361909754cee993d7afc103f Mon Sep 17 00:00:00 2001 From: Peter Savchenko Date: Thu, 21 Jul 2022 01:00:46 +0300 Subject: [PATCH] optimization --- src/frontend/js/classes/table-of-content.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/frontend/js/classes/table-of-content.js b/src/frontend/js/classes/table-of-content.js index 682bad1..86a879c 100644 --- a/src/frontend/js/classes/table-of-content.js +++ b/src/frontend/js/classes/table-of-content.js @@ -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 */