fadeOut when marker leaves canvas

also move fadeIn to position at new marker before showing infoBox
This commit is contained in:
byronbest 2019-12-05 17:06:18 -08:00 committed by GitHub
parent 0ba4ba3fd7
commit 1a0ba50c4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 11 deletions

View File

@ -1113,22 +1113,28 @@ function refreshHighlighted() {
infoBox.fadeOut(); infoBox.fadeOut();
return; return;
} }
infoBox.fadeIn(100);
var mapCanvas = $('#map_canvas'); var mapCanvas = $('#map_canvas');
var markerCoordinates = highlighted.marker.getGeometry().getCoordinates(); var markerCoordinates = highlighted.marker.getGeometry().getCoordinates();
var markerPosition = OLMap.getPixelFromCoordinate(markerCoordinates); var markerPosition = OLMap.getPixelFromCoordinate(markerCoordinates);
var x = markerPosition[0] + 20; var x = markerPosition[0];
var y = markerPosition[1] + 60; var y = markerPosition[1];
if (x < 0 || y < 0 || x > mapCanvas.width() || y > mapCanvas.height()) {
infoBox.fadeOut();
return;
}
x = x + 20;
y = y + 60;
var w = infoBox.outerWidth() + 20; var w = infoBox.outerWidth() + 20;
var h = infoBox.outerHeight(); var h = infoBox.outerHeight();
if (x > mapCanvas.width() - w) { if (x > mapCanvas.width() - w) {
x -= w + 20; x -= w + 20;
} }
if (y > mapCanvas.height() - h) { if (y > mapCanvas.height() - h) {
y -= h; y -= h;
} }
infoBox.animate({ left: x, top: y }, 500); infoBox.fadeIn(100);
infoBox.animate({ left: x, top: y }, 500);
if (highlighted.flight !== null && highlighted.flight !== "") { if (highlighted.flight !== null && highlighted.flight !== "") {
$('#highlighted_callsign').text(highlighted.flight); $('#highlighted_callsign').text(highlighted.flight);