Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-17-2005, 01:52 AM   PM User | #1
WMJB
New Coder

 
Join Date: Mar 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
WMJB will become famous soon enough
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."
WMJB is offline   Reply With Quote
Old 03-17-2005, 11:54 AM   PM User | #2
codegoboom
Regular Coder

 
Join Date: Aug 2004
Location: codegoboom@yahoo.com
Posts: 999
Thanks: 0
Thanked 0 Times in 0 Posts
codegoboom is an unknown quantity at this point
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*
codegoboom is offline   Reply With Quote
Old 03-18-2005, 12:13 AM   PM User | #3
WMJB
New Coder

 
Join Date: Mar 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
WMJB will become famous soon enough
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."
WMJB is offline   Reply With Quote
Old 03-18-2005, 01:07 AM   PM User | #4
codegoboom
Regular Coder

 
Join Date: Aug 2004
Location: codegoboom@yahoo.com
Posts: 999
Thanks: 0
Thanked 0 Times in 0 Posts
codegoboom is an unknown quantity at this point
OK, but to determine the point of mouse capture, would onmousedown not be sufficient?
__________________
*this message will self destruct in n-seconds*
codegoboom is offline   Reply With Quote
Old 03-18-2005, 01:54 AM   PM User | #5
WMJB
New Coder

 
Join Date: Mar 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
WMJB will become famous soon enough
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."
WMJB is offline   Reply With Quote
Old 03-18-2005, 02:01 AM   PM User | #6
codegoboom
Regular Coder

 
Join Date: Aug 2004
Location: codegoboom@yahoo.com
Posts: 999
Thanks: 0
Thanked 0 Times in 0 Posts
codegoboom is an unknown quantity at this point
Perhaps you should summarize this long story...
__________________
*this message will self destruct in n-seconds*
codegoboom is offline   Reply With Quote
Old 03-18-2005, 02:37 AM   PM User | #7
WMJB
New Coder

 
Join Date: Mar 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
WMJB will become famous soon enough
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."
WMJB is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:06 PM.


Advertisement
Log in to turn off these ads.