Skip to content

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

@pihart

Description

@pihart

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions