-
armandas
Hello, i´m really in love with the GP theme, very, very great work!!
Would you can help me make this effect or any ticket / documnetation allready exist?
I need, when from PC the menu is hover, make a body “dark shadow” (like the picture example).
It is my first support topic, sorry my english, have a nice day 🙂
-
Hi there,
It seems achievable using some CSS. The topic here appears to be similar to what you want to achieve:
https://generatepress.com/forums/topic/navigation-overlay/I checked your site, but it doesn’t have the menu navigation, so I cannot do any testing.
-
armandas
Hello again, yes i have tried this topic, but there is not the correct result for me, when clicked, the shadow is on sub-menu item, not on body, and my menu is hover, not clicked. (please see image)
Sorry, the website was maintenance mode, just i turned on, now you can see it 🙂
-
Hi there,
that method will only work when you have a fill width sub menu.
So remove that CSS, as what you need will require some Javascript.1. Hook in the following script to the
wp_footer
<script> const body = document.querySelector('body'); const menuItems = document.querySelectorAll('.menu-item-has-children'); const observer = new MutationObserver(mutations => { mutations.forEach(mutation => { if (mutation.type === 'attributes' && mutation.attributeName === 'class') { const target = mutation.target; const hasHoverClass = target.classList.contains('sfHover'); if ( hasHoverClass ) { body.classList.add('submenu-open'); } else { body.classList.remove('submenu-open'); } } }); }); menuItems.forEach(item => observer.observe(item, { attributes: true })); </script>
This observes the
sfHover
class when a sub menu is open and in turn adds a class of ofsubmenu-open
to the body tag.2. Add this CSS to style the page container when the
submenu-open
is present:.submenu-open #page { filter: brightness(0.5); }
-
armandas
Worked, thank you a lot, i am very happy, it is a great support!
-
Glad to be of help!
- You must be logged in to reply to this topic.