fix click on color.

This commit is contained in:
Miroslav Šedivý 2024-05-09 08:11:20 +02:00
parent 7998018cb8
commit 3a0bd06a31

View File

@ -168,26 +168,16 @@ function clearPoint() {
} }
function clickPicker(e: any) { function clickPicker(e: any) {
// get mouse position
const x = e.pageX
const y = e.pageY
// get picker position // get picker position
const p = getCoords(picker.value!) const p = getCoords(picker.value!)
// calculate new x,y position // get mouse position
let newX = x - p.left let pageX = e.pageX
let newY = y - p.top let pageY = e.pageY
// make it relative to video size // make it relative to video size and save it
newX = Math.round((newX / video.value!.offsetWidth) * video.value!.videoWidth) x.value = Math.round(((pageX - p.left) / video.value!.offsetWidth) * video.value!.videoWidth)
newY = Math.round((newY / video.value!.offsetHeight) * video.value!.videoHeight) y.value = Math.round(((pageY - p.top) / video.value!.offsetHeight) * video.value!.videoHeight)
console.log(newX, newY)
// set new x,y position
x.value = newX
y.value = newY
// remove picker element // remove picker element
picker.value!.remove() picker.value!.remove()
@ -197,8 +187,8 @@ function clickPicker(e: any) {
bullet.value.remove() bullet.value.remove()
} }
const b = document.createElement('div') const b = document.createElement('div')
b.style.left = x + 'px' b.style.left = pageX + 'px'
b.style.top = y + 'px' b.style.top = pageY + 'px'
// width and height of bullet // width and height of bullet
b.style.width = '10px' b.style.width = '10px'
b.style.height = '10px' b.style.height = '10px'