"scroll end" event?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Wigzell

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




  • Stephen Chalmers

    #2
    Re: "scroll end" event?


    "Simon Wigzell" <simonwigzell@s haw.ca> wrote in message
    news:RXMuc.6307 89$oR5.263367@p d7tw3no...
    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'even t?
    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.


    Comment

    • Simon Wigzell

      #3
      Re: &quot;scroll end&quot; 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?


      Comment

      • Andrew Thompson

        #4
        Re: &quot;scroll end&quot; 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=pgd n>
        <http://www.physci.org/kbd.jsp?key=hom e>..?

        --
        Andrew Thompson
        http://www.PhySci.org/ Open-source software suite
        http://www.PhySci.org/codes/ Web & IT Help
        http://www.1point1C.org/ Science & Technology

        Comment

        • Stephen Chalmers

          #5
          Re: &quot;scroll end&quot; event?


          "Simon Wigzell" <simonwigzell@s haw.ca> wrote in message
          news:zsQuc.6324 76$oR5.31064@pd 7tw3no...[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.


          Comment

          • rf

            #6
            Re: &quot;scroll end&quot; event?


            "Simon Wigzell" <simonwigzell@s haw.ca> wrote in message
            news:zsQuc.6324 76$oR5.31064@pd 7tw3no...[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.


            Comment

            • DU

              #7
              Re: &quot;scroll end&quot; 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=Y ES&PRODUCT=Full %20Color%20Broc hure&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.compa tMode == "CSS1Compat "?
              document.docume ntElement: 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

              Comment

              • DU

                #8
                Re: &quot;scroll end&quot; event?

                rf wrote:
                [color=blue]
                > "Simon Wigzell" <simonwigzell@s haw.ca> wrote in message
                > news:zsQuc.6324 76$oR5.31064@pd 7tw3no...
                >[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.



                NS 7.0 was supporting
                window.addEvent Listener("scrol l", functionName, false)
                much better than later releases:


                Opera 7 also had to fix a bug on this.

                DU

                Comment

                • Stephen Chalmers

                  #9
                  Re: &quot;scroll end&quot; event?


                  "Simon Wigzell" <simonwigzell@s haw.ca> wrote in message
                  news:RXMuc.6307 89$oR5.263367@p d7tw3no...[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{positi on:absolute;lef t: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('s lide'), oldVPos=0, scrollInt=null;

                  function getVPos()
                  {
                  var v;
                  return (v=window.pageY Offset)!=undefi ned ? v :
                  ((v=document.bo dy.scrollTop)!= undefined ? v: 0) ;
                  }

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

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

                  clearTimeout(de lay);

                  delay=setTimeou t("getDivRef('s lide').visibili ty='visible'",8 00);

                  dRef.top=v+10;
                  }
                  }

                  function getDivRef(divId )
                  {

                  return document.getEle mentById
                  ?
                  document.getEle mentById(divId) .style
                  :document.layer s
                  ?
                  document.layers[divId]
                  :document.all
                  ?
                  document.all(di vId).style
                  :null;

                  }

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

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

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

                  </BODY>
                  </HTML>


                  Comment

                  • Richard Cornford

                    #10
                    Re: &quot;scroll end&quot; 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.pageY Offset)!=undefi ned ? v :[/color]

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

                    And no support for IE 6 in standards mode.

                    Richard.


                    Comment

                    • Stephen Chalmers

                      #11
                      Re: &quot;scroll end&quot; event?


                      "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
                      news:c9ra8n$1t5 $1$8300dec7@new s.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.


                      Comment

                      • Richard Cornford

                        #12
                        Re: &quot;scroll end&quot; 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.


                        Comment

                        • Stephen Chalmers

                          #13
                          Re: &quot;scroll end&quot; event?


                          "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
                          news:ca0641$fsc $1$830fa795@new s.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.docume ntElement.scrol lTop, so it's just as well that
                          window.pageYOff set is still available as it must be used instead.

                          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 strict//EN">
                          <HTML>
                          <HEAD>
                          <style>
                          ..slider{positi on:absolute;lef t: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.p ageYOffset)!='u ndefined' ) //must test first
                          this.index=3;
                          else
                          if( typeof(document .body.scrollTop )!='undefined' )
                          this.index=( document.compat Mode &&
                          document.compat Mode.indexOf("C SS")==0 ) ? 1 : 2;

                          this.getVPos();
                          }

                          vPosData.protot ype.getVPos=fun ction()
                          {
                          switch(this.ind ex)
                          {
                          case 3: this.v=window.p ageYOffset; break;
                          case 2: this.v=document .body.scrollTop ; break;
                          case 1: this.v=document .documentElemen t.scrollTop; break;
                          case 0: this.v=0;
                          }

                          return this.v;
                          }

                          var stopWait=null, dr=getDivRef('s lide'), scrollPeriod=nu ll, vp=new
                          vPosData(), oldVPos=vp.v;

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

                          clearTimeout(st opWait);

                          stopWait=setTim eout("getDivRef ('slide').visib ility='visible' ",800);

                          dRef.top=20+vp. getVPos()+(type of(dRef.top)==' string'?'px':0) ;
                          }
                          }

                          function getDivRef(divId )
                          {
                          return document.getEle mentById
                          ?
                          document.getEle mentById(divId) .style
                          :document.layer s
                          ?
                          document.layers[divId]
                          :document.all
                          ?
                          document.all(di vId).style
                          :null;
                          }

                          scrollPeriod=se tInterval("if(o ldVPos!=vp.getV Pos()){oldVPos= vp.getVPos();mo v
                          eDiv(dr)}",200) ; //NN4 fix

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


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

                          </BODY>
                          </HTML>

                          --
                          S.C.


                          Comment

                          • Richard Cornford

                            #14
                            Re: &quot;scroll end&quot; 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.docume ntElement.scrol lTop, so it's just as well that
                            > window.pageYOff set 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.


                            Comment

                            Working...