scrollTo method
Scrolls the page horizontally and vertically to a specific point.
This method is identical to scroll.
Other resources
- Window.scrollTo from MDN.
Implementation
void scrollTo([dynamic optionsOrX, y, Map? scrollOptions]) {
final doc = document.documentElement;
if (doc == null) return;
if (optionsOrX is num) {
doc.scrollLeft = optionsOrX.toInt();
doc.scrollTop = (y is num) ? y.toInt() : doc.scrollTop;
return;
}
if (optionsOrX is Map) {
final left = optionsOrX['left'];
final top = optionsOrX['top'];
if (left is num) {
doc.scrollLeft = left.toInt();
}
if (top is num) {
doc.scrollTop = top.toInt();
}
}
}