diff --git a/src/index.d.ts b/src/index.d.ts
index 77fa6c8..c2613b2 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -1,4 +1,12 @@
declare module '*.svg' {
const content: any;
export default content;
+}
+
+interface BrowserSpriteSymbol {
+ id: string;
+ viewBox: string;
+ content: string;
+ node: SVGSymbolElement;
+ url: string;
}
\ No newline at end of file
diff --git a/src/leaflet/control/ClockControl.ts b/src/leaflet/control/ClockControl.ts
index 94712af..5ce0603 100644
--- a/src/leaflet/control/ClockControl.ts
+++ b/src/leaflet/control/ClockControl.ts
@@ -42,6 +42,8 @@ export class ClockControl extends Control {
private _sun?: HTMLElement;
private _moon?: HTMLElement;
private _clock?: HTMLElement;
+ private _currentMoonIcon?: BrowserSpriteSymbol;
+ private _currentSunIcon?: BrowserSpriteSymbol;
constructor(options: ClockControlOptions) {
super(Object.assign(options, {position: 'topcenter'}));
@@ -122,33 +124,35 @@ export class ClockControl extends Control {
if (this.options.showWeather) {
if (worldState.thundering) {
- this._sun!.innerHTML = `
- `;
- this._moon!.innerHTML = `
- `;
+ this._setSunIcon(sunStorm);
+ this._setMoonIcon(moonStorm);
} else if (worldState.raining) {
- this._sun!.innerHTML = `
- `;
- this._moon!.innerHTML = `
- `;
+ this._setSunIcon(sunRain);
+ this._setMoonIcon(moonRain);
} else {
- this._sun!.innerHTML = `
- `;
- this._moon!.innerHTML = `
- `;
+ this._setSunIcon(sun);
+ this._setMoonIcon(moon);
}
}
}
+
+ _setSunIcon(icon: BrowserSpriteSymbol) {
+ if(this._sun && this._currentSunIcon !== icon) {
+ this._sun!.innerHTML = `
+ `;
+ this._currentSunIcon = icon;
+ }
+ }
+
+ _setMoonIcon(icon: BrowserSpriteSymbol) {
+ if(this._moon && this._currentMoonIcon !== icon) {
+ this._moon!.innerHTML = `
+ `;
+ this._currentMoonIcon = icon;
+ }
+ }
}
\ No newline at end of file