-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Rotated background image disappearing upon panning #6646
Comments
The reason you are experience the bug is because there is an optimization to skip offScreen object from rendering. |
Hi @asturur 👋 Regarding fabric.js/src/static_canvas.class.js Lines 681 to 687 in 4f48cc5
(I am not super familiar with CanvasJS codebase so please disregard this comment if I am wrong 😅 ) Thank you again for your swift reply and also the rest of the team for the great work on this great lib 👍 |
Sorry for the late response. |
Hi awesome FabricJS team 👋 and first of all, thank you for all the awesome work on this library 🙇
This is also my first bug report so please correct me if I made a mistake somewhere in the process 🙇
Version
4.2.0
Test Case
(Unfortunately I was not able to reproduce behavior below in JSfiddle, but managed it in CodePen. I hope that is also OK)
https://codepen.io/driek/pen/yLJLVwW
I have placed two buttons, "rotate 48 degrees" and "rotate 54 degrees".
When pressing either button, the image will be rotated and panned accordingly to create illusion that image stays centered.
For reference, I also display a semi-transparent rectangle to indicate the original position of the background image.
When pressing the former button, the image is still visible (and so is said rectangle).
However, when pressing the latter button, the background is not visible anymore (see also behavior description below).
NOTE: since pressing a button will invoke
canvas.relativePan
, the buttons cannot be pressed in sequence but the page needs to be refreshed to reset to initial state before another button can be pressed.Information about environment
Nodejs or browser?
Browser
Which browsers?
Verified Codepen test case with:
Steps to reproduce
setBackgroundImage
and updateangle
option to the degree that the original position lays outside the viewport.(for convenience I set
originX
andoriginY
to "center" and for values oftop
andleft
I used center point of minimum required dimensions to fit the rotated image in my example)relativePan
to create the illusion that the background image stays centeredExpected Behavior
The background image to always be visible
Actual Behavior
The image disappears.
My best guess is that the position/dimension of the background image before rotation is being used to check whether or not to render the image as part of optimization. If you un-comment the line in my example so
setCoords
is invoked on the background image however, the image will be visible as expected.Currently I think this behavior is applicable to panning which means it also happens with
zoomToPoint
. (<= not part of the test case, but came across this while developing locally)If you are aware of other places where the same kind of thing could happen, pointing out those places is highly appreciated. (for risk assessment to higher ups and QA on my side)
However, if my approach is wrong to begin with, please point that as well. Thank you in advance for your time and effort 🙇
The text was updated successfully, but these errors were encountered: