Code Monkey home page Code Monkey logo

Comments (15)

MBWebTechMariusz avatar MBWebTechMariusz commented on June 11, 2024 2

I've had the same issue, and wanted to share the complete solution:

exitMenu: function (row) {
    return true;
},

This should be added in the docs, so other people can easily use this in their projects.

from jquery-menu-aim.

rossmedia avatar rossmedia commented on June 11, 2024 1

This bug is a general bug and not related to bottom setting or Shopware.

The bug also exists in the offical demo under:
https://rawgit.com/kamens/jQuery-menu-aim/master/example/example.html

Steps to reproduce:

  • Open https://rawgit.com/kamens/jQuery-menu-aim/master/example/example.html
  • Click on "Explode the monkeys" to open sub menu
  • Mouse over over any of the menu items, let's say "Patas"
  • Move your mouse out to the left and click anywhere on the page so the dropdown will be closed
  • Click again on "Explode the Monkeys" to open sub menu
  • Mouse over over the "Patas" again

Expected result

  • Drop-Down for "Patas" should open

Current result

  • Drop-Down does not open

from jquery-menu-aim.

heun01 avatar heun01 commented on June 11, 2024 1

The mouseleaveMenu function only triggers the deactivate function, if the exitMenu option is supplied and returns true:

`
$('.module-nav .module-nav__lvl1').each(function () {
var $menu = $(this);
$menu.menuAim({
activate: activateSubmenu,
exitMenu: deactivateSubmenu,
submenuDirection: "below"
});
});

function activateSubmenu(row) {
var $row = $(row);
$row.addClass('-hover').siblings().removeClass('-hover');
}

function deactivateSubmenu(row) {
var $row = $(row);
$row.find('> .module-nav__item').removeClass('-hover');
return true;
}
`

from jquery-menu-aim.

MBWebTechMariusz avatar MBWebTechMariusz commented on June 11, 2024 1

@rossmedia I think this is not the intended behaviour, see this post: #50 (comment)
Because of this, I think it is better to make this option as an "opt-in"-option, rather than the default.

What do you think?

from jquery-menu-aim.

rossmedia avatar rossmedia commented on June 11, 2024 1

@MBWebTechMariusz Oh yes sorry now i understand the problem. When i implement your solution the benefit of this plugin (work like amazons menu and don't close when you) is not working anymore. :(

from jquery-menu-aim.

MLK97 avatar MLK97 commented on June 11, 2024

Problem exists because the activate function gets executed but the deactivate function doesn't get executed

from jquery-menu-aim.

stevepiron avatar stevepiron commented on June 11, 2024

Quite annoying indeed. I've just found out about this bug, which makes the plugin not a good fit for production.

from jquery-menu-aim.

stevepiron avatar stevepiron commented on June 11, 2024

I've just found a workaround. It isn't ideal but it works:

/**
 * @function `init`
 *
 * Initializes the desktop navigation behavior.
 *
 * 1. Hide the panel on exit.
 */
function init() {
    $navBar.menuAim({
        rowSelector: navGroup,
        activationDelay: 0,
        activate: function(el) {
            showNavPanel(el);
        },
        deactivate: function(el) {
            hideNavPanel(el);
        },
        exit: function(el) {
            hideNavPanel(el); /* [1] */
        },
        submenuDirection: 'above'
    });
    is_desktop_nav = true;
    enableClickOnPanelLabel();
}

/**
 * When leaving the panel, unbind the mouseenter event
 * and initialize menuAim again. Not ideal as it doesn't destroy
 * the first instance.
 */
$navPanel.on('mouseleave', function(e) {
    e.preventDefault();
    $navGroup.unbind('mouseenter');
    init();
});

So basically: hide the nav panel on exit, bind a mouseleave event to all panels and initialize menuAim again.

from jquery-menu-aim.

MLK97 avatar MLK97 commented on June 11, 2024

I tried your workaround and it does the job just fine. You basically just double force it. In my own workaround I made it exactly like that, even though it wasn't as elegant as yours.
Hopefully someone will solve this issue

from jquery-menu-aim.

youngjuning avatar youngjuning commented on June 11, 2024

same issue

from jquery-menu-aim.

stevepiron avatar stevepiron commented on June 11, 2024

@heun01 is that how you suggest to fix it? 🤔

from jquery-menu-aim.

heun01 avatar heun01 commented on June 11, 2024

Yeah works for me.

from jquery-menu-aim.

jakedowns avatar jakedowns commented on June 11, 2024

I had the same issue and I had overlooked this comment on exitMenu in the example config

if you have a exitMenu option, it needs to return true

// Function to call when mouse exits the entire menu. If this returns
// true, the current row's deactivation event and callback function
// will be fired. Otherwise, if this isn't supplied or it returns
// false, the currently activated row will stay activated when the
// mouse leaves the menu entirely.
exitMenu: function (row) {
    return true;
},

from jquery-menu-aim.

rossmedia avatar rossmedia commented on June 11, 2024

@MBWebTechMariusz Thanks! We had no exitMenu callback implemented so we just added a function like you did and with that it works fine. I think there should be some workaround implemented which fixes that bug and let exitMenu return true by default, even if no callback is implemented.

from jquery-menu-aim.

MBWebTechMariusz avatar MBWebTechMariusz commented on June 11, 2024

Yeah, this is a drawback. But I think this is intended, so we need to try it with just

exitMenu: function (row) {
    return true;
},

from jquery-menu-aim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.