Git Product home page Git Product logo

Comments (12)

AtkinsSJ avatar AtkinsSJ commented on May 18, 2024 2

Took some digging, but I remembered this article from years ago describing creating an invisible triangle so that you're still hovering the correct menu: https://css-tricks.com/dropdown-menus-with-more-forgiving-mouse-movement-paths/#aa-get-fancy-with-a-javascript-built-triangle Not sure how easy that is to implement but it looks like there's a jQuery plugin included that you might be able to use, or learn from.

from puter.

Hiya-its-Aya avatar Hiya-its-Aya commented on May 18, 2024 1

Hi @jelveh I would love to work on this!

from puter.

Hiya-its-Aya avatar Hiya-its-Aya commented on May 18, 2024 1

Okay I've been super close, thanks @AtkinsSJ ! I have implemented the plugin but I also tweaked it in order to have the menuAim.submenuDirection detrmined in UIContextMenu.js. It works pretty seamlessly, but I'm still running into an issue that basically the first time the main menu pop ups up, it will determine if the menu is left or right and won't change until page reload. The idea is to have the menuAim.submenuDirection change each time a main menu pops up. Any help would be great. Thanks
I made a new branch you can check out here: https://github.com/Hiya-its-Aya/puter/tree/slow-sub-v2

from puter.

Hiya-its-Aya avatar Hiya-its-Aya commented on May 18, 2024 1

Sure thing! @jelveh

from puter.

jelveh avatar jelveh commented on May 18, 2024

Thank you! Let's go! Let me know if you need help.

from puter.

Hiya-its-Aya avatar Hiya-its-Aya commented on May 18, 2024

The closest I've gotten so far is I use a setTimeout to wait to add the context-menu-active class to contextMenu, so the mouseover does not trigger prematurely and gives some time for the user navigate to the submenu.

Here's the code starting from about line 150 of UIContextMenu.js:

// when mouse is over an item
    $(contextMenu).find('.context-menu-item').on('mouseover', function (e) {
         //and if conxtext menu is active
        if($(contextMenu).hasClass('context-menu-active')){
            // mark other items as inactive
            $(contextMenu).find('.context-menu-item').removeClass('context-menu-item-active');
            console.log("remove active", contextMenu)
            // mark this item as active
            $(this).addClass('context-menu-item-active');
            console.log("make active", contextMenu)
            // close any submenu that doesn't belong to this item
            $(`.context-menu[data-parent-id="${menu_id}"]`).remove();
            console.log("remove submenu", contextMenu)
            // mark this context menu as active after .7 seconds if submenu is open
            if($(this).attr('data-has-submenu') === 'true'){
                // $(contextMenu).removeClass('context-menu-active');   
                let timeout = setTimeout(() => {
                    console.log("menu is now active", contextMenu)
                    $(contextMenu).addClass('context-menu-active');
                    clearTimeout(timeout);  
                }, 300);    
            }   
        }
    })

One issue I'm having is that some items are not responding when hovered, or if I hover too fast past the items with submenus it lags and/or other submenus will pop up. I know it's becuase of the setTimeout so best solution I have is to make it 300ms. I'm sure there's somethng better but I'm trying not to abstract the whole mouseover event to keep it simple. I pushed it to my repo: https://github.com/Hiya-its-Aya/puter/tree/slow-submenu

Any sugestions would be awesome! Thanks!

from puter.

jelveh avatar jelveh commented on May 18, 2024

This is such an elegant solution! Thanks @AtkinsSJ

from puter.

Hiya-its-Aya avatar Hiya-its-Aya commented on May 18, 2024

Yes, thanks @AtkinsSJ ! I did take a look earlier today but didn't have time to implement it and looks like its's just what I need! I think this would have to be tweaked to account for both left and right since it only accounts for the submenu being on the right. Hopefully this works out!

from puter.

jelveh avatar jelveh commented on May 18, 2024

Awesome!
I'll look into this. @AtkinsSJ you're welcome to chime in as well.

from puter.

jelveh avatar jelveh commented on May 18, 2024

@Hiya-its-Aya could you submit a draft PR so that we could review it together?

from puter.

Hiya-its-Aya avatar Hiya-its-Aya commented on May 18, 2024

You know what @jelveh I think I got it! I'll clean it up and do a PR soon.

from puter.

jelveh avatar jelveh commented on May 18, 2024

Nice!! Can't wait to see it in action

from puter.

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.