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 8694989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:55:16+00:00 2026-06-13T00:55:16+00:00

I want to implement a scroll on mouse move in jQuery. The purpose of

  • 0

I want to implement a scroll on mouse move in jQuery.

The purpose of scroll is to view the complete image.. which has appeared as Modal Popup.

This image is present as Div’s Background image.

I am able to move image up-down on mouse move using jQuery.
But the problem is the div’s background continues to scroll event after complete image is scrolled.
I have to stop this from happening.

for reference u can see:-

http://zovi.com/california-dream-t-shirt-white–S123RNM84602#2

Click on the big image, a modal popup will appear. On scrolling, complete image is viewed without extra scrolling.

I am trying to achieve this.
Thanks in Advance..

Here is my code:-

Complete HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style>
        .backdrop
        {
            position: relative;
            height: 300px; /*could be anything really..*/
            width: 400px; /*could be anything really..*/
            border: 3px solid #6699ff;
            background: url('image/TShirt/tshirtpicZoom1.jpg') 0 0 no-repeat;

        }

        .direction
        {
            position: absolute;
            width: 50%;
            height: 100%;
        }
        .top
        {
            left: 0;
            top: 0;
            width:100%;

        }
        .bottom
        {
            left: 0;
            top: 50%;
            width:100%;
        }
    </style>
    <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script>
        $(function () {
            var x = 0,
        y = 0,
        rate = 0,
        maxspeed = 10;
            var backdrop = $('.backdrop');

            $('.direction', backdrop).mousemove(function (e) {
                var $this = $(this);
                var top = $this.is('.top');

                if (top) {
                    var h = $this.height();
                    rate = (h - e.pageY - $(this).offset().top + 1) / h;
                }
                else {
                    var h = $this.height();
                    rate = -(e.pageY - $(this).offset().top + 1) / h;
                }
            });

            backdrop.hover(
        function () {
            var scroller = setInterval(moveBackdrop, 10);
            $(this).data('scroller', scroller);
        },
        function () {
            var scroller = $(this).data('scroller');
            clearInterval(scroller);
        }
    );

            function moveBackdrop() {
                y += maxspeed * rate;
                var newpos = x + 'px ' + y + 'px';

                backdrop.css('background-position', newpos);
            }
        }); 

    </script>
</head>
<body>
    <div class="backdrop">
        <div class="direction top">
        </div>
        <div class="direction bottom">
        </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-13T00:55:18+00:00Added an answer on June 13, 2026 at 12:55 am

    I got the solution myself….

    Here’s what I did…

    Take a Dummy image control and keep it hidden

    <img id="DummyImage" class="hidden" />
    

    Assign the image source to the dummy image control before calling modal popup i.e. on $('#BigImage') click event.

    Also make y and rate value 0

    y = 0;
    rate = 0;
    $("#DummyImage").attr('src', imageSrc);
    

    Now in the mouse move event i.e ‘moveImageZoomBox‘ function make the dummy image control visible and get the height of the image.

    In the same mouse move event take to variables as ‘scrollmin‘ and ‘scrollmax‘ and then

    scrollmin=-(height of the image)

    scrollmax=(height of the image)/2
    

    Now apply condition such the the value of should be between ‘scrollmin‘ and ‘scrollmax‘

    The ‘moveImageZoomBox‘ function will look like this:

    function moveImageZoomBox() {
                    y += maxspeed * rate;
                    var ScrollYMin = 0;
                    var ScrollYMax = 0;
                    var tths = this;
                    $("#DummyImage").show();
    
                    ScrollYMin = -($("#DummyImage")[0].naturalHeight-300);//in order to stop scrolling whole image up
                    ScrollYMax = $("#DummyImage")[0].naturalHeight / 2-200;//in order to stop scrolling whole image down
    
                    $("#DummyImage").hide();
    
                    var newpos = x + ' ' + y + 'px';
                    if (y > ScrollYMin && y < ScrollYMax) {
                        imageZoomBox.css('background-position', newpos);
                    }
                    else {
                        y -= maxspeed * rate;
                    }
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement a scroll view which looks like the stock ticker. It
I want to implement the floating window in the html which it has scroll
I want to implement Paginated list View in android so when I scroll down
I have a set of around 300 images. I want to implement scroll view
I want to implement a date scroll label which displays a current date. Now,
i want to implement an iPhone scroll view like the iad scroller inside the
I want to implement a floating image that would scroll up/down when the user
Microsoft has announce that WindowsLiveID become a OpenID provider . I want implement it
I want to implement an application which will work as a parser. User will
I want to implement a fancy scroll bar for a multiline textbox like the

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.