Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
A written scroll offset reads back to a hundredth, as raea's window gives it back each frame (sdk/ui's DOM layer)
shinyobjectzb0cd52fd85fe
diff --git a/sdk/ui/src/dom/element.ts b/sdk/ui/src/dom/element.tsindex 86732e12..dcee7cb7 100644--- a/sdk/ui/src/dom/element.ts+++ b/sdk/ui/src/dom/element.ts@@ -427,7 +427,11 @@ function escapeHtml(s: string) {return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);}-function setScroll(el: Element_, box: number[], prop: string, at: number, v: number) {+function setScroll(el: Element_, box: number[], prop: string, at: number, wrote: number) {+ // held to a hundredth, as the host's geometry gives it back each frame (systems/page snapshot.rs), as Chrome snaps+ // a written offset to its pixels at once: read back finer, a write looked like a move the next frame took back, and a+ // spring that keeps what hasn't moved yet (use-stick-to-bottom's) threw its steps away and wrote every frame for good+ const v = Math.round(wrote * 100) / 100;// what it holds moves at once (Chrome lays out again on the next read): its descendants' boxes by the changeconst d = v - box[at];if (d) {diff --git a/sdk/ui/test/scroll.test.tsx b/sdk/ui/test/scroll.test.tsxindex 6b843562..0dad422d 100644--- a/sdk/ui/test/scroll.test.tsx+++ b/sdk/ui/test/scroll.test.tsx@@ -63,6 +63,40 @@ describe("P18 DOM surface: scrolling", () => {expect(heard).toEqual([120, 120, 300]);});+ test("an offset written reads back as the host will show it, to a hundredth, so steps smaller than that add up and arrive", () => {+ // (raea's window: the host's geometry each frame has every number to a hundredth, systems/page snapshot.rs. Read+ // back unrounded, a write of 74.9931 looked like a move, and a spring that keeps what hasn't moved yet, as+ // use-stick-to-bottom's does, threw that away; the frame then put 74.99 back. Its steps under 0.005 never+ // arrived, and it wrote every frame for good: a chat's last turn never held still)+ const host = fresh();+ let el: any;+ mount(+ <div data-testid="root">+ <div data-testid="box" className="overflow-y-auto" ref={(e: any) => (el = e)}>+ <div data-testid="inner" />+ </div>+ </div>,+ 0,+ { dom: true },+ );+ const frame = () => snap(host, { root: [0, 0, 800, 600], box: [0, 0, 200, 100, 0, Math.round(el.scrollTop * 100) / 100, 200, 175], inner: [0, -el.scrollTop, 200, 175] });+ snap(host, { root: [0, 0, 800, 600], box: [0, 0, 200, 100, 0, 74.99, 200, 175], inner: [0, -74.99, 200, 175] });+ el.scrollTop = 74.9931;+ expect(el.scrollTop).toBe(74.99);+ // the spring: a step under a hundredth each frame, kept until the offset moves+ let kept = 0;+ let frames = 0;+ while (el.scrollTop < 75 && frames++ < 60) {+ const was = el.scrollTop;+ kept += 0.002;+ el.scrollTop = was + kept;+ if (el.scrollTop !== was) kept = 0;+ frame();+ }+ expect(el.scrollTop).toBe(75);+ expect(frames).toBeLessThan(10);+ });+test("two scrollers kept in step both ways settle, though the host's scroll events come a frame late", async () => {// (a timeline's tracks and heads: they went round for good in raea's window, a drag's offsets coming back in turn)const host = fresh();