You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know this is four years too late, but it may help someone!
jQuery.fn.scrollLeftOriginal = jQuery.fn.scrollLeft;
jQuery.fn.scrollLeft = function(val) {
if (getComputedStyle(this[0]).direction === 'rtl') {
val = Math.abs(val);
if (jQuery.support.rtlScrollType==='negative') val = 0 - val;
else if (jQuery.support.rtlScrollType==='positive') val = (this[0].scrollWidth - this[0].clientWidth) - val;
}
this.scrollLeftOriginal( val );
};
This will replace jQuery's built-in scrollLeft function with one that takes RTL into account. You call it like so:
$(element).scrollLeft(value);
Zero means the element is scrolled all the way to the right (as at first load). The 'value' parameter can be positive or negative, and will scroll the element to that position. (Note it scrolls it TO the position, not BY the amount specified.)
It checks whether the element is RTL, and just calls the normal jQuery scrollLeft() function if not, so it should be safe to drop in.
Hi, I am using scrollTo plugin which have this exact problem on rtl containers.
I was wondering if any of you have some kind of a function that knows to calculate the reverse scroll from a regular one.
Thanks
The text was updated successfully, but these errors were encountered: