large image scroll effect
Hey all,
I'm a graphic designer with some experience in Actionscript/HTML/CSS. I'm now trying my hand on jQuery.
My goal is to achieve an effect to scroll a large image, something like this Flash example:
(click on 'Zoom In')
Below my result so far. It kind of works but nowhere near as smooth as i want it to be. Frankly my programming skills are insufficient to take it to a next level.
Anyone ideas, tips or seen this effect elsewhere?
- <html lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>slide scroll</title>
- <script src="jquery-1.5.1.min.js" type="text/javascript" charset="utf-8"></script>
-
- <script type="text/javascript">
- $(function(){
- $(document).mousemove(function(e) {
-
- var xPercentage = (e.pageX)/$(window).width();
- var yPercentage = (e.pageY)/$(window).height();
-
- var xPos = Math.round(($(window).width()-$('#photo').width())*xPercentage);
- var yPos = Math.round(($(window).height()-$('#photo').height())*yPercentage);
-
- $('#photo').stop().animate({'top':yPos, 'left':xPos})
-
- });
- });
- </script>
-
- <style>
- html{
- overflow:hidden;
- }
- #photo{
- position:relative;
- width:1000px;
- height:1300px;
- background:#999;
- border:5px dotted black;
- }
- </style>
- </head>
- <body>
- <div id="photo"></div>
- </body>
- </html>