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

Behaviour when clicking canvas without moving mouse in shapes mode #144

Closed
jonaspu opened this issue Feb 7, 2019 · 0 comments
Closed

Behaviour when clicking canvas without moving mouse in shapes mode #144

jonaspu opened this issue Feb 7, 2019 · 0 comments
Assignees
Labels
Milestone

Comments

@jonaspu
Copy link

jonaspu commented Feb 7, 2019

Version

3.4.0

Development Environment

Tested on Firefox, Google Chrome

Current Behavior

  1. Choose any shape (Rectangle, Circle, Triangle).
  2. Click on canvas without moving mouse, release mouse button.
  3. The shape's second corner now follows the cursor without the mouse button being pressed.
  4. Clicking on the canvas again, the shape is added but there is also a new shape with the first corner already set.

Image with the clicks marked:

image

Expected Behavior

Click and release at the same spot should not add anything.

Possible fix

In src/js/component/shape.js replace

_onFabricMouseUp() {
    const canvas = this.getCanvas();
    const shape = this._shapeObj;

    if (shape) {
        resizeHelper.adjustOriginToCenter(shape);
    }

    this.fire(eventNames.ADD_OBJECT_AFTER, this.graphics.createObjectProperties(shape));

    canvas.off({
        'mouse:move': this._handlers.mousemove,
        'mouse:up': this._handlers.mouseup
    });
}

with

_onFabricMouseUp() {
    const canvas = this.getCanvas();
    const shape = this._shapeObj;

    if (shape) {
        resizeHelper.adjustOriginToCenter(shape);
        this.fire(eventNames.ADD_OBJECT_AFTER, this.graphics.createObjectProperties(shape));
    }

    canvas.off({
        'mouse:move': this._handlers.mousemove,
        'mouse:up': this._handlers.mouseup
    });
}

This way if the mouse isn't moved nothing happens.

@junghwan-park junghwan-park self-assigned this Feb 13, 2019
@junghwan-park junghwan-park added this to the v3.5.0 milestone Feb 13, 2019
HerlinMatos pushed a commit to EveryMundo/tui.image-editor that referenced this issue Jul 2, 2020
* fix: Fire ADD_OBJECT_AFTER event in shape.add()

* fix: Add shape mouseClick without mouse moving fixes nhn#144

* refactor: Rename variable

* refactor: Move event
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

2 participants