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

When user drags inactive object, make sure he won't scale it instead #1570

Closed
wants to merge 1 commit into from

Conversation

pjanik
Copy link

@pjanik pjanik commented Aug 6, 2014

To replicate the issue using current release of FabricJS:

  1. Open http://fabricjs.com/.
  2. Move your mouse pointer exactly to the corner of a red rectangle.
  3. Do not select the rectangle, note that 'move' cursor is visible.
  4. Drag the rectangle.

I would expect that object would be moved, but instead it's scaled, as exactly under the mouse pointer there is a control point (invisible at the beginning, until the object is selected).

The problem seems to be here:
https://github.com/kangax/fabric.js/blob/818ab118b30a9205a0e57620452b08bb8f5f18cc/src/mixins/canvas_events.mixin.js#L414-L415

_findTargetCorner checks whether the target is active (what makes sense). It's called twice, once in _beforeTransform and the second time in _setupCurrentTransform. However the target is activated in the meantime, in _beforeTransform. So the second call to _findTargetCorner actually returns corner and scaling is being activated. I've just moved target activation out of _beforeTransform and it seems to fix the problem for me. These functions are used only in this context, so hopefully it's not a risky change.

Regards,
Piotr

@pjanik
Copy link
Author

pjanik commented Sep 19, 2014

Hi, any comments? Should I create an issue first to discuss that?
Basically the issue doesn't seem to be very significant, but also the fix is pretty simple.

The problem is especially annoying when you try to move around small shapes.

@asturur
Copy link
Member

asturur commented Sep 20, 2014

i pulled it and try it and looks fine for me.
I mean, you just moved some line of codes and fixed this strange behaviour.
Nice and not dangerous.

@asturur
Copy link
Member

asturur commented Sep 22, 2014

@kangax can you look at this? it looks harmless and solve that accidental resizing.

@kangax
Copy link
Member

kangax commented Sep 22, 2014

@asturur are you able to replicate the original issue (as described by @pjanik)?

@asturur
Copy link
Member

asturur commented Sep 22, 2014

Absolutely yes.
I I remember this problem was bothering me also this summer when i was doing various test, i wanted to drag and i always scaled :)

@kangax
Copy link
Member

kangax commented Sep 22, 2014

I suppose we can "fix" it although I'm not sure it's exactly the right behavior. If someone wanted to scale an object (after we merge this) they would need to first select it. So it's kind of a matter of whether we want to prioritize movement over scaling. Right now an object can be scaled by the corner even if it's not selected.

@asturur
Copy link
Member

asturur commented Sep 22, 2014

oh ok, if it is a feature ok.
So at leat the cursor icon has to be fixed, if you are on corner get reisize icon and not drag icon.

I also noticed some strange behaviour, like if you take the vertical resize corner, and you drag left, as soon as you overcome the left side, you flip the object. If you drag right you do not flip.

@jeffparsons
Copy link
Contributor

If you don't mind comments from the peanut gallery...

When I encountered this behaviour I also assumed it was a bug. Given that I can't see the resize handles before selecting the object, I would never intend to resize an object when dragging from that place. I also agree with @pjanik regarding manipulation of small objects.

Familiarity is another concern. I'm not aware of any other editor that lets you resize an object without selecting it first, unless using a special "resize" tool where it's obvious that this is the only action you could mean.

Just my €0.02!

@KJTsanaktsidis
Copy link
Contributor

I agree with @pjanik; I would find it surprising if I could resize an object that I had not selected.

@pjanik
Copy link
Author

pjanik commented Mar 2, 2015

Yeap, I still feel the same after couple of months... This can be considered as a matter of taste though.

But the fact that I can't move small object (as I always resize it instead) is an obvious problem / bug to me and it's pretty annoying in practice.

@asturur
Copy link
Member

asturur commented Apr 25, 2016

I was thinking again about this, i'm sure @pjanik is right.
An object that is smaller than twice the size of control is never draggabale.
And this is not normal - right.

@asturur
Copy link
Member

asturur commented Apr 26, 2016

replaced by #2907

@asturur asturur closed this Apr 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants