How do I remove a MouseWheel Event?

26 views
Skip to first unread message

TGurske

unread,
Jul 22, 2008, 6:04:14 PM7/22/08
to MooTools Users
I've tried window.mousewheel.removeEvents(); and other variations.
Can't figure it out. Anybody know how to do it?

horseweapon

unread,
Jul 22, 2008, 7:05:48 PM7/22/08
to MooTools Users
you can only remove events listeners that were generated with
mootools. For default event, like window's mousewheel, you can stop it
or preventDefault().

window.addEvent('mousewheel',function(event){
event.preventDefault();
});

I haven't tested it, but it should work, that's exactly like when you
prevent an anchor from redirecting when clicked

hellspawn

unread,
Jul 22, 2008, 7:43:23 PM7/22/08
to MooTools Users
i think the correct way is to do

window.addEvent('mousewheel',function(event){
event.stop();
});

this way will make preventDefault and also stopPropagation

Guillermo Rauch

unread,
Jul 22, 2008, 7:50:38 PM7/22/08
to mootool...@googlegroups.com
The propagation is not exactly what he wants to stop, but the default behavior of the browser associated to the event.
I'd go with stop() nonetheless for browser compat reasons.
--
Guillermo Rauch
http://devthought.com

TGurske

unread,
Jul 22, 2008, 9:15:04 PM7/22/08
to MooTools Users
Yeah... I can't get it to work.

Here is what I'm trying to do.
I am using the scroll bar function form here:
http://www.solutoire.com/experiments/scrollbar/index.html

The code works perfectly but when I resize the window I am using
onresize to resize all the scroll bars. So I need to kill the scroll
bar function and reinitiate it to get the new dimensions.

Here is how I was doing it:

$('fullHandle').removeEvents();
$('fullScrollBar').removeEvents();
window.mousewheel.removeEvents();
makeScrollbar( $('fullListingInside'), $('fullScrollBar'), $
('fullHandle') );

So I am just removing the events from the scroll function and then
calling the function again so it gets all the new dimensions.
Everything works great but the scroll bar part.

Any help is appreciated.

hellspawn

unread,
Jul 23, 2008, 4:44:48 AM7/23/08
to MooTools Users
in here
window.mousewheel.removeEvents();
mousewheel is the event ?

the syntax is

myElements.removeEvents([type]);


try

window.removeEvents(['mousewheel']);

TGurske

unread,
Jul 23, 2008, 1:47:56 PM7/23/08
to MooTools Users
Sorry. I mistyped when I edited the code to post it here. I had what
you wrote at one point and it didn't work. I just tried it again and
no luck either. I don't get any errors it just doesn't seem to do
anything.

The reason I need to remove the event is because I am ending up with
double events (I think) when I fire the scrollbar function again. So
once I fire ti a second time the mouse scroll gets very funky in
firefox.

hellspawn

unread,
Jul 23, 2008, 2:47:09 PM7/23/08
to MooTools Users
maybe a link would help us to help you :)

TGurske

unread,
Jul 23, 2008, 3:09:17 PM7/23/08
to MooTools Users
Cool. I uploaded it here: http://gurske.com/proofs/magazine-1/

I am making a magazine browser that adjusts everything to the size of
the screen when you resize.

Thanks!!!

TGurske

unread,
Jul 24, 2008, 2:02:45 PM7/24/08
to MooTools Users
Sorry. There was a problem with the link but it's back up now. Any
help would be appreciate! I really just need to be able to kill an
instance of that scrollbar function. Is there a command for that?

hellspawn

unread,
Jul 24, 2008, 4:11:38 PM7/24/08
to MooTools Users
i don't find a solution
maybe if u change the approach and rebuild the whole scroll panel will
help

you can extract the elements inside the scroll panel, rebuild and
reattach it
then call makeScrollBar...
Reply all
Reply to author
Forward
0 new messages