Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoHide does not work properly when the trigger object is affixed on screen. #95

Closed
alickq opened this issue Dec 12, 2012 · 1 comment
Labels

Comments

@alickq
Copy link

alickq commented Dec 12, 2012

I have created a web site that has a tree object on the left hand side and some content on the right. I fixed the position of the tree so that when the window scroll, the tree stays. When I ture on the AutoHide feature, it does not recognize the fact that I am still inside the trigger object when I move my mouse so the menu disappear as soon as I move my mouse to the left just by a tiny little bit. I have looked at the source code and found that you are using .position() function to get the position of the menu. If I change it to use .offset() instead, it all worked fine. I am wondering if there is a reason why you use .position() over .offset()? Here is the code segment:

        if (opt.autoHide) {
            // trigger element coordinates

// var pos = $this.position();

            // change to use .offset instead as .position returns position relative to offset parent where offset is relative to 
            //       the page or document.  It will not work if the triggering object has a fix position if we use .position.
            var pos = $this.offset();
            pos.right = pos.left + $this.outerWidth();
            pos.bottom = pos.top + this.outerHeight();
            // mouse position handler
            $(document).on('mousemove.contextMenuAutoHide', function(e) {
                if (opt.$layer && !opt.hovering && (!(e.pageX >= pos.left && e.pageX <= pos.right) || !(e.pageY >= pos.top && e.pageY <= pos.bottom))) {
                    // if mouse in menu...
                    opt.$menu.trigger('contextmenu:hide');
                }
            });
        }
@rodneyrehm
Copy link
Contributor

I'll look into this around christmas. The jQuery.offset() hunch is confirmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants