Re: Coordinates in SVG that embedded with scrolling
Svami Dhyan Nataraj <[email protected]> Mon, 7 Dec 2009 22:37:51 +0300
| Newsgroups | gmane.comp.mozilla.devel.svg |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 07 Dec 2009 09:06:12 +0100 Holger Jeromin <[email protected]> wrote: > 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; > } Thanks! You've made my live happier... BTW. I did not find pageX in SVG spec... It is mozilla specific implementation, or what? Is it described somewhere?