fixed relative positioning

This commit is contained in:
Preet Shihn
2020-04-27 20:19:28 -07:00
parent 08644c8c2a
commit be870cfdb2
2 changed files with 4 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "planar-range",
"version": "0.3.1",
"version": "0.3.2",
"description": "A 2D range component ",
"main": "lib/planar-range.js",
"module": "lib/planar-range.js",
@@ -32,4 +32,4 @@
"dependencies": {
"pointer-tracker": "^2.3.0"
}
}
}

View File

@@ -173,8 +173,8 @@ export class PlanarRange extends HTMLElement {
if (pointer) {
const w = viewAnchor[2];
const h = viewAnchor[3];
const newX = w ? ((pointer.pageX - viewAnchor[0]) / w) : 0;
const newY = h ? ((pointer.pageY - viewAnchor[1]) / h) : 0;
const newX = w ? ((pointer.clientX - viewAnchor[0]) / w) : 0;
const newY = h ? ((pointer.clientY - viewAnchor[1]) / h) : 0;
if ((newX !== t.x) || (newY !== t.y)) {
if (this.validator) {
t.setValue(this.validator([newX, newY], [t.x, t.y], t.getAttribute('name') || null), true);