Skip to content

Commit

Permalink
fix: account for scale factor in layout resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
HayesGordon committed Oct 30, 2024
1 parent f9bad8b commit bb07829
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/hooks/useRive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ export default function useRive(
if (rive) {
if (rive.layout && rive.layout.fit === Fit.Layout) {
if (canvasElem) {
const resizeFactor = devicePixelRatio * rive.layout.layoutScaleFactor;
// TODO (Gordon): expose these are properties on JS runtime
(rive as any)._devicePixelRatioUsed = devicePixelRatio;
(rive as any).artboard.width = canvasElem?.width / devicePixelRatio;
(rive as any).artboard.height = canvasElem?.height / devicePixelRatio;
(rive as any).artboard.width = canvasElem?.width / resizeFactor;
(rive as any).artboard.height = canvasElem?.height / resizeFactor;
}
}

Expand Down

0 comments on commit bb07829

Please sign in to comment.