jquery.rtl-scroll-type
v2.0.0
Published
Detect scrollLeft type under RTL language
Downloads
55
Readme
jQuery RTL Scroll Type Detector
Horizontal scrollbar with RTL(right to left) language support has different implementations in different browsers.
scrollLeft in RTL element is not defined by any spec or standards. So different browsers have different implementations. As far as I know, there are three implements: Chrome(Blink), Firefox/Safari, IE.
Chrome's RTL scrollbar is the same as LTR(left to right) element. Except for the initial position of the scrollbar controller is at the most right position.
Firefox has a clear definition in its MDN document. The most right position stands for 0. And when the user scrolls to the left. The value decreases. The value is possible to be negative in this implement.
IE thought the element is flip horizontal. So the most right position is 0. And if it scrolls to the left. Value increases.
A table is below to show these types more clear.
This plugin is designed to detect which type is the browser is using. Assign the result to jQuery's support object named rtlScrollType. You will need the scrollWidth of the element to transform between these three types of value.
3 Types of scrollLeft (scrollWidth = 100)
Usage
See demo.
Web Standard
It's defined in CSSOM View Module. The negative type is the chosen one. Chrome has a plan to change its behavior. More information is at #6.
License
Copyright (c) 2012 Wei-Ko Kao
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.