With GwtQuery :
import static com.google.gwt.query.client.GQuery.$;
import static com.google.gwt.query.client.GQuery.window;
...
//you can also use a GQuery object wrapping the element
public boolean isScrolledIntoView(Element elem)
{
int docViewTop = $(window).scrollTop();
int docViewBottom = docViewTop + $(window).height();
int elemTop = $(elem).offset().top;
int elemBottom = elemTop + $(elem).height();
return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)
&& (elemBottom <= docViewBottom) && (elemTop >= docViewTop) );
}
call this method to know if the elem is entirely visible on the screen
inside your scroll event handler. For adding a scroll event handler,
use the scroll method:
$(window).scroll(new Function(){
public void f(){
//put your code here
}
});
Julien
> --
> You received this message because you are subscribed to the Google Groups
> "gwtquery" group.
> To post to this group, send email to
gwtq...@googlegroups.com.
> To unsubscribe from this group, send email to
>
gwtquery+u...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/gwtquery?hl=en.