Click to See Complete Forum and Search --> : ½ math, ½ javascript question


Sam
10-01-2003, 04:01 PM
As the title sugests, I've got a bit of a question. I've got a img who's dimmensions are equal to document.body.clientHeight by document.body.clientWidth
My problem is this... I i'm trying to write a click&zoom script. (when a user clicks, the picture is enlarged by 20%. This part isn't very hard, I just multiply the height and width of the image by 1.2 (The image is in a div with overflow hidden, so it always fits in exactly one page...)
My question is this...
How can I make it so the point clicked is in the center of the picture in the enlarged screen...This really doesn't seem to pose a problem as far as the coding, but I haven't been able to figure it out mathematically

Khalid Ali
10-01-2003, 05:45 PM
you never emntioned that the point you click on is a button or image map?,
if its a button then you will need to get cleintWisth height divide it with 2,
I am usre thats not it, if describe it a bit more as well as answer the question I above ,it might be a bit easier to visualize your problem

Sam
10-01-2003, 05:59 PM
ah, sorry...
Since the picture is taking the whole screen, I have the script loggin the x&y onclick, this picture will change size dynamically, so the whole window is a picture, and if you click anywhere on that picture i would like to enlarge by 1.2, then center on the point clicked (which is stored in mX and mY)

Sam
10-02-2003, 10:46 AM
So... the img is within a div which I move the image around with, and that div is within another div that stays stationary at (0,0) The img div would need to be moved to negative postions in order for this to work

Sam
10-02-2003, 03:21 PM
Here is the temporary location of the page, if that will help at all
http://www.medford.k12.or.us/sample/

Sam
10-02-2003, 06:39 PM
I got it going... final formula for it was:
pixelLeft of the div was equal to the x distance between the location clicked on the image relative to the top left of the image subtracted from the center x value of the screen, same sort of thing for the y cord