Skip to content

Instantly share code, notes, and snippets.

@ultim8k
Last active April 24, 2018 20:34
Show Gist options
  • Save ultim8k/7752eb1d4cf105e8c4b9332be80b6b06 to your computer and use it in GitHub Desktop.
Save ultim8k/7752eb1d4cf105e8c4b9332be80b6b06 to your computer and use it in GitHub Desktop.
apothema
/**
* We create a timeout for menu-trigger in order to delay triggering the menu opening.
* If the user leaves the trigger button or hovers again we cancel the timeout to avoid
* the menu opening unexpectedly.
*
* To try the solution in browser console we need to run the following command first:
* `$('#open-mega-menu').unbind('mouseenter mouseleave');`
*
* To use the solution we remove the `$('#open-mega-menu').hover(...);` command with the new code.
*
*/
var megaMenuTriggerTimeout = null;
function openMegaMenuWithDelay() {
clearTimeout(megaMenuTriggerTimeout);
megaMenuTriggerTimeout = setTimeout(openMegaMenu, 800);
}
function cancelMegaMenuOpen() {
clearTimeout(megaMenuTriggerTimeout);
}
function openMegaMenu() {
if ($('.js_mega_menu').hasClass('js_is_mobile')) {
return false;
}
$('.js_mega_menu').css('top', '-41px');
$('.js_mega_menu').removeClass('hide');
$('.js_sub_item').removeClass('active');
resizeMegaMenu();
}
$('#open-mega-menu').hover(openMegaMenuWithDelay);
$('#open-mega-menu').on('mouseleave', cancelMegaMenuOpen);
<!--
| Product rating - unexpected 1px space on the right
| Simply adding pull-right to the col-md element fixes the problem because it forces the element to stick right.
-->
<div class="row">
<div class="col-md-12">
<div class="brand__box container-fluid">
<div class="row">
<div class="col-md-3 text-center Aligner">
<div class="Aligner-item">
product image
</div>
</div>
<div class="col-md-7">
product description
</div>
<div class="col-md-2 reviews__rating filter-blue Aligner">
<div class="text-center Aligner-item">
<div class="reviews__rating__total">4,6</div>
<div class="star-ratings-sprite"><span style="width:52%" class="star-ratings-sprite-rating"></span></div>
<p><a href="#">(250)</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment