large image scroll effect

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? 

  1. <html lang="en">
  2. <head>

  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  4. <title>slide scroll</title>

  5. <script src="jquery-1.5.1.min.js" type="text/javascript" charset="utf-8"></script>
  6. <script type="text/javascript">
  7. $(function(){
  8. $(document).mousemove(function(e) {
  9. var xPercentage = (e.pageX)/$(window).width();
  10. var yPercentage = (e.pageY)/$(window).height();
  11. var xPos = Math.round(($(window).width()-$('#photo').width())*xPercentage);
  12. var yPos = Math.round(($(window).height()-$('#photo').height())*yPercentage);
  13. $('#photo').stop().animate({'top':yPos, 'left':xPos})
  14. });
  15. });
  16. </script>
  17. <style>
  18. html{
  19. overflow:hidden;
  20. }

  21. #photo{
  22. position:relative;
  23. width:1000px;
  24. height:1300px;
  25. background:#999;
  26. border:5px dotted black;
  27. }
  28. </style>

  29. </head>
  30. <body>
  31. <div id="photo"></div>
  32. </body>
  33. </html>