|
|
@ -293,32 +293,12 @@ module.exports = class ColorTriangle { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_getRelativeCoordinates (evt) { |
|
|
|
_getRelativeCoordinates (evt) { |
|
|
|
let pos = {} |
|
|
|
let elem = this.triangle |
|
|
|
let offset = {} |
|
|
|
let rect = elem.getBoundingClientRect() |
|
|
|
let ref |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME this doesn't really work with scroll
|
|
|
|
|
|
|
|
// this.triangle is the canvas element
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ref = this.triangle.offsetParent |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pos.x = evt.touches ? evt.touches[0].pageX : evt.pageX |
|
|
|
|
|
|
|
pos.y = evt.touches ? evt.touches[0].pageY : evt.pageY |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
offset.left = this.triangle.offsetLeft |
|
|
|
|
|
|
|
offset.top = this.triangle.offsetTop |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (ref) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
offset.left += ref.offsetLeft |
|
|
|
|
|
|
|
offset.top += ref.offsetTop |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ref = ref.offsetParent |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
x: pos.x - offset.left, |
|
|
|
x: evt.clientX - rect.x, |
|
|
|
y: pos.y - offset.top |
|
|
|
y: evt.clientY - rect.y |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|