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

Set OriginX and OriginY makes object Unselectable #4677

Closed
samael205 opened this issue Feb 5, 2018 · 8 comments · Fixed by #4703
Closed

Set OriginX and OriginY makes object Unselectable #4677

samael205 opened this issue Feb 5, 2018 · 8 comments · Fixed by #4703
Labels

Comments

@samael205
Copy link

Version

2.0

Test Case

https://jsfiddle.net/samael205/j6w7jkgz/

Steps to reproduce

Clic on the square of checkboxes to change the rotation Origin

Expected Behavior

The rotation Origin changes, and we can manipulate he object correctly

Actual Behavior

The object cant be manipulated when we change the rotation Origin

@samael205
Copy link
Author

I am a bit Confused about this
I had a functionality in which I changed the "rotation point" to the scaling handles

@jilster
Copy link

jilster commented Feb 5, 2018

Changing the origin of an object impacts it's position. Because of that it seems like the object is unselectable, but in reality it is selectable, but you got to click on another position then expected. To fix this, you can:

  • Get the original position of the object
  • Change the origin
  • Fix the position

Also, i saw that you misspelled 'right' and 'bottom' in a few places, that's breaking as well

Example:

$("#checkboxOneInput").on('change', function(){
  if(canvas.getActiveObject()){
    var obj = canvas.getActiveObject();
    var point = obj.getPointByOrigin(obj.originX, objoriginY);
    obj.set('originX', 'left');
    obj.set('originY', 'top');
    obj.setPositionByOrigin(point, obj.originX, obj.originY);
    obj.setCoords();
    canvas.renderAll();
  }
});

@samael205
Copy link
Author

I reopen the issue, At Andrea's request

@samael205 samael205 reopened this Feb 5, 2018
@asturur
Copy link
Member

asturur commented Feb 5, 2018

so the rotation could change, if centeredRotation would be set to false.
But the unselectability, after a setCoord, is a bug.

@asturur asturur added the bug label Feb 5, 2018
@jilster
Copy link

jilster commented Feb 5, 2018

My changes made it work though, so does this mean it's only a bug if the position isn't changed before setCoords() ?

@asturur
Copy link
Member

asturur commented Feb 5, 2018

Well you change position top and left, and call setCoords.
The bug is that without changing top and left, calling setCoords should fix selectability.
The problem probably comes from my calcTransformMatrix memoization, that does not take in account originX and originY

@asturur
Copy link
Member

asturur commented Feb 5, 2018

transformMatrixKey: function(skipGroup) {
      var sep = '_', prefix = '';
      if (!skipGroup && this.group) {
        prefix = this.group.transformMatrixKey(skipGroup) + sep;
      };
      return prefix + this.top + sep + this.left + sep + this.scaleX + sep + this.scaleY +
        sep + this.skewX + sep + this.skewY + sep + this.angle +
        sep + this.width + sep + this.height + sep + this.strokeWidth + this.flipX + this.flipY;
    },

in this key i use for caching, originX and originY are missing.

@samael205
Copy link
Author

Thanks @asturur, your fix works fine!

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