Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
fix click on color.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k1o committed May 9, 2024
1 parent 7998018 commit 3a0bd06
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions src/page/components/color.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,26 +168,16 @@ function clearPoint() {
}
function clickPicker(e: any) {
// get mouse position
const x = e.pageX
const y = e.pageY
// get picker position
const p = getCoords(picker.value!)
// calculate new x,y position
let newX = x - p.left
let newY = y - p.top
// make it relative to video size
newX = Math.round((newX / video.value!.offsetWidth) * video.value!.videoWidth)
newY = Math.round((newY / video.value!.offsetHeight) * video.value!.videoHeight)
console.log(newX, newY)
// get mouse position
let pageX = e.pageX
let pageY = e.pageY
// set new x,y position
x.value = newX
y.value = newY
// make it relative to video size and save it
x.value = Math.round(((pageX - p.left) / video.value!.offsetWidth) * video.value!.videoWidth)
y.value = Math.round(((pageY - p.top) / video.value!.offsetHeight) * video.value!.videoHeight)
// remove picker element
picker.value!.remove()
Expand All @@ -197,8 +187,8 @@ function clickPicker(e: any) {
bullet.value.remove()
}
const b = document.createElement('div')
b.style.left = x + 'px'
b.style.top = y + 'px'
b.style.left = pageX + 'px'
b.style.top = pageY + 'px'
// width and height of bullet
b.style.width = '10px'
b.style.height = '10px'
Expand Down

0 comments on commit 3a0bd06

Please sign in to comment.