Ticket #8951 (closed enhancement: patchwelcome)
jQuery could handle firefox bug 383026 with .scrollLeft()
| Reported by: | arieleo | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.7 |
| Component: | offset | Version: | 1.5.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description (last modified by rwaldron) (diff)
Hi, This is a suggestion to handle a bug in Firefox (383026) rather than an actual jQuery bug.
Using jQuery .scrollLeft() on an element with a direction of RTL will return negative values in Firefox.
Although this is caused by a bug in Firefox and not in jQuery, given that jQuery is very useful in unifying browsers behaviour for the JavaScript programmer, maybe it should also unify this behavior across browsers.
For example, one need only to set an element's opacity with jQuery and forget it. jQuery will deal with the different opacity techniques for the different browsers.
Therefore, my suggestion is to add to jQuery's .scrollLeft the ability to take into consideration the rendering engine and to return a unified positive value, instead of Firefox's negative one.
Documentation for the Firefox bug is located here: https://bugzilla.mozilla.org/show_bug.cgi?id=383026
Your review of this suggestion is appreciated. Ariel
Change History
comment:1 follow-up: ↓ 2 Changed 2 years ago by timmywil
- Owner set to arieleo
- Priority changed from undecided to low
- Status changed from new to pending
- Component changed from unfiled to offset
comment:2 in reply to: ↑ 1 Changed 2 years ago by arieleo
- Status changed from pending to new
Thanks for checking! To reproduce it just play with the scrollbars, as they all read out '0' when in their initial location. You can use this change I made to the jsFiddle code: http://jsfiddle.net/F2sh8/7/
One more difference in behavior between browsers I now spotted, is that the initial value of '0' is also something specific to Firefox (I have Firefox 4). Other browsers will read out the scroll distance from the left, no matter the direction.
In this case Firefox is much more sensible, for cases when you want to localize a website by converting the CSS from LTR to RTL while not making any changes to the JavaScripts.
For that matter, perhaps it's worth leaving .scrollLeft() along, and creating a new jQuery function called .scrollDistanceHorizontal() or something along this line, that will represent the scroll distance from the initial scrollbar location, no matter the direction.
This way, given an example situation where I have an LTR site with a slider script that scrolls a div from right to left by increasing the scroll distance, I would not have to make any changes to the script if I localize the site to RTL languages.
This could be nice. Thanks again!
comment:3 Changed 2 years ago by timmywil
- Owner changed from arieleo to timmywil
- Status changed from new to assigned
comment:4 Changed 2 years ago by john
- Keywords 1.7-discuss added
Nominating ticket for 1.7 discussion.
comment:6 Changed 2 years ago by jaubourg
+1, seeing how "quick" Mozilla is to fix this, we might consider it.
comment:8 Changed 2 years ago by dmethvin
- Description modified (diff)
+0, Do we have a feature detect for this?
comment:9 Changed 2 years ago by timmywil
- Owner timmywil deleted
- Status changed from assigned to open
comment:10 Changed 2 years ago by john
- Description modified (diff)
+0, Very low priority, let's land only if there's a patch with unit tests.
comment:12 Changed 2 years ago by scott.gonzalez
- Description modified (diff)
+0, I'm in favor of fixing this bug, but I don't think this belongs specifically on the 1.7 roadmap
comment:13 Changed 2 years ago by rwaldron
- Keywords 1.7-discuss removed
- Status changed from open to closed
- Resolution set to patchwelcome
- Description modified (diff)
- Milestone changed from 1.next to 1.7
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Thanks for taking the time to contribute to the jQuery project!
I went ahead and made a test case and I couldn't reproduce the issue experienced: http://jsfiddle.net/timmywil/F2sh8/3/ (checked in Firefox 3.6 and Firefox 4). Perhaps you could update mine or create a test case on http://jsfiddle.net, or let us know which version of Firefox has the issue.