From 3960869f15ad2df45ffb8433816ba324d8a8f465 Mon Sep 17 00:00:00 2001 From: "Blue (Lukas Rieger)" Date: Mon, 17 Aug 2020 18:42:44 +0200 Subject: [PATCH] Stop following player-markers when they disappear from the map --- .../src/main/webroot/js/libs/hud/PlayerMarker.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/BlueMapCore/src/main/webroot/js/libs/hud/PlayerMarker.js b/BlueMapCore/src/main/webroot/js/libs/hud/PlayerMarker.js index b87cb262..38d189bc 100644 --- a/BlueMapCore/src/main/webroot/js/libs/hud/PlayerMarker.js +++ b/BlueMapCore/src/main/webroot/js/libs/hud/PlayerMarker.js @@ -27,7 +27,7 @@ export default class PlayerMarker extends Marker { if (!this.renderObject){ this.iconElement = $(`
${this.label}
`); this.iconElement.find("img").click(this.onClick); - $(window).on('mousedown touchstart', this.onStopFollowing); + $(window).on('mousedown touchstart', this.onUserInput); this.renderObject = new CSS2DObject(this.iconElement[0]); this.renderObject.position.copy(this.position); @@ -47,6 +47,12 @@ export default class PlayerMarker extends Marker { this.blueMap.hudScene.add(this.renderObject); } else { this.blueMap.hudScene.remove(this.renderObject); + + if (this.follow) { + this.follow = false; + this.iconElement.removeClass("following"); + this.blueMap.controls.targetPosition.y = 0; + } } } @@ -99,8 +105,8 @@ export default class PlayerMarker extends Marker { this.blueMap.controls.targetPosition.copy(this.position); }; - onStopFollowing = e => { - if (e.type !== "mousedown" || e.button === 0) { + onUserInput = e => { + if ((e.type !== "mousedown" || e.button === 0) && this.follow) { this.follow = false; this.iconElement.removeClass("following"); this.blueMap.controls.targetPosition.y = 0;