Skip to content

Commit

Permalink
fix hovering
Browse files Browse the repository at this point in the history
  • Loading branch information
jvde-github committed Sep 30, 2024
1 parent 9db6829 commit e973739
Show file tree
Hide file tree
Showing 8 changed files with 7,304 additions and 7,034 deletions.
4 changes: 2 additions & 2 deletions Application/AIS-catcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
#define VERSION "v0.60"
#define COPYRIGHT "jvde-github and other contributors"

#define VERSION_DESCRIBE "v0.60-119-g31f47cbc"
#define VERSION_URL_TAG "v0_60_119_g31f47cbc"
#define VERSION_DESCRIBE "1727718774"
#define VERSION_URL_TAG "1727718774"
6 changes: 3 additions & 3 deletions HTML/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<script src="https://cdn.jsdelivr.net/npm/ol@v10.0.0/dist/ol.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ol@v10.0.0/ol.css">

<link rel="stylesheet" href="style_1727715942.css" />
<link rel="stylesheet" href="style_1727718774.css" />
<link rel="stylesheet" href="config.css" />

</head>
Expand Down Expand Up @@ -925,7 +925,7 @@
<div title="Center map on current vessel" onclick="openAIScatcherSite(card_mmsi)"
class="noandroid"><i class="info_icon"></i><span>aiscatcher.org</span></div>
<div id="shipcard_track_option" title="Track of current vessel"
onclick="toggleTrack(card_mmsi)"><i class="timeline_icon"></i><span
onclick="toggleTrack(card_mmsi)"><i id = "shipcard_track_icon" class="timeline_icon"></i><span
id="shipcard_track">Track</span></div>
</footer>
</aside>
Expand Down Expand Up @@ -1006,7 +1006,7 @@
</div>
<div class="bottombar"></div>

<script src="script_1727715942.js"></script>
<script src="script_1727718774.js"></script>
<script src="config.js"></script>

<script>
Expand Down
1,568 changes: 788 additions & 780 deletions HTML/index_html.cpp

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions HTML/index_local.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<script src="cdn/npm/ol@v10.0.0/dist/ol.js"></script>
<link rel="stylesheet" href="cdn/npm/ol@v10.0.0/ol.css">

<link rel="stylesheet" href="style_v0_60_119_g31f47cbc.css" />
<link rel="stylesheet" href="style_1727718774.css" />
<link rel="stylesheet" href="config.css" />

</head>
Expand Down Expand Up @@ -925,7 +925,7 @@
<div title="Center map on current vessel" onclick="openAIScatcherSite(card_mmsi)"
class="noandroid"><i class="info_icon"></i><span>aiscatcher.org</span></div>
<div id="shipcard_track_option" title="Track of current vessel"
onclick="toggleTrack(card_mmsi)"><i class="timeline_icon"></i><span
onclick="toggleTrack(card_mmsi)"><i id = "shipcard_track_icon" class="timeline_icon"></i><span
id="shipcard_track">Track</span></div>
</footer>
</aside>
Expand Down Expand Up @@ -1006,7 +1006,7 @@
</div>
<div class="bottombar"></div>

<script src="script_v0_60_119_g31f47cbc.js"></script>
<script src="script_1727718774.js"></script>
<script src="config.js"></script>

<script>
Expand Down
1,562 changes: 785 additions & 777 deletions HTML/index_local_html.cpp

Large diffs are not rendered by default.

27 changes: 19 additions & 8 deletions HTML/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ function showContextMenu(event, mmsi, context) {
document.getElementById("ctx_menu_unpin").style.display = settings.fix_center && context.includes("ctx-map") ? "flex" : "none";

if (settings.show_track_on_select && context_mmsi == card_mmsi) {
document.getElementById("ctx_track").innerText = select_enabled_track && context.includes("mmsi-map") ? "Pin Track" : "Unpin Track";
document.getElementById("ctx_track").innerText = select_enabled_track && context.includes("mmsi-map") ? "Show Track" : "Hide Track";
}
else {
const isTrackVisible = marker_tracks.has(Number(context_mmsi));
Expand Down Expand Up @@ -3821,15 +3821,15 @@ const showTooltipShip = (tooltip, mmsi, pixel, angle = 0) => {
const dist = 15;

// we position the tooltip top-right of the ship in the direction of the ship's course to minimize overlap with path
const calculatePosition = (currentAngle) => {
const rad = (currentAngle + 45) * Math.PI / 180;
const calculatePosition = (a) => {
const rad = (a + 45) * Math.PI / 180;
const s = Math.sin(rad);
const c = -Math.cos(rad);
let x = pixel[0] + dist * s + (s < 0 ? -tw : 0);
let y = pixel[1] + dist * c + (c < 0 ? -th : 0);
return { x, y };
};

let pos = calculatePosition(angle);
// if it is off the screen, we try to move it to the opposite side
if (pos.x + tw > mapW - 50 || pos.x < 0 || pos.y + th > mapH - 10 || pos.y < 0) {
Expand All @@ -3855,9 +3855,8 @@ const startHover = function (mmsi, pixel = undefined) {
stopHover();
}


if ((mmsi in shipsDB && shipsDB[mmsi].raw.lon && shipsDB[mmsi].raw.lat)) {
const center = ol.proj.fromLonLat([shipsDB[mmsi].raw.lon, shipsDB[mmsi].raw.lat]);
pixel = map.getPixelFromCoordinate(center);
hoverMMSI = mmsi;
showTooltipShip(hover_info, hoverMMSI, pixel, shipsDB[mmsi].raw.cog);
}
Expand Down Expand Up @@ -3918,9 +3917,17 @@ const handlePointerMove = function (pixel, target) {
const feature = getFeature(pixel, target)

if (feature && 'ship' in feature) {

const coordinate = feature.getGeometry().getCoordinates();
pixel = map.getPixelFromCoordinate(coordinate);

startHover(feature.ship.mmsi, pixel);
}
else if (feature && 'tooltip' in feature) {
if ('station' in feature) {
const coordinate = feature.getGeometry().getCoordinates();
pixel = map.getPixelFromCoordinate(coordinate);
}
startHover(feature.tooltip, pixel);
} else if (hoverMMSI) {
stopHover();
Expand Down Expand Up @@ -4212,7 +4219,11 @@ function updateShipcardTrackOption() {

if (card_mmsi) {
if (settings.show_track_on_select) {
document.getElementById("shipcard_track").innerText = select_enabled_track ? "Pin Track" : "Unpin Track";
if(select_enabled_track) {
document.getElementById("shipcard_track").innerText = "Show Track";
} else {
document.getElementById("shipcard_track").innerText = "Hide Track";
}
}
else {
const isTrackVisible = marker_tracks.has(Number(card_mmsi));
Expand Down Expand Up @@ -5260,7 +5271,7 @@ function makeDraggable(element) {

const onPointerUp = (e) => {
onDragEnd();
element.releasePointerCapture(e.pointerId); // Release pointer capture
element.releasePointerCapture(e.pointerId);
element.removeEventListener('pointermove', onPointerMove);
element.removeEventListener('pointerup', onPointerUp);
};
Expand Down
Loading

0 comments on commit e973739

Please sign in to comment.