By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,297 Members | 1,409 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,297 IT Pros & Developers. It's quick & easy.

"scroll end" event?

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a

"Simon Wigzell" <si**********@shaw.ca> wrote in message
news:RXMuc.630789$oR5.263367@pd7tw3no...
What I really want is an "offScroll()" but there is
no such thing!


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.
Jul 23 '05 #2

P: n/a
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?
Jul 23 '05 #3

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


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
Jul 23 '05 #4

P: n/a

"Simon Wigzell" <si**********@shaw.ca> wrote in message
news:zsQuc.632476$oR5.31064@pd7tw3no...
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?

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.
Jul 23 '05 #5

P: n/a
rf

"Simon Wigzell" <si**********@shaw.ca> wrote in message
news:zsQuc.632476$oR5.31064@pd7tw3no...
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?


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.
Jul 23 '05 #6

P: n/a
DU
Simon Wigzell wrote:
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& PageName=8%20x%209&FIRSTTIME=YES&PRODUCT=Full%20Co lor%20Brochure&PageSize=8%20x%209


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
Jul 23 '05 #7

P: n/a
DU
rf wrote:
"Simon Wigzell" <si**********@shaw.ca> wrote in message
news:zsQuc.632476$oR5.31064@pd7tw3no...
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?

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.


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
Jul 23 '05 #8

P: n/a

"Simon Wigzell" <si**********@shaw.ca> wrote in message
news:RXMuc.630789$oR5.263367@pd7tw3no...
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


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>
Jul 23 '05 #9

P: n/a
Stephen Chalmers wrote:
<snip>
... - it even has a
bandage for Netscape 4, which doesn't
even have an onscroll event:
Fair enough.

<snip> function getVPos()
{
var v;
return (v=window.pageYOffset)!=undefined ? v :
But a runtime error ("undefined is undefined") on IE4.
((v=document.body.scrollTop)!=undefined ? v: 0) ;

<snip>

And no support for IE 6 in standards mode.

Richard.
Jul 23 '05 #10

P: n/a

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:c9*******************@news.demon.co.uk...
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.

--
S.C.
Jul 23 '05 #11

P: n/a
Stephen Chalmers wrote:
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.


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

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

Richard.
Jul 23 '05 #12

P: n/a

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:ca*******************@news.demon.co.uk...
Stephen Chalmers wrote:
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.


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

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

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.
Jul 23 '05 #13

P: n/a
Stephen Chalmers wrote:
Richard Cornford wrote:
Stephen Chalmers wrote:
> 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.


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

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

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.


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.
Jul 23 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.