Skip to content

Commit

Permalink
Updated map click handler with delay. Cancels click handler on double…
Browse files Browse the repository at this point in the history
…click.

Track keyboard shortcuts
  • Loading branch information
Mattk70 committed Mar 16, 2024
1 parent fbadfec commit bc86311
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ <h5 class="modal-title" id="locationModalLabel">Set Location</h5>
<script src="./js/ui.js" type="module"></script>
<script type="module" defer>
import { config, displayLocationAddress, LOCATIONS } from './js/ui.js';
let map, marker;
let map, marker, clickTimer = 0;
async function onMapClick(e) {
const {lat, lng} = e.latlng;
const target = map.getContainer().id;
Expand Down Expand Up @@ -1278,7 +1278,15 @@ <h5 class="modal-title" id="locationModalLabel">Set Location</h5>
const latEl = document.getElementById(latTxt);
const lonEl = document.getElementById(lonTxt);
showMap(divID);
map.on('click', onMapClick);
map.on('click', (e) => {
clearTimeout(clickTimer);
//Wait for doubleclick
clickTimer = setTimeout(() => {onMapClick(e)}, 250);
})
// don't call onMapClick if doubleclicked
map.on('dblclick', (e) => {
clearTimeout(clickTimer);
})
}

window.placeMap = placeMap;
Expand Down
2 changes: 2 additions & 0 deletions js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,8 @@ function onChartData(args) {
let action = e.code;
if (action in GLOBAL_ACTIONS) {
if (document === e.target || document.body === e.target || e.target.attributes["data-action"]) {}
const modifier = e.shiftKey ? 'Shift' : e.ctrlKey ? 'Control' : e.metaKey ? 'Alt' : 'no';
trackEvent(config.UUID, 'KeyPress', action, modifier );
GLOBAL_ACTIONS[action](e);
}

Expand Down

0 comments on commit bc86311

Please sign in to comment.