Avoid that the copy is triggered when drag the map

This commit is contained in:
BoBobby 2021-01-17 22:06:50 +01:00
parent 40cf6d355a
commit 8065836bf6

View File

@ -113,16 +113,20 @@ if (!window.location.href.includes('dofus-map')) {
const result = document.getElementById('mapCoordinates');
const mapElement = document.getElementById('mapContainer')
mapElement.addEventListener('click', event => {
const position = getPositionArray(result.innerHTML)
console.log(position)
if (position && position.length === 2) {
if (parameters.has('noob')) {
copyTextToClipboard('/p [' + position[0] + ',' + position[1] + ']')
} else {
copyTextToClipboard(travelCommand + position[0] + ',' + position[1])
mapElement.addEventListener('mousedown', mousedownEvent => {
let moved = false
mapElement.addEventListener('mousemove', moveEvent => moved = true)
mapElement.addEventListener('mouseup', mouseupEvent => {
const position = getPositionArray(result.innerHTML)
console.log(position)
if (position && position.length === 2 && !moved) {
if (parameters.has('noob')) {
copyTextToClipboard('/p [' + position[0] + ',' + position[1] + ']')
} else {
copyTextToClipboard(travelCommand + position[0] + ',' + position[1])
}
}
}
moved = false
})
})
}