diff --git a/.gitignore b/.gitignore index a2cea087..4cf4afab 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,9 @@ bin/* .project */.project +.idea +*/.idea + node_modules/ package-lock.json diff --git a/BlueMapCore/src/main/webroot/js/libs/BlueMap.js b/BlueMapCore/src/main/webroot/js/libs/BlueMap.js index 552417c8..97176aed 100644 --- a/BlueMapCore/src/main/webroot/js/libs/BlueMap.js +++ b/BlueMapCore/src/main/webroot/js/libs/BlueMap.js @@ -205,7 +205,9 @@ export default class BlueMap { setTimeout(this.update, 1000); this.lowresTileManager.setPosition(this.controls.targetPosition); - this.hiresTileManager.setPosition(this.controls.targetPosition); + if (this.camera.position.y < 400) { + this.hiresTileManager.setPosition(this.controls.targetPosition); + } this.locationHash = '#' + this.map @@ -239,7 +241,7 @@ export default class BlueMap { this.renderer.clearDepth(); this.renderer.render(this.hiresScene, this.camera, this.renderer.getRenderTarget(), false); } - } + }; handleContainerResize = () => { this.camera.aspect = this.element.clientWidth / this.element.clientHeight; @@ -254,7 +256,7 @@ export default class BlueMap { .css('height', this.element.clientHeight); this.updateFrame = true; - } + }; async loadSettings() { return new Promise(resolve => { @@ -455,20 +457,29 @@ export default class BlueMap { // ###### UI ###### - alert(content) { + toggleAlert(id, content) { let alertBox = $('#alert-box'); if (alertBox.length === 0){ alertBox = $('
').appendTo(this.element); } let displayAlert = () => { - let alert = $(` `).appendTo(alertBox); + let alert = $(` `).appendTo(alertBox); alert.find('.alert-close-button').click(() => { alert.fadeOut(200, () => alert.remove()); }); alert.fadeIn(200); }; + let sameAlert = alertBox.find(`.alert[data-alert-id=${id}]`); + if (sameAlert.length > 0){ + alertBox.fadeOut(200, () => { + alertBox.html(''); + alertBox.show(); + }); + return; + } + let oldAlerts = alertBox.find('.alert'); if (oldAlerts.length > 0){ alertBox.fadeOut(200, () => { @@ -476,8 +487,9 @@ export default class BlueMap { alertBox.show(); displayAlert(); }); - } else { - displayAlert(); + return; } + + displayAlert(); } } diff --git a/BlueMapCore/src/main/webroot/js/libs/Controls.js b/BlueMapCore/src/main/webroot/js/libs/Controls.js index 6705af6a..49609440 100644 --- a/BlueMapCore/src/main/webroot/js/libs/Controls.js +++ b/BlueMapCore/src/main/webroot/js/libs/Controls.js @@ -103,7 +103,7 @@ export default class Controls { }, false); window.addEventListener('mousemove', this.onMouseMove, false); canvas.addEventListener('mousedown', this.onMouseDown, false); - canvas.addEventListener('mouseup', this.onMouseUp, false); + window.addEventListener('mouseup', this.onMouseUp, false); //this is on the window instead of the canvas, so if we drag out of the canvas and release the mouse it actually gets released canvas.addEventListener('wheel', this.onMouseWheel, { passive: true }); window.addEventListener('keydown', this.onKeyDown, false); window.addEventListener('keyup', this.onKeyUp, false); @@ -197,7 +197,7 @@ export default class Controls { this.minHeight = intersects[0].point.y; } } - }; + } updateMouseMoves = () => { this.deltaMouse.set(this.lastMouse.x - this.mouse.x, this.lastMouse.y - this.mouse.y); @@ -249,7 +249,7 @@ export default class Controls { if (this.targetDistance < this.settings.zoom.min) this.targetDistance = this.settings.zoom.min; if (this.targetDistance > this.settings.zoom.max) this.targetDistance = this.settings.zoom.max; - } + }; onMouseMove = event => { this.mouse.set(event.clientX, event.clientY); @@ -257,11 +257,13 @@ export default class Controls { if (this.state !== Controls.STATES.NONE){ event.preventDefault(); } - } + }; onMouseDown = event => { if (this.state !== Controls.STATES.NONE) return; + $(":focus").blur(); + switch (event.button) { case Controls.KEYS.MOVE : this.state = Controls.STATES.MOVE; @@ -272,7 +274,7 @@ export default class Controls { event.preventDefault(); break; } - } + }; onMouseUp = event => { if (this.state === Controls.STATES.NONE) return; @@ -285,13 +287,13 @@ export default class Controls { if (this.state === Controls.STATES.ORBIT) this.state = Controls.STATES.NONE; break; } - } + }; onKeyDown = event => { this.keyStates[event.keyCode] = true; - } + }; onKeyUp = event => { this.keyStates[event.keyCode] = false; - } + }; } diff --git a/BlueMapCore/src/main/webroot/js/libs/modules/Compass.js b/BlueMapCore/src/main/webroot/js/libs/modules/Compass.js index 4121be0c..02b3e099 100644 --- a/BlueMapCore/src/main/webroot/js/libs/modules/Compass.js +++ b/BlueMapCore/src/main/webroot/js/libs/modules/Compass.js @@ -42,12 +42,12 @@ export default class Compass { onBlueMapUpdateFrame = () => { this.needle.css('transform', `rotate(${this.blueMap.controls.direction}rad)`); - } + }; onClick = () => { this.blueMap.controls.targetDirection = 0; this.blueMap.controls.direction = this.blueMap.controls.direction % (Math.PI * 2); if (this.blueMap.controls.direction < -Math.PI) this.blueMap.controls.direction += Math.PI * 2; if (this.blueMap.controls.direction > Math.PI) this.blueMap.controls.direction -= Math.PI * 2; - } + }; } diff --git a/BlueMapCore/src/main/webroot/js/libs/modules/Info.js b/BlueMapCore/src/main/webroot/js/libs/modules/Info.js index b380d866..ae3fb6b1 100644 --- a/BlueMapCore/src/main/webroot/js/libs/modules/Info.js +++ b/BlueMapCore/src/main/webroot/js/libs/modules/Info.js @@ -36,7 +36,7 @@ export default class Info { } onClick = () => { - this.blueMap.alert( + this.blueMap.toggleAlert('bluemap-info', '