rive-react icon indicating copy to clipboard operation
rive-react copied to clipboard

Fix: Prevent canvas resolution resizing if user passes in resolution values on canvas

Open zplata opened this issue 3 years ago • 0 comments

Addresses an issue where someone's setting of width/height on the RiveComponent from useRive doesn't get overridden (brought up in Discord).

This is setting data- attributes on the canvas for user-passed in values for width/height resolutions as an indicator for us to see whether or not to override the width/height with our devicePixelRatio logic. This is because from the internals of the hook, we can't tell what user passed-in props (i.e width and/or height) are set on the RiveComponent, but we can look into the ref of the canvas element to check for these attributes.

Definitely open to other ideas here; had to find a way to distinguish between us setting the width/height internally vs consumers setting it via props.

zplata avatar Aug 02 '22 04:08 zplata