vaadin / web-components

A set of high-quality standards based web components for enterprise web applications. Part of Vaadin 20+
https://vaadin.com/docs/latest/components
461 stars 83 forks source link

[grid] Fire scroll events #2045

Open jouni opened 7 years ago

jouni commented 7 years ago

We should fire scroll events when the grid is scrolled, which the developer can listen and react to.

var grid = document.querySelector("vaadin-grid");
grid.addEventListener("scroll", function(e) {
  ...
});

The event object ("e") should have both scrollTop and scrollLeft properties that present the grid’s state. If possible, it should also have the scrollHeight property that indicates the total of the grid body.

This will enable developers to do additional customizations based on the scroll position, to add some functionality which is not built-in, like a scrollbar indicator (like you see in Google Docs).

stramel commented 7 years ago

Would be nice to be able to scroll to certain place in the grid. My case is to reload the table and reset the scroll position to 0,0. Currently, I am doing this.$.grid.$.scroller.scroll(0,0)

alump commented 6 years ago

We did this on our px-data-grid wrapper element with magic of: https://gist.github.com/alump/cfa7b08a0973a53303a6be8cc83d1e16