Connecting Tech Pros Worldwide Help | Site Map

"scroll end" event?

Simon Wigzell
Guest
 
Posts: n/a
#1: Jul 23 '05
Can I trap when the scroll is ended? This is what I want - the calculator
disapears when the site visitor starts scrolling the main page. I'm doing
that with an "onScroll()" function. I'm bringing the calculator back with a
"onMouseup()" which I thoguht would activate when the scroll bar was
released but it doesn't. What I really want is an "offScroll()" but there is
no such thing!

http://www.mississippiprinting.com/M...Size=8%20x%209


Stephen Chalmers
Guest
 
Posts: n/a
#2: Jul 23 '05

re: "scroll end" event?



"Simon Wigzell" <simonwigzell@shaw.ca> wrote in message
news:RXMuc.630789$oR5.263367@pd7tw3no...
What I really want is an "offScroll()" but there is[color=blue]
> no such thing![/color]

Think carefully about what you are asking. The process of scrolling
consists of a series of sequential scroll actions, each of which moves the
page by a set amount, and each must end before another can start. What would
determine the triggering of an 'offscroll'event?
To re-show your div or whatever, you need to monitor the time that the page
displacement has remained the same.
In addition to using the onscroll event to hide the div, it could
set/refresh a timeout for restoring visibility.

--
S.C.


Simon Wigzell
Guest
 
Posts: n/a
#3: Jul 23 '05

re: "scroll end" event?


Surely it is possible to trap the "onmouseup" event when the user has
finished "dragging" and "lets go of" the scroll bar? "onmouseup" can be
trapped within the rest of the browser window?


Andrew Thompson
Guest
 
Posts: n/a
#4: Jul 23 '05

re: "scroll end" event?


On Tue, 01 Jun 2004 00:53:51 GMT, Simon Wigzell wrote:
[color=blue]
> Surely it is possible to trap the "onmouseup" event when the user has
> finished "dragging" and "lets go of" the scroll bar?[/color]

What about when I release..
<http://www.physci.org/kbd.jsp?key=up>
<http://www.physci.org/kbd.jsp?key=pgdn>
<http://www.physci.org/kbd.jsp?key=home>..?

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Stephen Chalmers
Guest
 
Posts: n/a
#5: Jul 23 '05

re: "scroll end" event?



"Simon Wigzell" <simonwigzell@shaw.ca> wrote in message
news:zsQuc.632476$oR5.31064@pd7tw3no...[color=blue]
> Surely it is possible to trap the "onmouseup" event when the user has
> finished "dragging" and "lets go of" the scroll bar? "onmouseup" can be
> trapped within the rest of the browser window?
>[/color]
Yes, but the scrollbar isn't classed as part of the window (except by
Mozilla).
You may be able to use <body onmouseover=... or the scripted equivalent, but
I would much prefer the way I suggested.
BTW, your current code is not cross-browser, and there is an error in the
CenterIt() function related to the scope of a variable.

--
S.C.


rf
Guest
 
Posts: n/a
#6: Jul 23 '05

re: "scroll end" event?



"Simon Wigzell" <simonwigzell@shaw.ca> wrote in message
news:zsQuc.632476$oR5.31064@pd7tw3no...[color=blue]
> Surely it is possible to trap the "onmouseup" event when the user has
> finished "dragging" and "lets go of" the scroll bar? "onmouseup" can be
> trapped within the rest of the browser window?[/color]

What if your viewer uses that arrow keys or page down/up keys to scroll?

What if your viewer uses the mouse wheel to scroll?

Cheers
Richard.


DU
Guest
 
Posts: n/a
#7: Jul 23 '05

re: "scroll end" event?


Simon Wigzell wrote:
[color=blue]
> Can I trap when the scroll is ended? This is what I want - the calculator
> disapears when the site visitor starts scrolling the main page. I'm doing
> that with an "onScroll()" function. I'm bringing the calculator back with a
> "onMouseup()" which I thoguht would activate when the scroll bar was
> released but it doesn't. What I really want is an "offScroll()" but there is
> no such thing!
>
> http://www.mississippiprinting.com/M...ame=Brochures&[/color]
PageName=8%20x%209&FIRSTTIME=YES&PRODUCT=Full%20Co lor%20Brochure&PageSize=8%20x%209[color=blue]
>
>[/color]

Your code is far from correct, interoperable and cross-browser. Even if
you choose to support only MSIE, your code as it is does not make a lot
of sense. You never define unit values in your css declarations and that
falls under error conditions in CSS. OTOH, you want to support MSIE when
in standards compliant rendering mode with
var root = (document.compatMode == "CSS1Compat"?
document.documentElement: document.body);
which is desirable but your code is incoherent with such praiseworthy goal.

IMO, you first need to validate your markup code and CSS code before
going any further.

DU
DU
Guest
 
Posts: n/a
#8: Jul 23 '05

re: "scroll end" event?


rf wrote:
[color=blue]
> "Simon Wigzell" <simonwigzell@shaw.ca> wrote in message
> news:zsQuc.632476$oR5.31064@pd7tw3no...
>[color=green]
>>Surely it is possible to trap the "onmouseup" event when the user has
>>finished "dragging" and "lets go of" the scroll bar? "onmouseup" can be
>>trapped within the rest of the browser window?[/color]
>
>
> What if your viewer uses that arrow keys or page down/up keys to scroll?
>
> What if your viewer uses the mouse wheel to scroll?
>
> Cheers
> Richard.
>
>[/color]

All of these don't matter if you properly set a scroll event listener on
the window.

http://www10.brinkster.com/doctorunc...rollEvent.html

NS 7.0 was supporting
window.addEventListener("scroll", functionName, false)
much better than later releases:
http://bugzilla.mozilla.org/show_bug.cgi?id=35011#c64
http://bugzilla.mozilla.org/show_bug.cgi?id=189308
Opera 7 also had to fix a bug on this.

DU
Stephen Chalmers
Guest
 
Posts: n/a
#9: Jul 23 '05

re: "scroll end" event?



"Simon Wigzell" <simonwigzell@shaw.ca> wrote in message
news:RXMuc.630789$oR5.263367@pd7tw3no...[color=blue]
> Can I trap when the scroll is ended? This is what I want - the calculator
> disapears when the site visitor starts scrolling the main page. I'm doing
> that with an "onScroll()" function. I'm bringing the calculator back with[/color]
a[color=blue]
> "onMouseup()" which I thoguht would activate when the scroll bar was
> released but it doesn't. What I really want is an "offScroll()" but there[/color]
is[color=blue]
> no such thing!
>
>[/color]
http://www.mississippiprinting.com/M...Size=8%20x%209[color=blue]
>
>[/color]

Nothing to stop it being 'simulated'. Try this - it even has a bandage for
Netscape 4, which doesn't
even have an onscroll event:

<HTML>
<HEAD>
<style>
..slider{position:absolute;left:20; top:10; border-style:ridge;
border-color:#0000ff; border-width:4px;

background-color:#000080; color:#ffffff; padding:10px; font-weight:bold}
</style>
</HEAD>

<BODY>

<DIV class=slider ID=slide>
Scroll the page & I will hide and stay hidden until the page stops.
</DIV>

<SCRIPT>
// (C)S Chalmers

var delay=null, dr=getDivRef('slide'), oldVPos=0, scrollInt=null;

function getVPos()
{
var v;
return (v=window.pageYOffset)!=undefined ? v :
((v=document.body.scrollTop)!=undefined ? v: 0) ;
}

function moveDiv(dRef)
{
var v=getVPos()

if(dRef)
{
dRef.visibility='hidden';

clearTimeout(delay);

delay=setTimeout("getDivRef('slide').visibility='v isible'",800);

dRef.top=v+10;
}
}

function getDivRef(divId)
{

return document.getElementById
?
document.getElementById(divId).style
:document.layers
?
document.layers[divId]
:document.all
?
document.all(divId).style
:null;

}

scrollInt=setInterval("if(oldVPos!=getVPos()){oldV Pos=getVPos();moveDiv(dr)}
",200); //NN4 fix

window.onscroll=function()
{
if(scrollInt!=null)
{
clearInterval(scrollInt);
scrollInt=null;
}
moveDiv(dr);
};

//// Page filler only - REMOVE ////
for(var i=0;i<200;i++)
document.write("|<BR>-<BR>");
///////////////////////////////////////
</SCRIPT>

</BODY>
</HTML>


Richard Cornford
Guest
 
Posts: n/a
#10: Jul 23 '05

re: "scroll end" event?


Stephen Chalmers wrote:
<snip>[color=blue]
> ... - it even has a
> bandage for Netscape 4, which doesn't
> even have an onscroll event:[/color]

Fair enough.

<snip>[color=blue]
> function getVPos()
> {
> var v;
> return (v=window.pageYOffset)!=undefined ? v :[/color]

But a runtime error ("undefined is undefined") on IE4.
[color=blue]
> ((v=document.body.scrollTop)!=undefined ? v: 0) ;[/color]
<snip>

And no support for IE 6 in standards mode.

Richard.


Stephen Chalmers
Guest
 
Posts: n/a
#11: Jul 23 '05

re: "scroll end" event?



"Richard Cornford" <Richard@litotes.demon.co.uk> wrote in message
news:c9ra8n$1t5$1$8300dec7@news.demon.co.uk...
[color=blue]
> And no support for IE 6 in standards mode.
>[/color]
The OP's site wasn't selecting standards mode, which is difficult to support
for the purposes of setting a div's position. Mozilla requires a string
parameter, including 'px', while Netscape 4 at least, requires an integer.

--
S.C.


Richard Cornford
Guest
 
Posts: n/a
#12: Jul 23 '05

re: "scroll end" event?


Stephen Chalmers wrote:[color=blue]
> Richard Cornford wrote:[color=green]
>> And no support for IE 6 in standards mode.
>>[/color]
> The OP's site wasn't selecting standards mode, which is difficult to
> support for the purposes of setting a div's position. Mozilla
> requires a string parameter, including 'px', while Netscape 4 at
> least, requires an integer.[/color]

The CSS units problem is not at all difficult to handle:-

<URL: http://jibberingg.com/faq/faq_notes/misc.html#mtCSSUn >

Richard.


Stephen Chalmers
Guest
 
Posts: n/a
#13: Jul 23 '05

re: "scroll end" event?



"Richard Cornford" <Richard@litotes.demon.co.uk> wrote in message
news:ca0641$fsc$1$830fa795@news.demon.co.uk...[color=blue]
> Stephen Chalmers wrote:[color=green]
> > Richard Cornford wrote:[color=darkred]
> >> And no support for IE 6 in standards mode.
> >>[/color]
> > The OP's site wasn't selecting standards mode, which is difficult to
> > support for the purposes of setting a div's position. Mozilla
> > requires a string parameter, including 'px', while Netscape 4 at
> > least, requires an integer.[/color]
>
> The CSS units problem is not at all difficult to handle:-
>
> <URL: http://jibberingg.com/faq/faq_notes/misc.html#mtCSSUn >
>[/color]
OK, but another pitfall is that Mozilla doesn't update
document.documentElement.scrollTop, so it's just as well that
window.pageYOffset is still available as it must be used instead.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 strict//EN">
<HTML>
<HEAD>
<style>
..slider{position:absolute;left:30px; top:20px; border-style:ridge;
border-color:#0000ff; border-width:4px;
background-color:#000080; color:#ffffff; padding:10px; font-weight:bold}
</style>
</HEAD>

<BODY>

<DIV class=slider ID=slide>
Scroll the page & I will hide until the page stops.
</DIV>

<SCRIPT>
// (C)S Chalmers

function vPosData()
{
this.index=0;
this.v=0;

if( typeof(window.pageYOffset)!='undefined' ) //must test first
this.index=3;
else
if( typeof(document.body.scrollTop)!='undefined' )
this.index=( document.compatMode &&
document.compatMode.indexOf("CSS")==0 ) ? 1 : 2;

this.getVPos();
}

vPosData.prototype.getVPos=function()
{
switch(this.index)
{
case 3: this.v=window.pageYOffset; break;
case 2: this.v=document.body.scrollTop; break;
case 1: this.v=document.documentElement.scrollTop; break;
case 0: this.v=0;
}

return this.v;
}

var stopWait=null, dr=getDivRef('slide'), scrollPeriod=null, vp=new
vPosData(), oldVPos=vp.v;

function moveDiv(dRef)
{
if(dRef)
{
dRef.visibility='hidden';

clearTimeout(stopWait);

stopWait=setTimeout("getDivRef('slide').visibility ='visible'",800);

dRef.top=20+vp.getVPos()+(typeof(dRef.top)=='strin g'?'px':0);
}
}

function getDivRef(divId)
{
return document.getElementById
?
document.getElementById(divId).style
:document.layers
?
document.layers[divId]
:document.all
?
document.all(divId).style
:null;
}

scrollPeriod=setInterval("if(oldVPos!=vp.getVPos() ){oldVPos=vp.getVPos();mov
eDiv(dr)}",200); //NN4 fix

window.onscroll=function()
{
if(scrollPeriod!=null)
{
clearInterval(scrollPeriod);
scrollPeriod=null;
}
moveDiv(dr);
};


//// Line generator only - REMOVE ////
for(var i=0, repeatCount=100/document.location.href.length;
i<repeatCount;i++)
for(var j=0; j<document.location.href.length;j++)
document.write(document.location.href.charAt(j)+"< BR>");
///////////////////////////////////////
</SCRIPT>

</BODY>
</HTML>

--
S.C.


Richard Cornford
Guest
 
Posts: n/a
#14: Jul 23 '05

re: "scroll end" event?


Stephen Chalmers wrote:[color=blue]
> Richard Cornford wrote:[color=green]
>> Stephen Chalmers wrote:[color=darkred]
>> > Richard Cornford wrote:
>> >> And no support for IE 6 in standards mode.
>> >>
>> > The OP's site wasn't selecting standards mode, which is difficult
>> > to support for the purposes of setting a div's position. Mozilla
>> > requires a string parameter, including 'px', while Netscape 4 at
>> > least, requires an integer.[/color]
>>
>> The CSS units problem is not at all difficult to handle:-
>>
>> <URL: http://jibberingg.com/faq/faq_notes/misc.html#mtCSSUn >
>>[/color]
> OK, but another pitfall is that Mozilla doesn't update
> document.documentElement.scrollTop, so it's just as well that
> window.pageYOffset is still available as it must be used instead.[/color]

Opera 7, Konqueror 3, Safari 1, IceBrowser 5 and others don't either so
pageX/YOffset should be preferred (and is widely supported outside IE
browsers):-

<URL:
http://jibberingg.com/faq/faq_notes/....html#bdScroll >

Richard.


Closed Thread