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

mouse scaling bug #2177

Closed
sapics opened this issue May 7, 2015 · 3 comments · Fixed by #2178
Closed

mouse scaling bug #2177

sapics opened this issue May 7, 2015 · 3 comments · Fixed by #2178
Labels
Milestone

Comments

@sapics
Copy link
Contributor

sapics commented May 7, 2015

A scaling by mouse might have a bug.

The scaled size of Line is twice larger than a expected size. The strokeWidth of object might cause this size difference.

http://jsfiddle.net/sapics/tt5zjjot/1/

ezgif com-gif-maker 1

@asturur
Copy link
Member

asturur commented May 7, 2015

Have a little bit patience with this...

height is not defined in currentTransform... intentional or problem?
Width is defined bad. I think that strokewidth should be considered here. With particular attention to lines ( horizontal and vertical limit case ).

      this._currentTransform = {
        target: target,
        action: action,
        scaleX: target.scaleX,
        scaleY: target.scaleY,
        offsetX: pointer.x - target.left,
        offsetY: pointer.y - target.top,
        originX: origin.x,
        originY: origin.y,
        ex: pointer.x,
        ey: pointer.y,
        left: target.left,
        top: target.top,
        theta: degreesToRadians(target.angle),
        width: target.width * target.scaleX,
        mouseXSign: 1,
        mouseYSign: 1
      };

Past this in kitchensink execute tab to see even stranger behaviour in both horizontal and vertical scaling.

// clear canvas
canvas.clear();

// add red rectangle
canvas.add(new fabric.Line([100,100,100,200],{
      fill: 'red',
      stroke: 'red',
      strokeWidth: 500,
    }));


@asturur asturur added the bug label May 7, 2015
@sapics
Copy link
Contributor Author

sapics commented May 7, 2015

kitchensink code is much stranger!!
kitchensink use other build version of fabric.js?

As you noticed, width and height in currentTransform looks strange.

By the way, newScaleX is calculated in _setObjectScale at canva.class.js, as
transform.newScaleX = localMouse.x / (target.width + strokeWidth / 2);
If localMouse.x has analogy with size of width, I guess that newScaleX should be calculated as,
transform.newScaleX = localMouse.x / (target.width + strokeWidth);
Dose localMouse.x have analogy with size of width?

@asturur
Copy link
Member

asturur commented May 7, 2015

is stranger because i crafted code intentionally to make the bug bigger.

it needs a coherent check with ongoing and planned change :/

@asturur asturur added this to the 1.5.1 milestone May 8, 2015
kangax added a commit that referenced this issue May 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants