By infinite scrolling, I mean I initially load a few child widgets, and as the user scrolls down lazily load more to fill it out.
Any ideas appreciated.
(ideally would like something for GWT 1.6 and 1.5)
Try something like this:
public static class InfiniteScrollPanel implements ScrollHandler {
String text = "Lorem ipsum dolor sit amet, consectetuer...";
ScrollPanel panel = new ScrollPanel(new HTML(text));
int height = 200;
int width = 200;
public InfiniteScrollPanel() {
panel.setHeight(height);
panel.setWidth(width);
panel.addScrollHandler(this);
}
public void onScroll(ScrollEvent event) {
if (panel.getScrollPosition == height) {
panel.add(new HTML(text));
}
}
}
What this code does: it creates a ScrollPanel and adds a ScrollHandler to it. In the ScrollHandler the scrollheight gets compared to the height of the panel and it then adds another child to the panel.
I haven't tested it because I'm writing this on a netbook and don't have an IDE on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With