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

fixed scaleFromCenter and aspectRatio bug #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

beasteers
Copy link

the scaleFromCenter and aspectRatio flags weren't working as I expected. I thought they would be flags that changed the default behavior of the transformation, but instead it was just the initial value from the mousedown event.

To fix it, I refactored a bit. Instead of manually specifying this

scale(scaleType, {
    startX: event.pageX, 
    startY: event.pageY, 
    startFromCenter: event.altKey,
    aspectRatio: event.shiftKey,
    ...
})

you can just do this:

scale(scaleType, {
    event,
    ...
})

That allows us to utilize startFromCenter and aspectRatio for specifying their default behavior. If we set either to true, alt/shift will still toggle, just in the other direction.
For the future, another capability that might be nice would be to allow startFromCenter and aspectRatio to be locked. Currently there is enableStartFromCenter=false which would disable scale from center, but it might be nice to be able to disable scale from corner and only allow scaling from the center. An easy thought would be to use something along the lines of enableStartFromCenter=[false|null|true] for specifying [scale from corner, toggleable, scale from center], though naming that argument might be a challenge.

@codecov-io
Copy link

Codecov Report

Merging #1 into master will increase coverage by 0.64%.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master     #1      +/-   ##
========================================
+ Coverage   99.35%   100%   +0.64%     
========================================
  Files           5      5              
  Lines         156    158       +2     
  Branches       30     28       -2     
========================================
+ Hits          155    158       +3     
+ Misses          1      0       -1
Impacted Files Coverage Δ
src/scale.js 100% <100%> (+2.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2abce6...c746fda. Read the comment docs.

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.

2 participants