Skip to content

Commit c3b5591

Browse files
feat: reset reference by meters for predictable behavior
1 parent fd7be53 commit c3b5591

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/state/state/StateBase.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export abstract class StateBase implements IStateBase {
4141
constructor(state: IStateBase) {
4242
this._spatial = new Spatial();
4343

44-
this._referenceThreshold = 0.01;
44+
this._referenceThreshold = 300;
4545
this._transitionMode = state.transitionMode;
4646

4747
this._reference = state.reference;
@@ -312,13 +312,19 @@ export abstract class StateBase implements IStateBase {
312312
}
313313

314314
private _setReference(image: Image): boolean {
315+
const distance = this._spatial.distanceFromLngLat(
316+
image.lngLat.lng,
317+
image.lngLat.lat,
318+
this.reference.lng,
319+
this.reference.lat);
320+
315321
// do not reset reference if image is within threshold distance
316-
if (Math.abs(image.lngLat.lat - this.reference.lat) < this._referenceThreshold &&
317-
Math.abs(image.lngLat.lng - this.reference.lng) < this._referenceThreshold) {
322+
if (distance < this._referenceThreshold) {
318323
return false;
319324
}
320325

321-
// do not reset reference if previous image exist and transition is with motion
326+
// do not reset reference if previous image exist and
327+
// transition is with motion
322328
if (this._previousImage != null && !this._motionlessTransition()) {
323329
return false;
324330
}

0 commit comments

Comments
 (0)