feat(html): add scroll method to MountedData (#3722)

* feat(html): add `scroll` method to MountedData

* feat(desktop): implement `scroll` method for DesktopElement

* feat(liveview): implement `scroll` method for LiveviewElement

* feat(web): implement `scroll` method for web_sys::Element

* docs(examples): add new example for `scroll` method

* fix(web): remove unncecessary f64 cast (clippy)

* fix(interpreter): return missing boolean from js

* docs(example): unwrap result instead of discarding its error

* docs(examples): create scroll restoring example on routing

* fix clippy

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
Youn MéloisandJonathan Kelley authored and GitHub committed 2025-05-07 12:45:47 -07:00
1 parent 60c1b0ead6
commit 85b373deff
11 files changed
+757 -607

No files matched your search

+9
View File
@@ -115,6 +115,15 @@ export class NativeInterpreter extends JSChannel_ {
return false;
}
scroll(id: NodeId, x: number, y: number, behavior: ScrollBehavior): boolean {
const node = this.nodes[id];
if (node instanceof HTMLElement) {
node.scroll({ top: y, left: x, behavior });
return true;
}
return false;
}
getScrollHeight(id: NodeId): number | undefined {
const node = this.nodes[id];
if (node instanceof HTMLElement) {