472,779 Members | 2,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

"scroll end" event?

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
13 16451

"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
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
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

"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
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
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
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

"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
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

"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
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

"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JohnR | last post by:
Wow, this is unbelieveable. I've narrowed it down to a few lines of code. Create a new project in VB.NET and put 2 buttons on it (a FBD button and an EXIT button) and enter these lines for the...
1
by: Najm Hashmi | last post by:
Hi all , I am trying to create a store procedure and I get the following error: SQL0104N An unexpected token "END-OF-STATEMENT" was found following "END". Expected tokens may include: "JOIN...
3
by: Summit | last post by:
Does anyone know what the C# equivalent for VB6 End is? I'm starting up a form with a boolean test. If I fail, I just want to end the app. Even though I close the form, it picks up on the line...
0
by: Tom Bower | last post by:
In the Windows Task Manager if I select a Process and right-click, I can choose to "End Process" or "End Process Tree." Is there a VB equivalent for "End Process Tree" if you have a handle to a...
4
by: Alex Maghen | last post by:
Does a call to Response.Redirect result in an immediate exit from the current page function (i.e. a "return()")? I want to make sure that the statements after the Response.Redirect() do not get...
3
by: caston | last post by:
Well, everybody can now agree with the fact that the Ajax hype is over. Still multiple Ajax Frameworks are flourishing, aren't they? So, last night I questioned myself with the following: "When...
28
by: kaleolani65 | last post by:
I have been having an ongoing problem with a DB at work concerning people getting "locked out". Access warnings relating to "exclusive" mode The research I have done and the replies received...
5
by: BA | last post by:
Hi there I am trying to write an "application" in Access 2000, that displays a front end and allows the user to interact with the database without seeing Access loaded, in the background, nor on...
2
by: jahanas | last post by:
Private Sub txtBox1.txtLife_Enter(ByVal frmQuote) Handles txtLife Me.txtQuote.Text = "I like life, it's something to do." End Sub Private Sub txtBox2.txtFuture_Enter(ByVal...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.