clickable navigation

This commit is contained in:
Matt Walsh
2020-09-08 16:27:03 -05:00
parent 0e5d831f4a
commit 6a2317d283
6 changed files with 24 additions and 6 deletions

View File

@@ -251,6 +251,9 @@ const navigation = (() => {
}
};
// return the specificed display
const getDisplay = (index) => displays[index];
return {
init,
updateStatus,
@@ -258,5 +261,6 @@ const navigation = (() => {
isPlaying,
displayNavMessage,
msg,
getDisplay,
};
})();

View File

@@ -1,6 +1,6 @@
// regional forecast and observations
/* globals WeatherDisplay, utils, STATUS, draw */
/* globals WeatherDisplay, utils, STATUS, draw, navigation */
// eslint-disable-next-line no-unused-vars
class Progress extends WeatherDisplay {
@@ -93,6 +93,20 @@ class Progress extends WeatherDisplay {
}
canvasClick(e) {
console.log(e);
const x = e.offsetX;
const y = e.offsetY;
console.log(x,y);
// eliminate off canvas and outside area clicks
if (!this.isActive()) return;
if (y < 100 || y > 410) return;
if (x < 440 || x > 570) return;
// use the y value to determine an index
const index = Math.floor((y-100)/29);
const display = navigation.getDisplay(index);
if (display && display.status === STATUS.loaded) {
display.showCanvas(navigation.msg.command.firstFrame);
this.hideCanvas();
}
}
}