Javascript zooming

J

Jon

Hello all.

I have implemented a simple javascript zoom function, however, as I
zoom in (by 10%) each time, I want to zoom in at the point if the
mouse cursor, much like google maps. Does anyone know of a script?

Regards,

Jon
 
J

Jon

Hello all.

I have implemented a simple javascript zoom function, however, as I
zoom in (by 10%) each time, I want to zoom in at the point if the
mouse cursor, much like google maps. Does anyone know of a script?

Regards,

Jon

Here is an example in flash, http://blog.organa.ca/?p=16, I'd like to
do this in Javascript.

Regards,

Jon
 
G

Gregor Kofler

Jon meinte:
Hello all.

I have implemented a simple javascript zoom function, however, as I
zoom in (by 10%) each time, I want to zoom in at the point if the
mouse cursor, much like google maps. Does anyone know of a script?

Where's the problem? Get your mouse position, enlarge your element, set
top and left position or - depending on your markup - the according
scrollTop/scrollLeft values. What would be the benefit of a third party
script in this case?

Gregor
 
J

Jon

Jon meinte:



Where's the problem? Get your mouse position, enlarge your element, set
top and left position or - depending on your markup - the according
scrollTop/scrollLeft values. What would be the benefit of a third party
script in this case?

Gregor

--http://www.gregorkofler.com

Gregor,

The element is enlarged by .zoom, so when you enlarge, it's enlarges
from the top left. It's easy to get the mouse position, but how do you
work out what to set the top and left of the element too?

If you have any examples it would be appreciated.

Jon
 
G

Gregor Kofler

Jon meinte:
The element is enlarged by .zoom, so when you enlarge, it's enlarges
from the top left. It's easy to get the mouse position, but how do you
work out what to set the top and left of the element too?

Iterate through the elements offsetParent elements until the parent
element yields null. Add up offsetTop and offsetLeft while iterating.

In my core.js[1] vxJS.dom.getElementOffset() does this.

Gregor


[1]
http://vxjs.gregorkofler.com/js/core.js
 
J

Jon

Jon meinte:
The element is enlarged by .zoom, so when you enlarge, it's enlarges
from the top left. It's easy to get the mouse position, but how do you
work out what to set the top and left of the element too?

Iterate through the elements offsetParent elements until the parent
element yields null. Add up offsetTop and offsetLeft while iterating.

In my core.js[1] vxJS.dom.getElementOffset() does this.

Gregor

[1]http://vxjs.gregorkofler.com/js/core.js

--http://www.gregorkofler.com

Thank you for this,

but offsetParent and offsetTop will always be 0 and 0 as the element
(image) grows from the bottom and right.

Jon
 
T

Thomas 'PointedEars' Lahn

What is .zoom?
It's easy to get the mouse position, but how do you
work out what to set the top and left of the element too?

In my core.js[1] vxJS.dom.getElementOffset() does this.
[...]

Thank you for this,

but offsetParent and offsetTop will always be 0 and 0 as the element
(image) grows from the bottom and right.

You've lost me here. What does the former have to do with the latter?

Please trim your quoted as seen here and described in the FAQ.
 
T

Thomas 'PointedEars' Lahn

Gregor said:
Jon meinte:
[...] It's easy to get the mouse position, but how do you
work out what to set the top and left of the element too?

Iterate through the elements offsetParent elements until the parent
element yields null. Add up offsetTop and offsetLeft while iterating.

In my core.js[1] vxJS.dom.getElementOffset() does this.

I can't be sure, I haven't looked at your code yet, but haven't we
established here that this is error-prone?
 
G

Gregor Kofler

Thomas 'PointedEars' Lahn meinte:
Gregor said:
Jon meinte:
[...] It's easy to get the mouse position, but how do you
work out what to set the top and left of the element too?
Iterate through the elements offsetParent elements until the parent
element yields null. Add up offsetTop and offsetLeft while iterating.

In my core.js[1] vxJS.dom.getElementOffset() does this.

I can't be sure, I haven't looked at your code yet, but haven't we
established here that this is error-prone?

Erm... was it? I have to look up the discussion. Could be. Anyway, since
the routine is short, it should suffice to convey the "idea".

Gregor
 
J

Jon

Thomas 'PointedEars' Lahn meinte:
Gregor said:
Jon meinte:
[...] It's easy to get the mouse position, but how do you
work out what to set the top and left of the element too?
Iterate through the elements offsetParent elements until the parent
element yields null. Add up offsetTop and offsetLeft while iterating.
In my core.js[1] vxJS.dom.getElementOffset() does this.
I can't be sure, I haven't looked at your code yet, but haven't we
established here that this is error-prone?

Erm... was it? I have to look up the discussion. Could be. Anyway, since
the routine is short, it should suffice to convey the "idea".

Gregor

--http://www.gregorkofler.com

Problem solved. Thanks to everyone for their help.
 
T

Thomas 'PointedEars' Lahn

Jon said:
Gregor said:
Thomas 'PointedEars' Lahn meinte:
Gregor Kofler wrote:
Jon meinte:
[...] It's easy to get the mouse position, but how do you
work out what to set the top and left of the element too?
Iterate through the elements offsetParent elements until the parent
element yields null. Add up offsetTop and offsetLeft while iterating.
In my core.js[1] vxJS.dom.getElementOffset() does this.
I can't be sure, I haven't looked at your code yet, but haven't we
established here that this is error-prone?

Erm... was it? I have to look up the discussion. Could be. Anyway, since
the routine is short, it should suffice to convey the "idea".
[snip sig]

Problem solved. Thanks to everyone for their help.

So you are neither going to adhere to the FAQ recommendations, nor answer
pending questions, nor give any feedback on your solution? That is not how
Usenet works, and chances are if that is your last word then it was the last
time anyone knowledgable replied to one of your postings.


PointedEars
 

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

No members online now.

Forum statistics

Threads
474,084
Messages
2,570,596
Members
47,217
Latest member
GuadalupeE

Latest Threads

Top