actions: make scroll coordinates optional

Updates the scroll action to accept optional x and y coordinates. This
allows scrolling on a single axis without resetting the other to zero.
This commit is contained in:
Adrià Arrufat
2026-03-16 22:44:37 +09:00
parent f5bc7310b1
commit a74e46debf
3 changed files with 8 additions and 14 deletions

View File

@@ -494,9 +494,6 @@ fn handleScroll(server: *Server, arena: std.mem.Allocator, id: std.json.Value, a
return server.sendError(id, .PageNotLoaded, "Page not loaded");
};
const x = args.x orelse 0;
const y = args.y orelse 0;
var target_node: ?*DOMNode = null;
if (args.backendNodeId) |node_id| {
const node = server.node_registry.lookup_by_id.get(node_id) orelse {
@@ -505,7 +502,7 @@ fn handleScroll(server: *Server, arena: std.mem.Allocator, id: std.json.Value, a
target_node = node.dom;
}
lp.actions.scroll(target_node, x, y, page) catch |err| {
lp.actions.scroll(target_node, args.x, args.y, page) catch |err| {
if (err == error.InvalidNodeType) {
return server.sendError(id, .InvalidParams, "Node is not an element");
}