Skip to content

Commit 980e6ec

Browse files
committed
Set constrain in clone (not apply)
Only set if the transform's constrain differs from its defaultConstrain
1 parent 9974452 commit 980e6ec

File tree

5 files changed

+3
-5
lines changed

5 files changed

+3
-5
lines changed

src/geo/projection/globe_transform.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ export class GlobeTransform implements ITransform {
265265

266266
clone(): ITransform {
267267
const clone = new GlobeTransform();
268+
if (this.constrain !== this.defaultConstrain) clone.setConstrain(this.constrain);
268269
clone._globeness = this._globeness;
269270
clone._globeLatitudeErrorCorrectionRadians = this._globeLatitudeErrorCorrectionRadians;
270271
clone.apply(this);

src/geo/projection/mercator_transform.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ export class MercatorTransform implements ITransform {
253253

254254
public clone(): ITransform {
255255
const clone = new MercatorTransform();
256+
if (this.constrain !== this.defaultConstrain) clone.setConstrain(this.constrain);
256257
clone.apply(this);
257258
return clone;
258259
}

src/geo/projection/vertical_perspective_transform.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ export class VerticalPerspectiveTransform implements ITransform {
268268

269269
clone(): ITransform {
270270
const clone = new VerticalPerspectiveTransform();
271+
if (this.constrain !== this.defaultConstrain) clone.setConstrain(this.constrain);
271272
clone.apply(this);
272273
return clone;
273274
}

src/geo/transform_helper.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ const emptyCallbacks = {
1414
describe('TransformHelper', () => {
1515
test('apply', () => {
1616
const original = new TransformHelper(emptyCallbacks);
17-
original.setConstrain((lngLat, zoom) => {
18-
return {center: lngLat, zoom: zoom ?? 0};
19-
});
2017
original.setBearing(12);
2118
original.setCenter(new LngLat(3, 4));
2219
original.setElevation(5);
@@ -42,7 +39,6 @@ describe('TransformHelper', () => {
4239
cloned.apply(original);
4340

4441
// Check all getters from the ITransformGetters interface
45-
expect(cloned.constrain).toEqual(original.constrain);
4642
expect(cloned.tileSize).toEqual(original.tileSize);
4743
expect(cloned.tileZoom).toEqual(original.tileZoom);
4844
expect(cloned.scale).toEqual(original.scale);

src/geo/transform_helper.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ export class TransformHelper implements ITransformGetters {
185185
}
186186

187187
public apply(thatI: ITransformGetters, constrain?: boolean, forceOverrideZ?: boolean): void {
188-
this._constrain = thatI.constrain;
189188
this._latRange = thatI.latRange;
190189
this._lngRange = thatI.lngRange;
191190
this._width = thatI.width;

0 commit comments

Comments
 (0)