Open mvysny opened 4 months ago
Workaround: call element.scroll()
:
public class VovScroller extends Scroller implements Scrollable {
@Override
public void scroll(@Nullable Integer top, @Nullable Integer left) {
if (top != null && top < 0) {
throw new IllegalArgumentException("Parameter top: invalid value " + top + ": must be 0 or greater");
}
if (left != null && left < 0) {
throw new IllegalArgumentException("Parameter top: invalid value " + left + ": must be 0 or greater");
}
// https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll
List<String> options = new ArrayList<>();
if (top != null) {
options.add("top: " + top);
}
if (left != null) {
options.add("left: " + left);
}
if (!options.isEmpty()) {
getElement().executeJs("this.scroll({" + String.join(",", options) + "});");
}
}
}
Describe your motivation
I'm migrating an app from Vaadin 8 and searching for a Panel replacement. Scroller is a natural candidate for that, unfortunately it doesn't support
setScrollTop()
norsetScrollLeft()
.Describe the solution you'd like
Add
Scroller.setScrollTop(int)
andScroller.setScrollLeft(int)
which would accept a non-negative value in pixels to set the scrolling offset on the client-side.Describe alternatives you've considered
No response
Additional context
No response