-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Calculate width/height
of canvas based on container dimensions (".excalidraw" selector) & remove props width & height
#3379
Conversation
…ainer and only apply that to canvas
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/excalidraw/excalidraw/9wMRtzSKUnLYa5K1qdMn9nXgHeCS |
I'd not remove the props since host apps may wanna do something custom and not make the width/height be dependent on parent container — though I guess it could be hacked by setting the width/height on the parent container instead — dunno, we'll see. Btw, you're still defaulting the canvas width/height to |
Now that width/height is actually set by browser I think we shouldn't take it from props any more as it just sets the canvas width/height which can be calculated from ".excalidraw" container and we also need not handle the additional cases of updating offsets when width/height prop updates.
yep since i am updating it in didMount so thats actually not getting used. I will remove that now. |
Fixed the tests, not sure if this is the best way to fix it, I had to stub the |
There's a problem where if you put the excalidraw component into a container with no explicit dimensions it'll keep on expanding due to a feedback loop because it seems there's some discrepancy between the https://codesandbox.io/s/excalidraw-v050-forked-9uure?file=/src/App.js In the example above, I've added a Making But, it just fixes this very case. Problem is any other thing can cause this feedback loop, e.g. adding Point is, dropping the |
Good catch 👍 . Yep this is a known issue / behaviour when using canvas when we try to resize it according to parent (example), I had faced the same issue in excal app but that got fixed after giving There are two work around for this
I have pushed the fix with absolute, you can try out with version |
Good idea about the |
width/height
of canvas based on container dimensions (".excalidraw" selector) & remove props width & height
absolute
canvas due to feat: Calculatewidth/height
of canvas based on container dimensions (".excalidraw" selector) & remove props width & height #3379 (comment)Tests show an extra rerender but that's only specific to the tests due to mocking the
getBoundingClientRect
. The real app actually does one less render.Try here