Skip to content

Commit

Permalink
fix: datapoint location scales with screen size
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierSwaak committed Jul 13, 2024
1 parent d76d3d9 commit 4f3b36a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/assets/uncertainty/uncertainty.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
function addPoint(e) {
const click_box = document.getElementById("click_box");
var rect = click_box.getBoundingClientRect();
var x = e.clientX - rect.left;
var y = e.clientY - rect.top;
var x = (e.clientX - rect.left - 6) / rect.width * 100;
var y = (e.clientY - rect.top - 6) / rect.width * 100;
console.log(x + ", " + y);

const datapoint = document.createElement("span");
datapoint.classList.add("datapoint");

click_box.appendChild(datapoint);

datapoint.style.left = x - 6 + 'px';
datapoint.style.top = y - 6 + 'px';
datapoint.style.left = x + "%";
datapoint.style.top = y + "%";

datapoint.style.zIndex = -1;
}

0 comments on commit 4f3b36a

Please sign in to comment.