scroll method

  1. @override
Future<void> scroll({
  1. int? x,
  2. int? y,
})
override

Scrolls this element in x and/or y direction by pixels.

ScrollOptions is currently not supported. https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll

Implementation

@override
Future<void> scroll({int? x, int? y}) async {
  await syncFn(() => _retryWhenStale(() {
        final element = _single;

        // Note: element.scroll(...) from dart:html does not work.
        return _microtask(() {
          element.scrollLeft += x ?? 0;
          element.scrollTop += y ?? 0;
          // In practice, 'scroll' events are sent rapidly but we only send
          // it once here.
          element.dispatchEvent(Event('scroll'));
        });
      }));
}