Avoid unnecessary dom updates for player markers

This commit is contained in:
James Lyne 2021-01-05 23:48:56 +00:00
parent ac2dd1f399
commit 3573694df0

View File

@ -56,6 +56,8 @@ export class PlayerIcon extends DivIcon {
private _playerInfo?: HTMLSpanElement; private _playerInfo?: HTMLSpanElement;
private _playerName?: HTMLSpanElement; private _playerName?: HTMLSpanElement;
private _currentName?: string;
private _playerHealth?: HTMLDivElement; private _playerHealth?: HTMLDivElement;
private _playerHealthBar?: HTMLDivElement; private _playerHealthBar?: HTMLDivElement;
private _playerArmor?: HTMLDivElement; private _playerArmor?: HTMLDivElement;
@ -148,7 +150,9 @@ export class PlayerIcon extends DivIcon {
return; 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.options.showHealth) {
if (this._player.health !== undefined && this._player.armor !== undefined) { if (this._player.health !== undefined && this._player.armor !== undefined) {