By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,519 Members | 1,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,519 IT Pros & Developers. It's quick & easy.

Simple image pan

P: n/a
>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

Sep 2 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
<ji*******@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
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


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>
Sep 2 '05 #2

P: n/a
wrote on 02 sep 2005 in comp.lang.javascript:
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.


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'

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Sep 2 '05 #3

P: n/a
On 2 Sep 2005 11:26:30 -0700, ji*******@hotmail.com wrote:
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.


There's code on http://jibbering.com/routeplanner/ which does this.

Jim.
Sep 3 '05 #4

P: n/a
Close, but it allows the image to be scrolled outside of its margins.

Jim Ley wrote:
On 2 Sep 2005 11:26:30 -0700, ji*******@hotmail.com wrote:
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.


There's code on http://jibbering.com/routeplanner/ which does this.

Jim.


Sep 6 '05 #5

P: n/a
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

Evertjan. wrote:
wrote on 02 sep 2005 in comp.lang.javascript:
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.


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'

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


Sep 6 '05 #6

P: n/a
On 6 Sep 2005 14:09:52 -0700, ji*******@hotmail.com wrote:
Jim Ley wrote:
On 2 Sep 2005 11:26:30 -0700, ji*******@hotmail.com wrote:
>>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.


There's code on http://jibbering.com/routeplanner/ which does this.


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.
Sep 7 '05 #7

P: n/a
wrote on 06 sep 2005 in comp.lang.javascript:
Evertjan. wrote:
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'
>


[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 <div> and experiment with different css like overflow and clip.
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.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Sep 7 '05 #8

P: n/a
Hi Jim,

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

Thanks,

Jim

Sep 7 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.