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

Custom anchor point #108

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
652f63e
add ability to specify custom rotation anchor point
druzinis Apr 19, 2017
f50bac9
Safe removal of rotation handlers
eeroki Jun 4, 2017
f32f5a5
leaflet 1.1.0
w8r Jun 29, 2017
26e5275
fixes #26
w8r Apr 3, 2018
98b1587
1.1.1
w8r Apr 3, 2018
aa7e860
fixes #30
w8r Nov 27, 2018
cceb594
bumped dependencies
w8r Nov 27, 2018
6677d2c
fixes #36
w8r Nov 27, 2018
8b81e25
closes #24
w8r Nov 27, 2018
4796401
v1.1.2
w8r Nov 27, 2018
97971d6
ensure handlers are set
lc-spxl May 11, 2019
f305190
`L.Util.merge` fixes #57
w8r Jan 3, 2020
1b8eef1
Bump lodash from 4.17.11 to 4.17.15
dependabot[bot] Jan 3, 2020
773fc0b
Bump ecstatic from 3.3.0 to 3.3.2
dependabot[bot] Jan 3, 2020
d03ec6c
Bump js-yaml from 3.12.0 to 3.13.1
dependabot[bot] Jan 3, 2020
59be35c
Bump eslint-utils from 1.3.1 to 1.4.3
dependabot[bot] Jan 3, 2020
49fb145
Bump mixin-deep from 1.3.1 to 1.3.2
dependabot[bot] Jan 3, 2020
a595334
v1.1.3
w8r Jan 3, 2020
9855374
Remove references to image files that don't exist
Jan 3, 2020
e2fe7e0
Bump acorn from 6.0.4 to 6.4.1
dependabot[bot] Mar 13, 2020
5c99c4a
Update circle radius after scale (#46)
muka Mar 20, 2020
05c5900
Bump http-proxy from 1.17.0 to 1.18.1 (#75)
dependabot[bot] Oct 12, 2020
356b596
Bump elliptic from 6.5.2 to 6.5.3 (#74)
dependabot[bot] Oct 12, 2020
0198981
Bump lodash from 4.17.15 to 4.17.19 (#73)
dependabot[bot] Oct 12, 2020
ba74979
Bump path-parse from 1.0.6 to 1.0.7 (#80)
dependabot[bot] Aug 10, 2021
71312ca
Bump follow-redirects from 1.5.10 to 1.14.8 (#88)
dependabot[bot] Feb 12, 2022
df258a1
Bump tar from 4.4.13 to 4.4.19 (#90)
dependabot[bot] Feb 12, 2022
ac1d3a9
Bump ini from 1.3.5 to 1.3.8 (#89)
dependabot[bot] Feb 12, 2022
a81a0d8
Bump ajv from 6.5.5 to 6.12.6 (#87)
dependabot[bot] Jun 15, 2022
c0b3ec7
Bump cached-path-relative from 1.0.2 to 1.1.0 (#83)
dependabot[bot] Jun 15, 2022
4ebfaec
Bump lodash from 4.17.19 to 4.17.21 (#78)
dependabot[bot] Jun 15, 2022
180427f
Bump elliptic from 6.5.3 to 6.5.4 (#76)
dependabot[bot] Jun 15, 2022
ac2415e
support leaflet 1.8 (#94)
ammd1313 Jul 12, 2022
8539fb3
1.8.0 (#95)
w8r Jul 12, 2022
3d06b1f
Bump shell-quote from 1.7.2 to 1.7.3 (#93)
dependabot[bot] Jul 12, 2022
2bece9c
Added gh actions (#96)
w8r Jul 12, 2022
618637f
1.8.0-beta.3
w8r Jul 12, 2022
7b76679
New lockfile
w8r Jan 5, 2023
5c93f3c
Bump minimist, mkdirp and http-server (#106)
dependabot[bot] Jan 5, 2023
955f7de
Bump ansi-regex from 3.0.0 to 3.0.1 (#105)
dependabot[bot] Jan 5, 2023
84e16c4
Bump minimatch from 3.0.4 to 3.1.2 (#104)
dependabot[bot] Jan 5, 2023
fdec529
Bump decode-uri-component from 0.2.0 to 0.2.2 (#101)
dependabot[bot] Jan 5, 2023
ad0b55e
Prevents handlers from becoming inaccessible when covered by another …
strfx Jan 5, 2023
11d0223
1.8.0
w8r Jan 5, 2023
40e952e
1.8.0-beta.4
w8r Jan 5, 2023
b653f76
Merge branch 'master' into druzinis-master
w8r Feb 28, 2023
05c5eac
Removing built code
w8r Feb 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions src/Path.Transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ L.PathTransform.RotateHandle = L.PathTransform.Handle.extend({
L.Handler.PathTransform = L.Handler.extend({
options: {
rotation: true,
rotationAnchor: null,
scaling: true,
uniformScaling: true,
maxZoom: 22,
Expand Down Expand Up @@ -360,12 +361,29 @@ L.Handler.PathTransform = L.Handler.extend({
this._path._transform(null);
this._rect._transform(null);

this._transformPoints(this._path);
this._transformPoints(this._rect);

if (this.options.rotation) {
this._handleLine._transform(null);
this._transformPoints(this._handleLine, this._angle, null, this._origin);
this._transformPoints(
this._path,
this._angle,
null,
this.options.rotationAnchor
);
this._transformPoints(
this._rect,
this._angle,
null,
this.options.rotationAnchor
);
this._transformPoints(
this._handleLine,
this._angle,
null,
this.options.rotationAnchor
);
} else {
this._transformPoints(this._path);
this._transformPoints(this._rect);
}
},

Expand Down Expand Up @@ -506,7 +524,9 @@ L.Handler.PathTransform = L.Handler.extend({

// move handlers to the top of all other layers; prevents handlers from
// being blocked by other layers
this._handlersGroup.getLayers().forEach(function(layer) { layer.bringToFront(); });
this._handlersGroup.getLayers().forEach(function (layer) {
layer.bringToFront();
});
},

/**
Expand Down Expand Up @@ -558,6 +578,14 @@ L.Handler.PathTransform = L.Handler.extend({
* @return {L.LatLng}
*/
_getRotationOrigin: function () {
if (this.options.rotationAnchor) {
var anchor = this.options.rotationAnchor;
if (Array.isArray(anchor) && anchor.length >= 2) {
return new L.LatLng(anchor[0], anchor[1]);
} else if (anchor instanceof L.LatLng) {
return anchor;
}
}
var latlngs = this._rect._latlngs[0];
var lb = latlngs[0];
var rt = latlngs[2];
Expand Down