Skip to content
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

Using setDimensions on Canvas with isDrawingMode leaves a ghost path #5890

Closed
technotablet opened this issue Sep 25, 2019 · 6 comments
Closed
Labels

Comments

@technotablet
Copy link

Version

3.4.0

Test Case

Working OK in 3.2.0 - https://jsfiddle.net/marquivon/s0zL28x9/2/
Working NOT OK 3.4.0 - https://jsfiddle.net/marquivon/b342mg6h/

Information about environment

Nodejs or browser? Browser
Which browsers? Firefox, Safari, Chrome

Steps to reproduce

  1. Create a Canvas with the following options
var canvas = new fabric.Canvas("c");
canvas.isDrawingMode = true;
// Brush size WITH opacity - important to view difference
canvas.freeDrawingBrush.color = "rgba(255, 0, 0, 0.5)";
canvas.freeDrawingBrush.width = 5;
  1. Draw something on the canvas
  2. Resize the canvas using the following
canvas.setDimensions({
  width: 450,
  height: 450
});
canvas.requestRenderAll();
  1. Draw again. On mouse up, you'll see a darker brush on top of the original path.

Expected Behavior

There should not be a ghost path on top of the original path.
Once the path is created, on mouse up, no additional ghost path is visible.

In version 3.2.0 it is working as expected - Example: https://jsfiddle.net/marquivon/s0zL28x9/2/

Actual Behavior

  • There is a ghost path that is created.
  • The ghost path is not available as an object when you do canvas.getObjects(), so it is not yet "registered" as an object.
  • It is removed as soon as another path is created, or any selection action is performed on the canvas.
@technotablet
Copy link
Author

Is there a workaround where I can refresh the canvas after mouse up? The statement
canvas.requestRenderAll()
doesn't seem to help. Thank you for any suggestions.

@asturur
Copy link
Member

asturur commented Sep 27, 2019

ok definitely a bug, a weird bug.

@asturur asturur added the bug label Sep 27, 2019
@alexkonst
Copy link

I think PR #5866 fix this issue.

@technotablet
Copy link
Author

technotablet commented Sep 27, 2019

Thanks, @alexkonst. I just tried it out, and this minor change made a significant difference! Thank you! I guess as @asturur mentioned in the PR, once he's is confident about this change, then we might see it in an upcoming release.

Edit: There is one case related to touch events where I think it still gives trouble. I'll prepare a suitable fiddle and share.

@asturur
Copy link
Member

asturur commented Oct 14, 2019

sorry for letting this behind, i ll be back to it as soon as possible

@asturur
Copy link
Member

asturur commented Nov 18, 2019

fixed with #5866

@asturur asturur closed this as completed Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants