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 7 of 7
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Onscroll and componentFromPoint bugs

    I am trying to capture the onscroll event so that I can record what button or area a user clicked on a particular scrollbar.

    There are two problems that are giving me grief.

    1. The onscroll event fires ~40 times each time a scrollup or scrolldown button is pressed. This causes my onscroll= function to run over and over again where I only want it to run once!

    2. The componentFromPoint() method returns the value from AFTER the scroll has taken place. So, if you click in the scrollbars track, immediately below the slider (or thumb) you are returned the value "scrollbarVThumb" instead of "scrollbarpagedown".

    These two errors combined produce a very annoying effect. Check it out with the following sample HTML. Try clicking on the scrollbar, you have to click a few times to get rid of the alert box. (Or hold down the esc key).

    <HTML>
    <head>
    <script>
    function sayCheese(obj)
    {
    sElem = obj.componentFromPoint(event.clientX,event.clientY);
    alert(sElem);
    }
    </script>
    </head>
    <body>
    <div style="overflow: hidden;" style="height: 300; width: 20" >
    <div id="divy" style="overflow-y: scroll;width:0;height:300;" onScroll="sayCheese(this);">
    <div style="height: 1000px;width:1;">
    </div>
    </div>
    </div>
    </body>
    </html>

    Thanks guys.

    W.

    "It doesn't matter if I'm optomistic or not, nothing ever works out for me."

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WMJB
    I am trying to capture the onscroll event so that I can record what button or area a user clicked on a particular scrollbar.
    Why?
    *this message will self destruct in n-seconds*

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Believe it or not I am trying to emulate a fake scrollbar. But I want the fake scrollbar to look exactly like a real scrollbar (Its a long story)
    "It doesn't matter if I'm optomistic or not, nothing ever works out for me."

  • #4
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK, but to determine the point of mouse capture, would onmousedown not be sufficient?
    *this message will self destruct in n-seconds*

  • #5
    New Coder
    Join Date
    Mar 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, if I can calculate the exact size and position of the slider. The problem with this is that the slider's height is dependant on your control panel settings!
    "It doesn't matter if I'm optomistic or not, nothing ever works out for me."

  • #6
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perhaps you should summarize this long story...
    *this message will self destruct in n-seconds*

  • #7
    New Coder
    Join Date
    Mar 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Its ok. I am going to assume that if scrollTop changes by more than 10px and I am returned scrollbarVthumb then it was a pagedown. Then I just ignore the next 100 events. Its not great but it will have to do. I may have to make the 10px a variable depending on the length of the scrollbar.. not sure yet.

    Thanks for your help.

    W.
    "It doesn't matter if I'm optomistic or not, nothing ever works out for me."


  •  

    Posting Permissions

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