Reputation: 2519
I need to accomplish very simple drag and drop of panels in vertical layout.
Now when I have a several panels in vertical layout and I drag panel above another one and drop it my dropListener runs and here I'm not sure how to manage what I require. I simply need panel to move on proper place based on mouse pointer. Can anyone share some code how to accomplish this using Vaadin 8.2 ? Should I switch panels manualy? If so how can I detect the place mouse points to in the vertical layout?
dropTarget.addDropListener(event -> {
Optional<AbstractComponent> dragSource = event.getDragSourceComponent();
if (dragSource.isPresent() ) {
# I can remove dragged panel from layout using this code
fieldsLayout.removeComponent(dragSource.get());
## how to place dragged panel into proper place ??
}
});
Upvotes: 1
Views: 427
Reputation: 4754
Not sure if it's overkill, but in Vaadin 7 we always used the DragDropLayouts addon to simplify code. We also used it in Vaadin 8 projects recently and it just works ;)
https://vaadin.com/directory/component/dragdroplayouts
Upvotes: 1