forked from MapComplete/MapComplete
UX: tweaks to compass element
This commit is contained in:
parent
f1ced2c123
commit
88d4d00911
2 changed files with 17 additions and 6 deletions
|
|
@ -610,7 +610,6 @@ class MappedStore<TIn, T> extends Store<T> {
|
||||||
}
|
}
|
||||||
this._upstreamPingCount = this._upstreamCallbackHandler.pingCount
|
this._upstreamPingCount = this._upstreamCallbackHandler.pingCount
|
||||||
this._callbacksAreRegistered = false
|
this._callbacksAreRegistered = false
|
||||||
console.log("Unregistering from upstream", this._upstream)
|
|
||||||
this._unregisterFromUpstream()
|
this._unregisterFromUpstream()
|
||||||
this._unregisterFromExtraStores?.forEach((unr) => unr())
|
this._unregisterFromExtraStores?.forEach((unr) => unr())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,12 @@ import North_arrow from "../../assets/svg/North_arrow.svelte"
|
||||||
|
|
||||||
export let mapProperties: { rotation: UIEventSource<number>, allowRotating: Store<boolean> }
|
export let mapProperties: { rotation: UIEventSource<number>, allowRotating: Store<boolean> }
|
||||||
let orientation = Orientation.singleton.alpha
|
let orientation = Orientation.singleton.alpha
|
||||||
|
let gotNonZero = new UIEventSource(false)
|
||||||
|
orientation.addCallbackAndRunD(o => {
|
||||||
|
if (o !== undefined && o !== 0) {
|
||||||
|
gotNonZero.set(true)
|
||||||
|
}
|
||||||
|
})
|
||||||
let mapRotation = mapProperties.rotation
|
let mapRotation = mapProperties.rotation
|
||||||
export let size = "h-10 w-10"
|
export let size = "h-10 w-10"
|
||||||
let wrapperClass = "absolute top-0 left-0 " + size
|
let wrapperClass = "absolute top-0 left-0 " + size
|
||||||
|
|
@ -26,9 +32,11 @@ function clicked(e: Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
{#if $allowRotation || !$gotNonZero}
|
||||||
<button style="z-index: -1" class={"relative as-link pointer-events-auto "+size} on:click={(e) => clicked(e)}>
|
<button style="z-index: -1" class={"relative as-link pointer-events-auto "+size} on:click={(e) => clicked(e)}>
|
||||||
{#if $allowRotation && !$compassLoaded}
|
{#if $allowRotation && !$compassLoaded && !$gotNonZero}
|
||||||
<div class={"border-2 rounded-full border-gray-500 border-dotted "+wrapperClass} style={`transform: rotate(${-$mapRotation}deg); transition: transform linear 500ms`}>
|
<div class={"border-2 rounded-full border-gray-500 border-dotted "+wrapperClass}
|
||||||
|
style={`transform: rotate(${-$mapRotation}deg); transition: transform linear 500ms`}>
|
||||||
<North_arrow class="w-full" />
|
<North_arrow class="w-full" />
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
|
|
@ -37,8 +45,12 @@ function clicked(e: Event) {
|
||||||
<Compass_back class="w-full" />
|
<Compass_back class="w-full" />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class={wrapperClass} style={`transform: rotate(${-$orientation}deg)`}>
|
{#if $compassLoaded && $gotNonZero}
|
||||||
|
<div class={wrapperClass+ (!$allowRotation ? " rounded-full bg-white bg-opacity-50" : "")}
|
||||||
|
style={`transform: rotate(${-$orientation}deg)`}>
|
||||||
<Compass_needle class="w-full" />
|
<Compass_needle class="w-full" />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
|
{/if}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue