Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Coordinates in SVG that embedded with scrolling

60 views
Skip to first unread message

Svami Dhyan Nataraj

unread,
Dec 5, 2009, 10:08:09 AM12/5/09
to dev-te...@lists.mozilla.org

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?

problem.html

Svami Dhyan Nataraj

unread,
Dec 6, 2009, 3:00:42 AM12/6/09
to dev-te...@lists.mozilla.org

Oups, list engine have deleted attached svg file...
these files can be found here:

http://lj.shaplov.ru/2009/svg/problem.svg
http://lj.shaplov.ru/2009/svg/problem.html

Holger Jeromin

unread,
Dec 7, 2009, 3:06:12 AM12/7/09
to

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

Svami Dhyan Nataraj

unread,
Dec 7, 2009, 2:37:51 PM12/7/09
to dev-te...@lists.mozilla.org

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?

Holger Jeromin

unread,
Dec 8, 2009, 3:09:58 AM12/8/09
to
Svami Dhyan Nataraj schrieb am 07.12.2009 20:37:
> On Mon, 07 Dec 2009 09:06:12 +0100
> Holger Jeromin <news0...@katur.de> wrote:
>> Svami Dhyan Nataraj schrieb am 05.12.2009 16:08:
>>> 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...
>>> 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.
> 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?

It is available in Opera, Webkit and Mozilla.

It is described in a Working Draft:
http://www.w3.org/TR/cssom-view/

According to https://developer.mozilla.org/en/DOM/event.pageX
it is "Not part of any public standard."

--
best regards
Holger Jeromin

0 new messages