Skip to content

Commit

Permalink
fix: make it so resizeable no longer requires draggable to be true to…
Browse files Browse the repository at this point in the history
… work (#213)
  • Loading branch information
JamesLMilner authored Mar 7, 2024
1 parent 2cb6fc3 commit 9bb227c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions guides/4.MODES.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ const selectMode = new TerraDrawSelectMode({
// Can be moved
draggable: true,

// [Requires draggable to be true] allow resizing of the geometry from
// a given origin. Center fixed will allow resizing on fixed aspect ratio from the center
// Allow resizing of the geometry from a given origin.
// center-fixed will allow resizing on fixed aspect ratio from the center
// and opposite-fixed allows resizing from the opposite corner of the bounding box
// of the geometry. Defaults to geodesic transforms, unless planar options are used.
resizeable: 'center-fixed', // can also be 'opposite-fixed', 'opposite-planar', 'center', 'center-planar'
// of the geometry. Defaults to geodesic transforms, unless planar options are
// used such as center-planar or opposite-planar. Will take priority over draggable
// if set to a value.
resizeable: 'opposite-planar', // can also be 'opposite-fixed', 'opposite-planar', 'center', 'center-planar'

// Can be deleted
deletable: true,
Expand Down
4 changes: 2 additions & 2 deletions src/modes/select/select.mode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2985,12 +2985,12 @@ describe("TerraDrawSelectMode", () => {
expect(onFinish).toBeCalledWith(expect.any(String));
});

it.only("fires onFinish for resizeable if it is currently being dragged", () => {
it("fires onFinish for resizeable if it is currently being dragged", () => {
setSelectMode({
flags: {
polygon: {
feature: {
coordinates: { draggable: true, resizable: "center-fixed" },
coordinates: { resizable: "center-fixed" },
},
},
},
Expand Down
4 changes: 3 additions & 1 deletion src/modes/select/select.mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,9 @@ export class TerraDrawSelectMode extends TerraDrawBaseSelectMode<SelectionStylin
modeFlags.feature &&
(modeFlags.feature.draggable ||
(modeFlags.feature.coordinates &&
modeFlags.feature.coordinates.draggable));
modeFlags.feature.coordinates.draggable) ||
(modeFlags.feature.coordinates &&
modeFlags.feature.coordinates.resizable));

if (!draggable) {
return;
Expand Down

0 comments on commit 9bb227c

Please sign in to comment.