Tuesday, April 5, 2011

Dragging a widget down a long list so that scrolling is necessary with gwt-dnd

I'm investigating using gwt-dnd to implement drag-and-drop reordering of a list of widgets. The list might be longer than its visible area, and so I'd like the user to be able to do that drag-the-widget-near-the-bottom-and-the-list-auto-scrolls behavior that's pretty much standard.

Does gwt-dnd have this support built in anywhere? If not, any ideas on implementing it?

From stackoverflow
  • You can try to do the following in case, you are using PickUpDragController and other classes which might have dragMove.

    Subclass the PickUpDragController class and override dragMove as follows

    @Override
      public void dragMove()
      {
            DOM.scrollIntoView(context.selectedWidgets.get(0).getElement());
            super.dragMove();
      }
    
  • As it turns out, gwt-dnd has support for this automatically. It requires that the dropArea be inside an AbsolutePanel dragBoundary, and that the dragBoundary is within a scroll panel.

0 comments:

Post a Comment