Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Alternative "scrollIntoView"

Reply
Thread Tools

Alternative "scrollIntoView"

 
 
xevi.matavacas@gmail.com
Guest
Posts: n/a
 
      12-30-2005
Hi friends,

I found a problem while "scrolling into view" and to overcome this I
made a function to simulate javascript's function. I would like to
share it and here it is:

function alternativeScrollIntoView(parentDiv,elementIntoDiv )
{
var principal =parentDiv;
principal.scrollTop = 0;
var rects = principal.getClientRects()[0];
var topFinal = rects.top;
var bottomFinal = rects.bottom;
var bottomActual = elementIntoDiv.getClientRects()[0].bottom;
if (bottomActual == 0)
{
return;
}
while(bottomActual>bottomFinal||bottomActual<topFi nal)
{
var direction="down";
if(bottomActual<topFinal) direction="up";
principal.doScroll(direction);
bottomActual=elementIntoDiv.getClientRects()[0].bottom;
}
}

It worked in my enviroment, i hope it could be useful for you too.

Xevi.

PS: It was done for IE. I didn't test it in other enviroments.

 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      12-30-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi friends,
>
> I found a problem while "scrolling into view" and to overcome this I
> made a function to simulate javascript's function. I would like to
> share it and here it is:


What version of IE supports getClientRects() and doScroll() but not
scrollIntoView()? Doesn't scrollIntoView() go back to IE 4 and the
other two to IE 5?


[...]


--
Rob
 
Reply With Quote
 
 
 
 
xevi.matavacas@gmail.com
Guest
Posts: n/a
 
      12-30-2005
All of these functions worked on IE5.5 but the result was not always
the expected. Sometimes the element didn't fit into the view. That's
why we made this function to overcome this.

 
Reply With Quote
 
RobG
Guest
Posts: n/a
 
      12-30-2005
(E-Mail Removed) wrote:
> All of these functions worked on IE5.5 but the result was not always
> the expected. Sometimes the element didn't fit into the view. That's
> why we made this function to overcome this.
>


A more cross-browser function could use scrollIntoView first, then
adjust the position using your function if the features are supported
(of course scrollIntoView should be feature tested too).

That may also provide some extra speed/efficiency on IE where the
element needs to scroll a long way.


--
Rob
 
Reply With Quote
 
xevi.matavacas@gmail.com
Guest
Posts: n/a
 
      12-30-2005
You're right, I agree that this is the best option. Better use first
what the enviroment provides and if necessary use the function I made.

Thanks a lot.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Quicktime Alternative, RealPlayer Alternative & Media Player Classic John Capleton Computer Support 3 12-05-2005 07:41 AM
WPS DDK Updates or alternative? glenn Wireless Networking 1 11-06-2005 03:20 PM
Symantec Express Cleanup or alternative Ron P Firefox 2 04-24-2005 10:39 AM
Real Player Alternative and Mozilla probs dw Firefox 1 09-04-2003 12:18 PM



Advertisments