vaadin / touchkit

TouchKit is a library of mobile components for Vaadin Framework
https://vaadin.com/touchkit
Other
11 stars 25 forks source link

SwipeView and Table on Android, swipe does not always happen on the correct row #400

Open vaadin-bot opened 9 years ago

vaadin-bot commented 9 years ago

Originally by @johannest


Steps to reproduce

  1. Use the simple example app below.
  2. Open the app in Android's browser (native or Chrome)
  3. Swipe a row
  4. Scroll upwards and swipe another row

Sometimes the previously swiped row (or some other row) is swiped again instead of the row under the finger (about 1 out of 6 times), but sometimes it works as expected. Tested with Samsung Galaxy 4 and Nexus tablet.

See also the related ticket: http://dev.vaadin.com/ticket/16902

@Theme("swipeviewtest")
public class SwipeviewtestUI extends UI {

    @WebServlet(value # "/*", asyncSupportedtrue)
    @VaadinServletConfiguration(productionMode # false, uiSwipeviewtestUI.class, widgetset = "com.example.swipeviewtest.widgetset.SwipeviewtestWidgetset")
    public static class Servlet extends VaadinServlet {
    }

    private Table table;

    @Override
    protected void init(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);
        layout.addComponents(createTable());
    }

    public Table createTable() {
        table = new Table();
        table.addContainerProperty("name", Component.class, null);
        for (int i = 0; i < 100; i++) {
            table.addItem(new Object[] { createEmailSwiperForGivenComponentAndItemId(i) }, i);
        }
        table.setImmediate(true);
        table.setSizeFull();
        table.setPageLength(table.size());
        table.setColumnExpandRatio("name", 1);
        table.setVisibleColumns(new Object[] { "name" });
        return table;
    }

    private NavigationManager createEmailSwiperForGivenComponentAndItemId(
            Object itemId) {
        HorizontalLayout lo = new HorizontalLayout(new Label("Label - current: " + itemId));
        lo.setWidth("100%");
        lo.setHeight("100px");
        SwipeView swipeView = new SwipeView(lo);
        swipeView.setSizeFull();

        final NavigationManager nm = new NavigationManager(swipeView);
        nm.setNextComponent(new Label("Label - next"));
        nm.setPreviousComponent(new Label("Label - previous"));
        return nm;
    }
}

Css for the app

    .v-table-cell-wrapper {
        height: 110px;
    }

    .v-table-cell-wrapper > .v-widget {
        height: 110px;
    }

Imported from https://dev.vaadin.com/ issue #16920