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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:23:23+00:00 2026-06-17T07:23:23+00:00

I have posted my problem at http://jsfiddle.net/ugnf4/ as it would be make it easier.

  • 0

I have posted my problem at http://jsfiddle.net/ugnf4/ as it would be make it easier.

Below is my html / javascript code

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div id="mainContainer">
<div id="pageContainer" style="background: #cdcdcd;"></div>
</div>
<style>
    BODY {
        margin: 0px;
        padding: 0px;
    }
    #pageContainer {
        position: relative;
        margin: 10px auto;
        -webkit-transform-origin:50% 20%;
        -webkit-transform:scale(1.37);
        width: 1218px;
        height: 774px;
        border: 1px solid #000000;
    }
    #mainContainer {
        width: 100%;
        overflow: hidden;
    }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</script>

<script type="text/javascript">

$(document).ready(function() {
    setHeight();

    $(window).resize(setHeight);
});


function setHeight()
{
    $('#mainContainer').css({'height': $(window).height()});
}

$('#mainContainer').mousemove(function (e) {

});

</script>

</body>
</html>

Currently #mainContainer div has overflow hidden as i dont want to show scroll bars and #pageContainer div (inner div) is scaled at 1.37 using css3, as in certain cases based on screen / browser width height #pageContainer's content would be hidden because of overflow hidden.

I want to code javascript so that if somebody moves cursor in #mainContainer, based on position of mouse X and Y co-ordinates I would like to move #pageContainer so that similar position of #pageContainer would be visible (I hope it is clear).

I m having problem as I m using -webkit-transform-origin, unable to understand how to move #pageContainer around with respect to mouse co-ordinates of #mainContainer.

UPDATE:

I m looking something like what happens in issuu.com website when you open an ebook and zoom it more than the browser size (Should make it more clear)

I m looking for algo or pointer how to achieve it (how to calculate it) not necessarily a working script.

How can this be achieved.

Below is working html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div id="mainContainer">
<div id="pageContainer" >
<div id="pageContainerInner"style="background: #cdcdcd;">
</div>
</div>
<style>
    BODY {
        margin: 0px;
        padding: 0px;
    }
    #pageContainer {
        margin: 10px auto;
        -webkit-transform-origin:50% 20%;
        -webkit-transform:scale(1.37);
        width: 1218px;
        height: 774px;
    }
    #mainContainer {
        width: 100%;
        overflow: hidden;
    }

    #pageContainerInner {
        position: relative;
        width: 1218px;
        height: 774px;
        border: 1px solid #000000;
        top: 0;
        left: 0;
    }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</script>

<script type="text/javascript">

var pageWidth = 1220;
var pageHeight = 776;

var scale = 1.37;

var scaledDelta = 5; //Percentage mouse position approximation

$(document).ready(function() {
    setHeight();

    $(window).resize(setHeight);
});


function setHeight()
{
    $('#mainContainer').css({'height': $(window).height()});
}

$('#mainContainer').mousemove(function (e) {

    // Calculate the offset of scaled Div
    var offsetX = $('#pageContainer').offset().left;
    var offsetY = $('#pageContainer').offset().top;

    // Calculate div origin with respect to screen
    var originX = (-1 * offsetX) / scale;
    var originY = (-1 * offsetY) / scale;

    var wWdt = $(window).width();
    var wHgt = $(window).height();

    // Now convert screen positions to percentage
    var perX = e.pageX * 100 / wWdt;
    var perY = e.pageY * 100 / wHgt;

    // Div content which should be visible
    var pageX = perX * pageWidth / 100;
    var pageY = perY * pageHeight / 100;

    // Calculate scaled divs new X, Y offset
    var shiftX =  (originX - pageX) + (e.pageX / scale);
    var shiftY = (originY - pageY) + (e.pageY / scale);

    $('#pageContainerInner').css({'left': shiftX+'px', 'top': shiftY+'px'});
});

</script>

</body>
</html>

Hope this will help others.

  • 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-17T07:23:24+00:00Added an answer on June 17, 2026 at 7:23 am

    I have posted a probable solution at http://jsfiddle.net/PYP8c/.

    Below are the modified styles for your page.

    BODY {
            margin: 0px;
            padding: 0px;
        }
    
    #mainContainer {
            width: 100%;
            overflow: hidden;
      position: relative;
            margin: 10px auto;
            -webkit-transform-origin:50% 20%;
            -webkit-transform:scale(1.37);
            width: 1218px;
            height: 774px;
            border: 1px solid #000000;
        }
        #pageContainer {
            position:absolute;
        top:0px;
        }
    

    This is the javascript code for the same.

    $(document).ready(function() {
        //setHeight();
    
        //$(window).resize(setHeight);
    });
    
    
    function setHeight()
    {
        $('#mainContainer').css({'height': $(window).height()});
    }
    
    $('#mainContainer').mousemove(function (e) {
      var contentHeight = $("#pageContainer").height();
      var minTop = 774 - contentHeight;
      if(minTop>0)
          minTop = 0;
        var currTop = ((e.pageY-10)/774.0)*(minTop);
      document.getElementById("pageContainer").style.top = currTop+'px';
    });
    

    Its just a demo on how you could get the text to move based on the mouse coordinates.

    You could make a lot of changes, like adding a scrollbar that fades which gives the user a feedback about how much content is still available in both the vertical directions.

    Also I have used hard coded values for height, but in your final version I would recommend you get the height of the mainContainer division dynamically.

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

Sidebar

Related Questions

I have sample code for question here: http://jsfiddle.net/MuydK/ The problem relates to legend title
I have the following code working: http://jsfiddle.net/SzW7q/ Admins will be able to go in
ASP.NET 4.0 Need some help with this vexing HTTP POST problem - I have
Originally posted on: http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_21355401.html I have a solution containing two projects: a webservice project
This sounds like a problem many others have posted about, but there's a nuance
We have a problem in a specific server. All plus signs posted to the
I have a RichTextBox which contains links posted by the users. The problem is
Following on from a question I posted yesterday about GUIs, I have another problem
I have posted an example below and the desired result . I saw a
I have posted my class below and with sample data. I need to pass

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.