Fit.Layout doesn't reflow elements in canvas-lite

Open
#409 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
frontend

Research direction

Reproduce the issue with the supplied useRive example, Fit.Layout, and the same .riv file in @rive-app/react-canvas-lite and @rive-app/react-canvas. Compare how the two runtimes handle layout-constrained elements, then verify that elements pinned to bottom-left remain anchored in canvas-lite while the canvas still fills the viewport.

Written by the indexing model from the issue text.

Description

enhancement

Title:
Fit.Layout doesn't reflow layout-constrained elements in canvas-lite — elements render at top-left instead of
anchored position


Description:

When using @rive-app/react-canvas-lite with Fit.Layout, elements that use Rive Layout constraints (e.g.
pinned to bottom-left) are not reflowed correctly. They render at the top-left of the canvas instead of their
anchored position. The exact same .riv file works correctly with @rive-app/react-canvas (full runtime).

Environment:

  - @rive-app/canvas-lite: 2.35.0 (also reproduced on 2.34.3)
  - @rive-app/react-canvas-lite: 4.27.0
  - Works correctly with: @rive-app/react-canvas@4.26.2 + @rive-app/canvas@2.34.2
  - Browser: Chrome / Safari on macOS

Artboard info (from rive.bounds and rive.layout?.layoutScaleFactor):

  layoutScaleFactor: 1
  bounds: { minX: 0, minY: 0, maxX: 1512, maxY: 798 }

Canvas at runtime: correctly fills the viewport. The canvas
sizing itself is fine — the bug is purely the position of elements within the canvas.

Code:

  const { rive, RiveComponent } = useRive({
    src: animationUrl,
    stateMachines: 'Training Machine',
    layout: new Layout({ fit: Fit.Layout }),
  });

  return (
    <div style={{ position: 'fixed', inset: 0 }}>
      <RiveComponent />
    </div>
  );

Expected: elements pinned to bottom-left via Rive Layout constraints render at the bottom-left of the canvas
(as they do with react-canvas).

Actual: elements render at the top-left of the canvas regardless of their layout constraints.

Dominant language
TypeScript
Stars
1.2k
Forks
58
Avg merge
3h 23m
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rive-app/rive-react

All issues in rive-app/rive-react

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.