From 3573694df0e64348c120cc75b4c1a3313836554f Mon Sep 17 00:00:00 2001 From: James Lyne Date: Tue, 5 Jan 2021 23:48:56 +0000 Subject: [PATCH] Avoid unnecessary dom updates for player markers --- src/leaflet/icon/PlayerIcon.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/leaflet/icon/PlayerIcon.ts b/src/leaflet/icon/PlayerIcon.ts index 38da1e5..35d8559 100644 --- a/src/leaflet/icon/PlayerIcon.ts +++ b/src/leaflet/icon/PlayerIcon.ts @@ -56,6 +56,8 @@ export class PlayerIcon extends DivIcon { private _playerInfo?: HTMLSpanElement; private _playerName?: HTMLSpanElement; + private _currentName?: string; + private _playerHealth?: HTMLDivElement; private _playerHealthBar?: HTMLDivElement; private _playerArmor?: HTMLDivElement; @@ -148,7 +150,9 @@ export class PlayerIcon extends DivIcon { return; } - this._playerName!.innerHTML = this._player!.name; + if(this._player!.name !== this._currentName) { + this._playerName!.innerHTML = this._currentName = this._player!.name; + } if(this.options.showHealth) { if (this._player.health !== undefined && this._player.armor !== undefined) {