Closed
Bug 310387
Opened 19 years ago
Closed 19 years ago
with smooth scrolling on, scrollTop is inaccurate from onscroll event listener
Categories
(Core :: DOM: Events, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 189308
People
(Reporter: mohith, Unassigned)
Details
Attachments
(1 file)
655 bytes,
text/html
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7
Suppose you have a scrollable element to which you've attached an "onscroll"
event listener. With smooth scrolling off, querying the "scrollTop" property of
the element from within the "onscroll" listener returns the value *after* the
element has been scrolled. With smooth scrolling on, querying the "scrollTop"
property of the element from within the "onscroll" listener returns the value
*before* the element has been scrolled. No subsequent "onscroll" event is fired
with the correct value.
This problem occurs in Firefox. See the "Steps to Reproduce" for a detailed
example.
With smooth scrolling off, the "scrollTop" property of a scrolled element will
return the scrollTop *AFTER* the scroll
Reproducible: Always
Steps to Reproduce:
1. Create an HTML file with the following source:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html><head>
<style type="text/css">
#a { position: absolute; border: 1px solid black; top: 50px; left: 150px; width:
100px; height: 300px; overflow: auto; }
#b { position: absolute; width: 1px; height: 1000px; }
</style>
<script>
function attachListeners() {
var a = document.getElementById("a");
a.onscroll = function() {
var div = document.createElement("div");
div.appendChild(document.createTextNode("scrollTop: " + a.scrollTop));
document.body.appendChild(div);
}
}
</script>
</head>
<body onload="attachListeners()">
<div id="a"><div id="b"></div></div></body></html>
2. Run Firefox with the "smooth scrolling" option turned off.
3. Click the down scroll button 3 times and then the up scroll button 3 times.
You should see the following output:
scrollTop: 19
scrollTop: 38
scrollTop: 57
scrollTop: 38
scrollTop: 19
scrollTop: 0
4. Run Firefox with the "smooth scrolling" option turned on.
5. Click the down scroll button 3 times and then the up scroll button 3 times.
You should see the following output:
scrollTop: 0
scrollTop: 19
scrollTop: 38
scrollTop: 57
scrollTop: 38
scrollTop: 19
6. Note the inconsistency
Actual Results:
There is an inconsistency in the values "scrollTop" reports, depending on
whether smooth scrolling is on or off.
This bug causes problems for DHTML applications that rely on "onscroll" events
to implement custom scrolling. Fortunately, smooth scrolling is turned off by
default.
Comment 2•19 years ago
|
||
This is WFM with current trunk build.
Reporter, please retest with the latest nightly trunk build, or with
Firefox1.5beta2.
![]() |
||
Comment 3•19 years ago
|
||
Bug 189308 fixed this.
*** This bug has been marked as a duplicate of 189308 ***
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•