chg: [layout:sidebar] Added a bit of JS to not close the sidebar sub-menu right after the mouse leaves

pull/9439/head
Sami Mokaddem 2023-12-05 10:14:39 +01:00
parent ce6825ccaa
commit 1a078e2783
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
3 changed files with 18 additions and 1 deletions

View File

@ -174,7 +174,7 @@ main.content {
top: 50%;
}
.sidebar .sidebar-link-container:hover .submenu-container {
display: block;
/* display: block; */
}
.sidebar .sidebar-link-container .submenu-container:hover {
display: block;

View File

@ -321,4 +321,17 @@ $(document).ready(() => {
$('.sidebar #btn-add-bookmark').click(() => {
openSaveBookmarkModal(window.location.pathname)
})
$('.sidebar .sidebar-link-container.parent').on('mouseenter', function() {
const $subContainer = $(this).find('.submenu-container')
$subContainer.css({ display: 'block' })
$(this).on('mouseleave', function() {
delay(function () {
if (!$subContainer[0].matches(':hover')) {
$subContainer.css({ display: 'none' })
$(this).trigger('mouseenter')
}
}, 150)
})
})
})

View File

@ -147,6 +147,10 @@ function debounce(func, wait, options) {
return debounced
}
function delay(func, wait, ...args) {
return setTimeout(func, wait, ...args)
}
function arrayEqual(array1, array2) {
const array2Sorted = array2.slice().sort();
return array1.length === array2.length && array1.slice().sort().every((value, index) => value === array2Sorted[index])