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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:49:43+00:00 2026-06-06T06:49:43+00:00

Actually I’m looking for a jQuery plug-in that can handle this: there is a

  • 0

Actually I’m looking for a jQuery plug-in that can handle this:

  • there is a container with overflow hidden
  • inside of this is another one, which is way larger
  • when i move over the div, the part I’m seeing depends on my current position
    • when I’m in the left top corner I see the top left corner of the inner container
    • when I’m in the middle i see the middle of the container …

I wrote a little JavaScript that does that:

this.zoom.mousemove( function(event) {

    var parentOffset    = $(this).parent().offset(); 
    var relativeX       = event.pageX - parentOffset.left;
    var relativeY       = event.pageY - parentOffset.top;

    var differenceX     = that.zoom.width() - that.pageWidth;
    var differenceY     = that.zoom.height() - that.pageHeight;

    var percentX        = relativeX / that.pageWidth;
    var percentY        = relativeY / that.pageHeight;

    if (1 < percentX) {
        percentX        = 1;
    }
    if (1 < percentY) {
        percentY        = 1;
    }

    var left            = percentX * differenceX;
    var top             = percentY * differenceY;

    that.zoom.css('left', -left).css('top', -top);

});

But this isn’t very smooth and kinda jumpy, when you enter from another point of the container. So, before reinventing the wheel: Is there one plug in, that does exactly that and has iOS support (drag instead of mouse move)? All zoom plug ins (like Cloud Zoom) are over the top for this purpose and most have no support for dragging on iOS.

And if there’s not something like this. How can I make this smoother and cooler. Any approach would be helpful. 🙂

Many thanks.

  • 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-06T06:49:46+00:00Added an answer on June 6, 2026 at 6:49 am

    So, here is my solution – which works pretty well and is easy to achieve. There could be done some improvement, but to get the idea i’ll leave it that way. 🙂

    there is a demo on jsfiddle:

    http://jsfiddle.net/insertusernamehere/78TJc/

    CSS

    <style>
        div.zoom_wrapper {
            position:   relative;
            overflow:   hidden;
            width:      500px;
            height:     500px;
            border:     1px solid #ccc;
            cursor:     crosshair;
        }
        div.zoom_wrapper > * {
            position:   absolute;
        }
    </style>
    

    HTML

    <div class="zoom_wrapper">
        <img id="zoom" src="http://lorempixel.com/output/people-q-c-1020-797-9.jpg" alt="">
    </div>
    

    JAVASCRPT

    <script>
    
        var zoom        = null;
    
        // this function will work even if the content has changed
        function move() {
    
        // get current position
        var currentPosition = zoom.position();
        var currentX        = currentPosition.left;
        var currentY        = currentPosition.top;
    
        // get container size
        var tempWidth       = zoom.parent().width();
        var tempHeight      = zoom.parent().height();
    
        // get overflow
        var differenceX     = zoom.width() - tempWidth;
        var differenceY     = zoom.height() - tempHeight;
    
        // get percentage multiplied by difference (in pixel) cut by percentage (here 1/4) that is used as "smoothness factor"
        var tempX           = zoom.data('x') / tempWidth * differenceX / 4;
        var tempY           = zoom.data('y') / tempHeight * differenceY / 4;
    
        // get real top and left values to move to and the last factor slows it down and gives the smoothness (and it's corresponding with the calculation before)
        var left            = (tempX - currentX) / 1.25;
        var top             = (tempY - currentY) / 1.25;
    
        // finally apply the new values
        zoom.css('left', -left).css('top', -top);   
    
    }
    
    $(document).ready(function () {
    
        zoom    = $('#zoom');
    
        //handle mousemove to zoom layer - this also works if it is not located at the top left of the page
        zoom.mousemove( function(event) {
            var parentOffset    = $(this).parent().offset(); 
            zoom.data('x', event.pageX - parentOffset.left);
            zoom.data('y', event.pageY - parentOffset.top);
        });
    
        // start the action only if user is over the container
        zoom.hover(
            function() {
                zoom.data('running', setInterval( function() { move(); }, 30) );
            },
            function() {
                clearInterval(zoom.data('running'));
            }
        );
    
    });
    
    </script>
    

    Note:
    This one has, of course, no support for touch devices. But for that I use (again)/I can recommend the good old iScroll … 🙂

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

Sidebar

Related Questions

Actually I can save it in swf and in avi formats. Is there any
actually this is not hang status, i mean..it slow response, so in that case,
Actually, I want to create an application in C such that 2 people can
Actually this is a classic problem as SO user Victor put it (in another
actually I can not find an exact title for this problem. But I can
Actually i want that, suppose i have a colorcode #FF3366. How can i examine
Actually I have two questions. (1) Is there any reduction in processing power or
Actually, almost exactly the same thing. A matrix of small views that would expand
Actually, I am facing a problem in Android. I am creating an application that
Actually this is my code: echo <pre>; // get current vars $p1 = isset($_GET['p1'])

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.