org.dominokit.domino.ui.datatable.plugins.BodyScrollPlugin Maven / Gradle / Ivy
package org.dominokit.domino.ui.datatable.plugins;
import elemental2.dom.HTMLTableSectionElement;
import org.dominokit.domino.ui.datatable.DataTable;
import org.dominokit.domino.ui.datatable.events.BodyScrollEvent;
public class BodyScrollPlugin implements DataTablePlugin {
@Override
public void onBodyAdded(DataTable dataTable) {
HTMLTableSectionElement tbody = dataTable.bodyElement().asElement();
tbody.addEventListener("scroll", evt -> {
if (tbody.scrollTop == 0) {
dataTable.fireTableEvent(new BodyScrollEvent(ScrollPosition.TOP));
}
if (tbody.offsetHeight + tbody.scrollTop == tbody.scrollHeight) {
dataTable.fireTableEvent(new BodyScrollEvent(ScrollPosition.BOTTOM));
}
});
}
public enum ScrollPosition{
TOP,
BOTTOM
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy