From c767bcde7db4f5c1a9631516592aa56ef4fbbd5d Mon Sep 17 00:00:00 2001 From: wbuezas Date: Tue, 27 Feb 2024 10:55:45 -0300 Subject: [PATCH] Add scroll on LeftMenu item expansion --- src/components/LeftMenu.vue | 14 +++++++++++-- src/components/LeftMenuItemGroup.vue | 20 ++++++++++++++++++- src/composables/elementIsVisibleInViewport.js | 6 ++++++ 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 src/composables/elementIsVisibleInViewport.js diff --git a/src/components/LeftMenu.vue b/src/components/LeftMenu.vue index 1721adfec..c7496621d 100644 --- a/src/components/LeftMenu.vue +++ b/src/components/LeftMenu.vue @@ -1,6 +1,6 @@ diff --git a/src/components/LeftMenuItemGroup.vue b/src/components/LeftMenuItemGroup.vue index 1fdb41e7c..741d58228 100644 --- a/src/components/LeftMenuItemGroup.vue +++ b/src/components/LeftMenuItemGroup.vue @@ -1,6 +1,7 @@ + diff --git a/src/composables/elementIsVisibleInViewport.js b/src/composables/elementIsVisibleInViewport.js new file mode 100644 index 000000000..e9f284855 --- /dev/null +++ b/src/composables/elementIsVisibleInViewport.js @@ -0,0 +1,6 @@ +export const elementIsVisibleInViewport = (el) => { + const { top, left, bottom, right } = el.getBoundingClientRect(); + const { innerHeight, innerWidth } = window; + + return top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth; +};