scrollLeft and bidi languages

C

ChadW

I am writing a page which displays Arabic and Hebrew (language goes
from right to left) and it is running on IE7.

On mouse events, the X coordinate is the distance from the visible
left side of the window (to the right of the vertical scrollbar) to
the mouse.

If I am to dynamically position elements however, the left style
property (element.style.left) is based off a 0 X coordinate relative
to the horizontal scrollbar being set all the way to the right
(remember, this is a RTL language... in English, the horizontal
scrollbar would normally be set all th way to the left by default). If
I was to scroll horizontally over to the left, the 0 coordinte would
be N pixels (where N > 0) over to the right of the vertical scrollbar
(which appears on the left side of the browser).

To properly calculate position, I need to know how far the user
scrolled horizontally. The problem is, the document.body.scrollLeft
property still works like a LTR language (ie, English). So, when the
page first loads and the horizontal scrollbar appears & lets me scroll
right to left, the scrollLeft property gives me an initial value of N
pixels (where N > 0). Only when I scroll all the way over to the left
side does scrollLeft give me a value of 0.

What I need to figure out is how far over did I scroll. Basically, I
need a scrollRight property.

Any ideas how I can figure this out?

scrollWidth property tells me how wide the page is in total but not
how much I can scroll right to left.

Thanks in advance,
Chad
 
D

David Mark

I am writing a page which displays Arabic and Hebrew (language goes
from right to left) and it is running on IE7.

On mouse events, the X coordinate is the distance from the visible
left side of the window (to the right of the vertical scrollbar) to
the mouse.

If I am to dynamically position elements however, the left style
property (element.style.left) is based off a 0 X coordinate relative
to the horizontal scrollbar being set all the way to the right
(remember, this is a RTL language... in English, the horizontal
scrollbar would normally be set all th way to the left by default). If
I was to scroll horizontally over to the left, the 0 coordinte would
be N pixels (where N > 0) over to the right of the vertical scrollbar
(which appears on the left side of the browser).

To properly calculate position, I need to know how far the user
scrolled horizontally. The problem is, the document.body.scrollLeft
property still works like a LTR language (ie, English). So, when the
page first loads and the horizontal scrollbar appears & lets me scroll
right to left, the scrollLeft property gives me an initial value of N
pixels (where N > 0). Only when I scroll all the way over to the left
side does scrollLeft give me a value of 0.

What I need to figure out is how far over did I scroll. Basically, I
need a scrollRight property.

Any ideas how I can figure this out?

scrollWidth property tells me how wide the page is in total but not
how much I can scroll right to left.

document.body.scrollWidth - document.body.clientWidth will tell you
that.
 
C

Chad

document.body.scrollWidth - document.body.clientWidth will tell you
that.- Hide quoted text -

- Show quoted text -

Thank you.

Under IE, the formula (document.body.scrollWidth -
document.body.clientWidth - document.body.scrollLeft) is exactly what
I needed.

Under Firefox, document.body.scrollLeft still seems to be the right
formula. IE follows the RTL rules better by putting the vertical
scrollbar on the left side of the screen and positioning the
horizontal scrollbar all the way over to the right. Firefox acts more
like LTR in terms of scrollbars.
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top