diff --git a/src/Logic/UIEventSource.ts b/src/Logic/UIEventSource.ts index 22e2431cc..c4af67e6e 100644 --- a/src/Logic/UIEventSource.ts +++ b/src/Logic/UIEventSource.ts @@ -87,6 +87,8 @@ export class Stores { }) return newStore } + + } export abstract class Store implements Readable { @@ -347,6 +349,16 @@ export abstract class Store implements Readable { } }) } + + /** + * Create a new UIEVentSource. Whenever 'this.data' changes, the returned UIEventSource will get this value as well. + * However, this value can be overridden without affecting source + */ + public followingClone(): UIEventSource { + const src = new UIEventSource(this.data) + this.addCallback((t) => src.setData(t)) + return src + } } export class ImmutableStore extends Store { @@ -814,17 +826,6 @@ export class UIEventSource extends Store implements Writable { (b) => JSON.stringify(b) ?? "" ) } - - /** - * Create a new UIEVentSource. Whenever 'source' changes, the returned UIEventSource will get this value as well. - * However, this value can be overriden without affecting source - */ - static feedFrom(store: Store): UIEventSource { - const src = new UIEventSource(store.data) - store.addCallback((t) => src.setData(t)) - return src - } - /** * Adds a callback * diff --git a/src/Models/MapProperties.ts b/src/Models/MapProperties.ts index b5a3f1974..e4e46ba58 100644 --- a/src/Models/MapProperties.ts +++ b/src/Models/MapProperties.ts @@ -18,6 +18,9 @@ export interface MapProperties { readonly maxbounds: UIEventSource readonly allowMoving: UIEventSource readonly allowRotating: UIEventSource + /** + * Current rotation of the map, ccw in degrees + */ readonly rotation: UIEventSource readonly pitch: UIEventSource readonly lastClickLocation: Store<{ diff --git a/src/UI/BigComponents/CompassWidget.svelte b/src/UI/BigComponents/CompassWidget.svelte index 8cec2bc39..dc7e7d745 100644 --- a/src/UI/BigComponents/CompassWidget.svelte +++ b/src/UI/BigComponents/CompassWidget.svelte @@ -22,7 +22,7 @@ let compassLoaded = Orientation.singleton.gotMeasurement let allowRotation = mapProperties.allowRotating - function clicked(e: Event) { + function clicked() { if (mapProperties.rotation.data === 0) { if (mapProperties.allowRotating.data && compassLoaded.data) { mapProperties.rotation.set(orientation.data) @@ -35,9 +35,8 @@ {#if $allowRotation || $gotNonZero}