style(2054): Remove unnessessary nesting
Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2372>
This commit is contained in:
parent
0cbe567ac1
commit
90f93e052e
|
@ -105,18 +105,17 @@ const openMenu = () => {
|
||||||
// little magic to ensure the menu is always visible in the viewport
|
// little magic to ensure the menu is always visible in the viewport
|
||||||
// By default, try to display it on the right if there is enough room
|
// By default, try to display it on the right if there is enough room
|
||||||
const menu = dropdown.value.find('.menu')
|
const menu = dropdown.value.find('.menu')
|
||||||
if (!menu.classList.includes('visible')) {
|
if (menu.classList.includes('visible')) return
|
||||||
const viewportOffset = menu.get(0)?.getBoundingClientRect() ?? { right: 0, left: 0 }
|
const viewportOffset = menu.get(0)?.getBoundingClientRect() ?? { right: 0, left: 0 }
|
||||||
const viewportWidth = document.documentElement.clientWidth
|
const viewportWidth = document.documentElement.clientWidth
|
||||||
const rightOverflow = viewportOffset.right - viewportWidth
|
const rightOverflow = viewportOffset.right - viewportWidth
|
||||||
const leftOverflow = -viewportOffset.left
|
const leftOverflow = -viewportOffset.left
|
||||||
|
|
||||||
menu.css({
|
menu.css({
|
||||||
cssText: rightOverflow > 0
|
cssText: rightOverflow > 0
|
||||||
? `left: ${-rightOverflow - 5}px !important;`
|
? `left: ${-rightOverflow - 5}px !important;`
|
||||||
: `right: ${-leftOverflow + 5}px !important;`
|
: `right: ${-leftOverflow + 5}px !important;`
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue