DNDScroll Add-on
Extensions for adding automatic scrolling during drag'n'drop to a Vaadin Table or Panel.
DNDScroll is an extension add-on for Vaadin 7 (1.x branch) and Vaadin 8 (2.x branch). It contains TableAutoScrollExtension and PanelAutoScrollExtension, which both add automatic scrolling when a dragged element is hovered near the end or the beginning of the layout.
NOTE: this extension replaces the default implementations of VDragAndDropManager and VDragAndDropWrapper with extended custom versions to enable the autoscroll functionality. If you have any other custom implementations of these classes in your project, you'll need to combine them manually.
For an example of how to use the extensions, see the side panel and the sources.
Tested from 7.6.0 up, might work with older versions as well.
Sample code
protected Table createTable() { Table table = new Table(); BeanItemContainer<TestBean> container = new BeanItemContainer<TestBean>( TestBean.class); for (int i = 0; i < 30; ++i) { container.addBean(new TestBean("item" + i)); } table.setDragMode(TableDragMode.ROW); table.setContainerDataSource(container); table.setPageLength(6); table.setWidth(200, Unit.PIXELS); table.setDropHandler(new TableDropHandler()); TableAutoScrollExtension extension = new TableAutoScrollExtension(); extension.extend(table); return table; }
private Component createVerticalPanel() { Panel panel = new Panel(); VerticalLayout content = new VerticalLayout(); content.setSpacing(true); PanelDropHandler dropHandler = new PanelDropHandler(content); for (int i = 0; i < 30; ++i) { Label label = new Label("label" + i); label.setWidthUndefined(); DragAndDropWrapper wrapper = new DragAndDropWrapper(label); wrapper.setDragStartMode(DragStartMode.COMPONENT); wrapper.setDropHandler(dropHandler); content.addComponent(wrapper); } panel.setContent(content); panel.setHeight(200, Unit.PIXELS); PanelAutoScrollExtension extension = new PanelAutoScrollExtension(); extension.extend(panel); return panel; }
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
- Fix for excess auto scroll
- Limit auto scroll to source and its children
- Released
- 2018-04-23
- Maturity
- EXPERIMENTAL
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 8.0+
- Vaadin 7.6+ in 1.0.0
- Browser
- N/A
DNDScroll Add-on - Vaadin Add-on Directory
Extensions for adding automatic scrolling during drag'n'drop to a Vaadin Table or Panel.Source Code
Discussion Forum
DNDScroll Add-on version 1.0.0
null
DNDScroll Add-on version 1.0.1
Java from 1.8 to 1.7.
DNDScroll Add-on version 1.0.2
Fix to autoscroll issue after scrolling interrupted, thanks to qwasli for the pull request!
DNDScroll Add-on version 2.0.0
Upgrade to Vaadin 8 and Java 8
DNDScroll Add-on version 2.0.1
Fix to autoscroll issue after scrolling interrupted, thanks to qwasli for the pull request!
DNDScroll Add-on version 2.0.2
* Fix for excess auto scroll
* Limit auto scroll to source and its children