This topic has 11 replies, 2 voices, and was last updated 6 years, 1 months ago ago by Rose Tyler
Hi –
I’m trying to trigger the page hover on the .menu-wrapper vs. the .secondary-menu-wrapper. I tried swapping out the instances of .secondary-menu-wrapper with .menu-wrapper in theme.js below but it doesn’t seem to trigger it. Am I missing something?
secondaryMenu: function() {
$('.et-secondary-visibility-on_click').on('click', '.secondary-title', function() {
secondaryShowHide();
});
$('.et-secondary-visibility-on_hover.et-secondary-darkerning-on').on('mouseover', '.secondary-menu-wrapper', function() {
secondaryShow();
});
$('.et-secondary-visibility-on_hover.et-secondary-darkerning-on').on('mouseleave', '.secondary-menu-wrapper', function() {
secondaryHide();
});
var secondaryShowHide = function() {
if($('body').hasClass('et-secondary-shown')) {
secondaryHide();
} else {
secondaryShow();
}
};
var secondaryShow = function () {
$('body').addClass('et-secondary-shown');
}
var secondaryHide = function () {
$('body').removeClass('et-secondary-shown');
}
$(document).on('click touchstart', function(event) {
if( !$(event.target).closest('.secondary-menu-wrapper').length ) {
if($('body').hasClass('et-secondary-shown')) {
$('body').removeClass('et-secondary-shown');
}
}
})
},
Hang on, I figured it out. I was doing it on the wrong file. Change has to be done on the minified js file ‘etheme.min.js’. Ok, so now that I’ve figured this out, how would you recommend I apply this in my child these to not affect the core file?
Hello,
1) Please describe the desired result in more details for better understanding and provide your site URL.
2) You can create etheme-child.js file with your code in child theme folder then add http://prntscr.com/ld5nxb into xstore-child/functions.php file
wp_enqueue_script('et-child-js', get_stylesheet_directory_uri().'/etheme-child.js', array(),false,true);
Regards
Hi Rose. I’ve provided details below.
Hello,
Please add this code in style.css of child theme:
body:before {
content: "";
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
z-index: -1;
display: none;
animation: slideOut;
}
.menu-item-hovered:before {
display: block;
z-index: 1002;
animation-name: fadeIn;
animation-duration: 0.2s;
}
.menu-item-hovered .page-wrapper {
z-index: auto;
}
.menu-item-hovered .header-wrapper {
z-index: 1003;
}
and this:
jQuery(document).ready(function($){
$('.menu-wrapper>.menu-main-container>.menu>.item-with-block').on('mouseover', function() {
$('body').addClass('menu-item-hovered');
});
$('.menu-wrapper>.menu-main-container>.menu>.item-with-block').on('mouseleave', function() {
$('body').removeClass('menu-item-hovered');
})
});
into etheme-child.js file
https://gyazo.com/86fb2cb17c8a326f246c8bf30edd6ab4
Regards
This is great Rose. Thank you for your help. Once again!
Hi Rose. I noticed that this doesn’t darken the whole page. As you scroll down, it only cover’s the height of the static block. What do I need to adjust in the css to push it full height?
Hello,
Please add this code:
.menu-item-hovered {
position: relative;
}
Regards
Did the trick.
Here’s the final solution.
XStore – How to make page darkening happen on menu (non-secondary menu) that have static blocks as mega-menu dropdown
CSS
body:before {
content: "";
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
z-index: -1;
display: none;
animation: slideOut;
}
.menu-item-hovered:before {
display: block;
z-index: 1002;
animation-name: fadeIn;
animation-duration: 0.2s;
}
.menu-item-hovered .page-wrapper {
z-index: auto;
}
.menu-item-hovered .header-wrapper {
z-index: 1003;
}
.menu-item-hovered {
position: relative;
}
JS
jQuery(document).ready(function($){
$('.menu-wrapper>.menu-main-container>.menu>.item-with-block').on('mouseover', function() {
$('body').addClass('menu-item-hovered');
});
$('.menu-wrapper>.menu-main-container>.menu>.item-with-block').on('mouseleave', function() {
$('body').removeClass('menu-item-hovered');
})
});
Hello,
Great. Thank you for letting us know.
Regards
You must be logged in to reply to this topic.Log in/Sign up