Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2003
    Location
    Ukraine
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Overriding onmousewheel event

    Hello

    I have a div element with it's childNodes collection filled with span elements,
    div has style.overflow set to auto. I want it to work like a select/listbox.
    I attached an event handler to onmousewheel event in my javascript class and scroll this div using scrollTop property when next/prev span element is not in div's visible area.
    But trouble is div implements mousewheel scrolling too, like you're scrolling html page and I have some kind of a double scrolling . What I want is to disable div's standard mousewheel scrolling (but keep scroll bars).

    Thanks

    Vladislav

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    <div onmousewheel="return false">......</div>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Oct 2003
    Location
    Ukraine
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I need to handle onmousewheel, because I do there my own event processing - changing background on items and scrolling.
    What I want is to disable div's built in scrolling behavior , I use scrollTop property myself.
    For example when user rotates wheel I select (set blue background) on the next or previous span elements in div, to work like listbox/select.
    But at the same time div scrolls content itself.

    Slava

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    If you use onmousewheel to fire another function, try:

    <div onmousewheel="that_function();return false">......</div>

    or:

    function that_function(){
    ...
    ... statments;
    return false
    }

    <div onmousewheel="return that_function()">......</div>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    New Coder
    Join Date
    Oct 2003
    Location
    Ukraine
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It works.

    Thank you Kor.

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts

    Thumbs up

    You're welcome... Any time here for help, if we are able to
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •