Re: Coordinates in SVG that embedded with scrolling
Holger Jeromin <[email protected]> Mon, 07 Dec 2009 09:06:12 +0100
| Newsgroups | gmane.comp.mozilla.devel.svg |
|---|---|
| Message-ID | <[email protected]> |
Svami Dhyan Nataraj schrieb am 05.12.2009 16:08:
> I have problems with getting coordinates of mouse when I embedded SVG
> into view port with scrollbars...
>
> If you try an example from attached file (an html one), you will be able
> to drag-n-drop blue circle while you did not scroll view port. But if
> you scroll viewport to see green ball, you will not be able to drag it.
>
> clientX and clientY are given as if the image were not scrolled at all,
> and the circle immediately moves to the top of the image...
>
> It seems to me that I should add dx and dy of scrollbars, to get real
> coordinates. But I do not know where to get them.
>
> Can you please help me with this sample?
pageX is relative to the top of page, regardless of the browser scrolling.
Beware that the AdobeSVG Viewer Pluginarea is not "informed" by the
scrolling, so there clientx is not changed.
var mousePosX;
var mousePosY;
if (evt.pageX || evt.pageY) {
//code for native SVG. pageX based on the full XHTML Document
mousePosX = evt.pageX;
mousePosY = evt.pageY;
}else{
//code for plugin. clientX is based on the Plugin area, without browser
scrolling sideeffects
mousePosX = evt.clientX;
mousePosY = evt.clientY;
}
--
best regards
Holger