dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: jQuery: How to Detect When Mouse Enters Left Third of Window?

  1. #1
    Join Date
    Jan 2003
    Posts
    228

    Question jQuery: How to Detect When Mouse Enters Left Third of Window?

    I need to detect when the mouse enters the left third (33%) of the browser window and detect when it leaves. I'm assuming it's a combination of either mousemove() or mouseenter() and pageX. Correct? Something like this?

    Code:
    var thirdOfWindow = jQuery(window).width() / 3;
    jQuery().mousemove(function(e) {
        if (e.pageX <= thirdOfWindow) {
            // Slide Sidebar Out
         } else if (e.pageX > thirdOfWindow) {
            // Slide Sidebar Back
        }
    });
    I also need to account for the window being resized and the 33% of the browser window changing.

    This is to animate the leftMargin for a sidebar DIV out and back in. If I'm missing an obvious better way to do this -- let me know. I can't use a transparent DIV hover -- because there are links in the sidebar.

    Thank you for your help.

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,744
    JavaScript Frameworks forum next to this forum is the best place to ask.

    *** Thread moved - jedaisoul ***
    Last edited by jedaisoul; 07-13-2014 at 03:23 PM.
    STOP using $ prefix on JavaScript variable names...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  3. #3
    Join Date
    Oct 2013
    Posts
    728
    Quote Originally Posted by \\.\ View Post
    JavaScript Frameworks forum next to this forum is the best place to ask.
    Isn't that where this thread is?

    Forum >> Client-Side Development >> JavaScript Frameworks (such as JScript) >> jQuery: How to Detect When Mouse Enters Left Third of Window?

    Unless it got moved by a mod...

    Yes, I moved it. Perhaps I should have annotated the comment - jedaisoul
    Last edited by jedaisoul; 07-13-2014 at 03:22 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles