...

View Full Version : Mouse wheels and Mozilla



mohith_j
06-04-2004, 10:05 PM
I was curious if anyone knows if there is a way to detect if the mouse wheel is being used to scroll a div. Neither onscroll or IE's onmousewheel get fired. I can't seem to find any event that gets fired, yet Mozilla still scrolls the div (the reason I need to detect this is because I have custom scrolling logic that I need to run).

In the following sample code, I add <a> tags to my divs so that the divs can grab focus and respond to key events. This also has the sideeffect that mouse wheel scrolling is enabled.


<html>
<body>

<div id="parent" style="overflow: auto; width: 100px; height: 400px; border: 1px solid blue;"></div>

<script>

var colors = [ "red", "green", "yellow" ];

var p = document.getElementById("parent");

for (var i = 0; i < 100; i++) {
var d = document.createElement("div");
var a = document.createElement("a");
a.href = "#";
a.appendChild(document.createTextNode(colors[i % colors.length]));
d.appendChild(a);
d.style.width = "75px";
d.style.height = "30px";
d.style.backgroundColor = colors[i % colors.length];
p.appendChild(d);
}

</script>
</body>
</html>

fredmv
06-07-2004, 03:28 AM
yet Mozilla still scrolls the divYou sure? Last I checked Mozilla nor IE respond to the scrollwheel being used inside a block element with overflow: auto defined.

liorean
06-07-2004, 03:46 AM
You sure? Last I checked Mozilla nor IE respond to the scrollwheel being used inside a block element with overflow: auto defined.It does in these very forums. As soon as the mouse pointer is above a vertically scrollable element, the scroll wheel will scroll that element and not the document. Test it yourself, if you wish.

(There might be a difference between Logitech, Microsoft and other mice, though, as well as a difference based on what extensions are installed. Logitech are generally recognised as having the best drivers for their mice, and have the best support from the application side.)

fredmv
06-07-2004, 03:56 AM
It does in these very forums. As soon as the mouse pointer is above a vertically scrollable element, the scroll wheel will scroll that element and not the document. Test it yourself, if you wish.
Wait a second. Are you referring to textareas? If so what you said is indeed true. However, it doesn't appear to work for something like this (which is what I was referring to above):
<div style="overflow: auto; height: 100px; width: 450px;">
foo<br /> foo<br />
foo<br /> foo<br />
foo<br /> foo<br />
foo<br /> foo<br />
foo<br /> foo<br />
foo<br /> foo<br />
foo<br /> foo<br />
foo<br /> foo<br />
</div>

liorean
06-07-2004, 04:02 AM
No, not textareas. If you have a look at the code behind the [​code][​/code] you'll find it looks like this:
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="border: 1px inset ; margin: 0px; padding: 6px; width: 640px; height: 498px; overflow: auto;">
</pre>
</div>These are not textareas, but block level elements with overflow: auto;. They scroll using the scrollwheel, though.

fredmv
06-07-2004, 04:07 AM
Oh, yes; I knew those weren't textareas. I was referring to the textarea used to post a new reply, of which does indeed exhibit the behavior you described. Though in both the example used here and the example I provided, the element does not appear to respond to scroll events. In fact, Opera 7.51 seems to be the only browser that it worked correctly in.

liorean
06-07-2004, 04:14 AM
Well, then it's probably a miss in their implementations, not triggering the scroll event when the element is scrolled. However, at least for me, ALL vertically scrollable elements that I focus are scrolled when I use my mouse wheel in moz (both moz1.7b2 without any extensions and ff.8 with lots of extensions).

Arielladog
06-07-2004, 09:28 PM
Hey mo, et all,

The problem seems to be on Mozilla's side, and there's a bug complaint here:

http://bugzilla.mozilla.org/show_bug.cgi?id=97283

They have a lot of activity about it, but doens't seem like any solution or a planned solution in action. It's annoying and hopefully it'll be stamped out. They do have a workaround posted, but again it doesn't work too well.

~Ryan (aDog :cool: )

liorean
06-07-2004, 10:13 PM
Strangely, all the testcases from that bug report worked as they should for me...

Arielladog
06-08-2004, 01:31 AM
Hmm, do you know why? Could it be an extension you added?

I've tried with Firefox .8 and Mozilla 1.6

liorean
06-08-2004, 11:01 AM
SuperScroll and Smoothwheel extensions may have something to do with it in ff. Moz1.8a1 with a new profile didn't work. Moz1.7b2 works without any extensions, but I used an old profile, so it may be a remnant from that.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum