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

Create additional separate Scale and Rotate tools for use in downstream UIs #112

Closed
jywarren opened this issue Oct 21, 2018 · 2 comments
Closed

Comments

@jywarren
Copy link
Member

jywarren commented Oct 21, 2018

Projects described in #105 need separate tools for scale and rotate. We can copy out sections of the combined Scale/Rotate to make independent parts.

rotation/scale were split into separate actions in this diff from @ChrisLowe-Takor (Also see this line

Here is the full diff; it's not too complex: https://gist.github.com/jywarren/59f0cb0baec03bee99540ac2af2ecf70/revisions?diff=split#diff-d592453497ece2dffbf1a19cb06db126

There's new code for a "scale" handle here:

https://gist.github.com/jywarren/59f0cb0baec03bee99540ac2af2ecf70/revisions?diff=split#diff-d592453497ece2dffbf1a19cb06db126R308

We don't need to include these new tools in the Toolbar because @ChrisLowe-Takor doesn't use the Toolbar in his implementation. So we just need a new handle in a file here, called ScaleHandle.js:

https://github.com/publiclab/Leaflet.DistortableImage/tree/master/src/edit

And we should rename RotateHandle.js to RotateAndScaleHandle.js and preserve the original version there too. Then we can hook up our new handles like is done here:

this._rotateHandles = new L.LayerGroup();

Later we could make things less redundant by sharing some utility functions. But let's not worry about that now.

So to be clear, we'll end with three handles:

  1. the original RotateHandle.js renamed to RotateAndScaleHandle.js
  2. the new RotateHandle.js which ONLY rotates (as per the diff-modified version above)
  3. the new ScaleHandle.js which ONLY scales (as per the diff-modified version above)

And matching code in /src/edit/DistortableImage.Edit.js to connect them all up.

The Toolbar code will probably need to be modified to link only to RotateAndScaleHandle

Finally, this will take some chasing around the codebase to ensure the new files are included in Grunt, and all references to RotateHandle are updated to RotateAndScaleHandle:

https://github.com/publiclab/Leaflet.DistortableImage/search?q=rotate&unscoped_q=rotate

This is a bit more complex, and tests will have to be updated, but we can do this step by step and I'm happy to help out if anyone wants to take on this project!

@jywarren
Copy link
Member Author

jywarren commented Feb 17, 2019 via email

@jywarren
Copy link
Member Author

Solved!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant