Skip to content

Commit a217ddf

Browse files
committed
Catch web-app error and cancel alert animations
1 parent 2c1fb0a commit a217ddf

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

BlueMapCore/src/main/webroot/js/libs/BlueMap.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,15 +475,15 @@ export default class BlueMap {
475475
let displayAlert = () => {
476476
let alert = $(`<div class="alert box" data-alert-id="${id}" style="display: none;"><div class="alert-close-button"></div>${content}</div>`).appendTo(alertBox);
477477
alert.find('.alert-close-button').click(() => {
478-
alert.fadeOut(200, () => alert.remove());
478+
alert.stop().fadeOut(200, () => alert.remove());
479479
});
480-
alert.fadeIn(200);
480+
alert.stop().fadeIn(200);
481481
};
482482

483483
if (id !== undefined) {
484484
let sameAlert = alertBox.find(`.alert[data-alert-id=${id}]`);
485485
if (sameAlert.length > 0) {
486-
alertBox.fadeOut(200, () => {
486+
alertBox.stop().fadeOut(200, () => {
487487
alertBox.html('');
488488
alertBox.show();
489489
});
@@ -493,7 +493,7 @@ export default class BlueMap {
493493

494494
let oldAlerts = alertBox.find('.alert');
495495
if (oldAlerts.length > 0){
496-
alertBox.fadeOut(200, () => {
496+
alertBox.stop().fadeOut(200, () => {
497497
alertBox.html('');
498498
alertBox.show();
499499
displayAlert();

BlueMapCore/src/main/webroot/js/libs/Controls.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -215,41 +215,43 @@ export default class Controls {
215215
}
216216

217217
updateHeights() {
218-
function between(n, min, max) {
219-
return n >= min && n < max;
220-
}
218+
function between(n, min, max) {
219+
return n >= min && n < max;
220+
}
221221

222-
let inTile = (pos, thisPos) => {
223-
return between(pos.x, thisPos.x - this.tileSize.x, thisPos.x) &&
224-
between(pos.z, thisPos.z - this.tileSize.z, thisPos.z);
225-
};
222+
let inTile = (pos, thisPos) => {
223+
return between(pos.x, thisPos.x - this.tileSize.x, thisPos.x) &&
224+
between(pos.z, thisPos.z - this.tileSize.z, thisPos.z);
225+
};
226226

227-
let tileChildren = (targetPos) => {
228-
return this.heightScene.children.filter(child => inTile(child.position, targetPos))
229-
};
227+
let tileChildren = (targetPos) => {
228+
return this.heightScene.children.filter(child => inTile(child.position, targetPos))
229+
};
230230

231+
// check hight at target
232+
try {
231233
let rayStart = new Vector3(this.targetPosition.x, 300, this.targetPosition.z);
232234
this.raycaster.set(rayStart, this.rayDirection);
233235
this.raycaster.near = 1;
234236
this.raycaster.far = 300;
235237
let intersects = this.raycaster.intersectObjects(tileChildren(this.targetPosition));
236238

237-
if (intersects.length > 0){
239+
if (intersects.length > 0) {
238240
this.minHeight = intersects[0].point.y;
239-
//this.targetPosition.y = this.minHeight;
240-
} else {
241-
//this.targetPosition.y = 0;
242241
}
242+
} catch (ignore){}
243243

244-
rayStart.set(this.camera.position.x, 300, this.camera.position.z);
244+
// check height at camera
245+
try {
246+
let rayStart = new Vector3(this.camera.position.x, 300, this.camera.position.z);
245247
this.raycaster.set(rayStart, this.rayDirection);
246-
intersects.length = 0;
247-
intersects = this.raycaster.intersectObjects(tileChildren(this.camera.position));
248-
if (intersects.length > 0){
249-
if (intersects[0].point.y > this.minHeight){
248+
let intersects = this.raycaster.intersectObjects(tileChildren(this.camera.position));
249+
if (intersects.length > 0) {
250+
if (intersects[0].point.y > this.minHeight) {
250251
this.minHeight = intersects[0].point.y;
251252
}
252253
}
254+
} catch (ignore){}
253255
}
254256

255257
updateMouseMoves = () => {

0 commit comments

Comments
 (0)