Skip to content

Refactor: Use offsetX and offsetY #4

@oixel

Description

@oixel

Instead of having to subtract by a custom variable, you can use offsetX and offsetY from the window element to grab the mouse's position in relation to the canvas. "But that would cause errors whenever the mouse exits the canvas!" Actually, there is already a boolean tracking whether the mouse is hovering over the canvas. It's called isHovering. Simply only draw / append to currentStroke if isHovering === true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorA suggestion that could improve the code base

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions