Simple image pan

J

jim_adams

From a web page, I'd like to show a jpg/gif image that is larger than
its frame, and allow a user to pan around by mouse. It shouldn't allow
the user to move the frame view out of the image boundaries.

I've Googled for a while on this one, but nothing comes up that's
simple and polished.

Thanks for any pointers.

Jim
 
M

McKirahan

its frame, and allow a user to pan around by mouse. It shouldn't allow
the user to move the frame view out of the image boundaries.

I've Googled for a while on this one, but nothing comes up that's
simple and polished.

Thanks for any pointers.

Jim

Will this do? Watch for word-wrap.

<html>
<head>
<title>mapScroll.htm</title>
<body>
<p align="center">
<b>Scroll to view the map.</b><br><br>
<iframe
src="http://freepages.genealogy.rootsweb.com/~monticue/photogallery/photo203
08/colorado_map.jpg"
width="580" height="300" marginheight="0" marginwidth="0" align="center"
frameborder="0"></iframe>
</p>
</body>
</html>
 
E

Evertjan.

wrote on 02 sep 2005 in comp.lang.javascript:
its frame, and allow a user to pan around by mouse. It shouldn't allow
the user to move the frame view out of the image boundaries.

I've Googled for a while on this one, but nothing comes up that's
simple and polished.

IE only, I think, try this first without framing:

<body onmousemove='window.scrollTo(x=event.x*4-500,
y=event.y*3-200);status=x+","+y'>
<img src='myPicture.gif'
style='width:300%;'
onclick='this.style.width=(this.style.width=="300%")?"100%":"300%"'
alt='Click me to enlarge and to move by moving the mouse'
 
J

jim_adams

Hi Evertjan,

Since it's for a general website, I'd like it to support IE and Firefox
at minimum. In your example, the zoom in/out works great, but the
scroll doesn't seem to do its job, even in IE. Also, it brings up a
warning about unsafe code in IE.

I thought this would be an easy one but somehow it isn't.

Just to recap, I'd like to show images at their native resolution
(screen captures), but allow the user to move them around with a mouse
in a view port (maybe an iFrame), similar to the way Google Earth does
it (click and drag around). For asthetic reasons, I don't want the
image boundaries to be movable across the viewport, just stop at the
images edges accordingly.

Thanks,

Jim
 
J

Jim Ley

Close, but it allows the image to be scrolled outside of its margins.

Which is trivial to stop, just add some drag checking to see if it's
outside the bounds... it's another 4 lines of code at most...

Cheers,

Jim.
 
E

Evertjan.

wrote on 06 sep 2005 in comp.lang.javascript:
[please do not toppost on usenet, jim]
Since it's for a general website, I'd like it to support IE and
Firefox at minimum. In your example, the zoom in/out works great, but
the scroll doesn't seem to do its job, even in IE.

You will have to correct the numbers according to the actual hight/width
ratio. I suggest to do this by trial and error.
Also, it brings up
a warning about unsafe code in IE.

Not on my IE6
I thought this would be an easy one but somehow it isn't.

Just to recap, I'd like to show images at their native resolution
(screen captures), but allow the user to move them around with a mouse
in a view port (maybe an iFrame),

Use a said:
similar to the way Google Earth does
it (click and drag around). For asthetic reasons, I don't want the
image boundaries to be movable across the viewport, just stop at the
images edges accordingly.

My code was only a code I use for a simple IE6 only application.

Feel free to use it as a staring point. I am sure your requirements can
be met, however to make thelm cross browser compatible needs a lot of
knowledge and testing.
 
J

jim_adams

Hi Jim,

As my Javascript knowledge is quite limited, would you mind taking a
crack at these 4 lines?

Thanks,

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top