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

How come Laser requires re-render but Eraser doesn't? #199

Open
pihart opened this issue Jun 19, 2021 · 1 comment
Open

How come Laser requires re-render but Eraser doesn't? #199

pihart opened this issue Jun 19, 2021 · 1 comment
Labels
question Further information is requested

Comments

@pihart
Copy link
Collaborator

pihart commented Jun 19, 2021

qboard/src/lib/tools.ts

Lines 197 to 203 in fe6fdc3

export class Laser extends Brush {
pathCreated = (e: PathEvent): void => {
setTimeout(() => {
this.baseCanvas.remove(e.path);
this.baseCanvas.requestRenderAll();
}, 1000);
};

qboard/src/lib/tools.ts

Lines 163 to 173 in fe6fdc3

export class Eraser extends Brush {
pathCreated = (e: PathEvent): void => {
const path = fabric.util.object.clone(e.path);
this.baseCanvas.remove(e.path);
const objects = this.baseCanvas
.getObjects()
.filter((object) => object.intersectsWithObject(path));
if (!objects.length) return;
this.baseCanvas.remove(...objects);
this.history.remove(objects);
};

Is it because Eraser path operations are done immediately after creating the stroke, so that the render happens slightly after the invocation of the function? If so, is this guaranteed by fabric (I doubt it) or just lucky?

(Replacing Eraser with Pen in this question also raises a valid question, but the answer to that question is that you don't do anything worthy of re-render.)

@pihart pihart added the question Further information is requested label Jun 19, 2021
@cjquines
Copy link
Owner

i dunno

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants