bidi.js
No description.

File Location

/goog/style/bidi.js


Public Protected Private

Global Functions

goog.style.bidi.getOffsetStart(element) number
Returns the "offsetStart" of an element, analagous to offsetLeft but normalized for right-to-left environments and various browser inconsistencies. This value returned can always be passed to setScrollOffset to scroll to an element's left edge in a left-to-right offsetParent or right edge in a right-to-left offsetParent. For example, here offsetStart is 10px in an LTR environment and 5px in RTL:
|          xxxxxxxxxx     |
 ^^^^^^^^^^   ^^^^   ^^^^^
    10px      elem    5px
If an element is positioned before the start of its offsetParent, the startOffset may be negative. This can be used with setScrollOffset to reliably scroll to an element:
var scrollOffset = goog.style.bidi.getOffsetStart(element);
goog.style.bidi.setScrollOffset(element.offsetParent, scrollOffset);
Arguments:
element : Element
The element for which we need to determine the offsetStart position.
Returns: number  The offsetStart for that element.
code »
goog.style.bidi.getScrollLeft(element) number
Returns the normalized scrollLeft position for a scrolled element.
Arguments:
element : Element
The scrolled element.
Returns: number  The number of pixels the element is scrolled. 0 indicates that the element is not scrolled at all (which, in general, is the left-most position in ltr and the right-most position in rtl).
code »
goog.style.bidi.setPosition(elemlefttopisRtl)
Sets the element's left style attribute in LTR or right style attribute in RTL. Also clears the left attribute in RTL and the right attribute in LTR.
Arguments:
elem : Element
The element to position.
left : number
The left position in LTR; will be set as right in RTL.
top : ?number
The top position. If null only the left/right is set.
isRtl : boolean
Whether we are in RTL mode.
code »
goog.style.bidi.setScrollOffset(elementoffsetStart)
Sets the element's scrollLeft attribute so it is correctly scrolled by offsetStart pixels. This takes into account whether the element is RTL and the nuances of different browsers. To scroll to the "beginning" of an element use getOffsetStart to obtain the element's offsetStart value and then pass the value to setScrollOffset.
Arguments:
element : Element
The element to set scrollLeft on.
offsetStart : number
The number of pixels to scroll the element. If this value is < 0, 0 is used.
code »

Directory style

File Reference