Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8591703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:35:13+00:00 2026-06-11T23:35:13+00:00

I have a neat little jQuery script I am working on. Goal: parent div

  • 0

I have a neat little jQuery script I am working on.

Goal: parent div with overflow hidden holds a larger div with image. When I move the mouse to the left or right of the parent div, the div with image changes margin-left to move left or right.

Problem is… if I move the mouse out of the parent div (left or right), the image keeps going. I need the image to stop when the mouse is not on the inside left or right edge of the parent div.

Any ideas?

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

        <script type="text/javascript">
            //<![CDATA[

              jQuery.noConflict ();

              jQuery(document).ready(function(){

                jQuery('#container').mousemove(function(e){
                  var parentWidth = jQuery('#container').width();
                  var parentWidthLeft = Math.round(.1 * jQuery('#container').width());
                  var parentWidthRight = Math.round(jQuery('#container').width() - parentWidthLeft);
                  var parentHeight = jQuery('#container').height();
                  var parentOffset = jQuery('#container').offset();
                  var X = Math.round(e.pageX - parentOffset.left);
                  var Y = Math.round(e.pageY - parentOffset.top);

                 if (X<parentWidthLeft)
                    {
                      jQuery('#image').animate({'left': '-' + parentWidth }, 5000);
                    }
                 if (X>parentWidthRight)
                    {
                      jQuery('#image').animate({'left': parentWidth }, 5000);
                    }
                 if (X<=parentWidthRight && X>=parentWidthLeft)
                    {
                      jQuery('#image').stop();
                    }
                 if (X<1)
                    {
                      jQuery('#image').stop();
                    }


                  });

                  jQuery('#container').mouseleave(function(){
                      jQuery('#image').stop();
                  });




              });

            // ]]>
        </script>

    </head>
    <body>

    <div id="container" style="width: 500px; height: 500px; overflow: hidden; border: 10px solid #000; position: relative; margin: auto auto;">
        <div id="image" style="position: absolute; left: 0; top: 0;"><img src="http://dump4free.com/imgdump/1/Carmen-Electra_1wallpaper1024x768.jpg" alt="" /></div>
    </div>

    </body>
    </html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:35:14+00:00Added an answer on June 11, 2026 at 11:35 pm

    The stop() function of jQuery can have a boolean parameter named “clearQueue”.
    If you try to use .stop(true) instead of .stop(), the animation will stop correctly, and your page run well.

    The fact is when you move your mouse, a lot of event are fired and a lot of animation are triggered.

    One is currently running, and all others are store in a queue, and executed later (after the first animation finish).

    In this way, the framework has a “memory” of the chronological list of event.

    By using stop(true), you order to flush completely the queue of animation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok I have this neat little piece of JQuery I have been working on.
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
In the Wikipedia Article on Block Cipher Modes they have a neat little diagram
So I have this neat little javascript function that I'm using to print text
I'm trying to write a little greasemonkey script/bookmarklet/what have you for Google Docs. The
I have a neat little javascript data grid and I want people to be
I have a little shader that looks like this, and has a neat effect.
I have been working on a childish little program: there are a bunch of
On the World of Warcraft forums they have a neat style set up that
I have never found a neat(er) way of doing the following. Say I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.