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
    226

    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,500
    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.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  3. #3
    Join Date
    Oct 2013
    Posts
    600
    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