Skip to content

Commit

Permalink
hacky fix for x offset
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmeeks committed Dec 7, 2023
1 parent c247f8d commit 7946449
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions blob/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ const states = {};
const pelletStates = {};

let scale = 1.0;
let offsetX = 0.0;
const viewportElem = document.getElementById("container");

function setScale(v) {
scale = v;
viewportElem.style.scale = v;
viewportElem.style.left = `${Math.round(
Math.max(0, visualViewport.width - v * 1280) / 2,
)}px`;
offsetX = Math.round(Math.max(0, visualViewport.width - v * 1280) / 2);
viewportElem.style.left = `${offsetX}px`;
}

visualViewport.onresize = () => {
Expand Down Expand Up @@ -348,7 +348,7 @@ function sendMessage(msg) {
viewportElem.onclick = (ev) => {
sendMessage({
SetTarget: {
x: Math.round(ev.x / scale),
x: Math.round((ev.x - offsetX) / scale),
y: Math.round(ev.y / scale),
temp_from_x: Math.round(states[localId].x),
temp_from_y: Math.round(states[localId].y),
Expand Down
9 changes: 7 additions & 2 deletions blob/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,16 @@ button {
color: white;
padding: 0.5rem;
border-radius: 0.5rem;
margin: 1rem;
}

#btn-appearance {
left: 1rem;
bottom: 1rem;
}

#btn-fullscreen {
right: 0;
right: 1rem;
bottom: 1rem;
}

button:active {
Expand Down

0 comments on commit 7946449

Please sign in to comment.