Browse Source

Offset entities w.r.t. the entities holder, not the window

tags/v0.0.1
Fen Dweller 5 years ago
parent
commit
8dd9489af5
2 changed files with 8 additions and 2 deletions
  1. +4
    -0
      macrovision.css
  2. +4
    -2
      macrovision.js

+ 4
- 0
macrovision.css View File

@@ -42,6 +42,10 @@ body {
background: red;
}

#entities {
position: relative;
}

#world {
flex: 9 0 85vw;
min-height: 80vh;


+ 4
- 2
macrovision.js View File

@@ -97,8 +97,10 @@ function makeEntity() {
function clickDown(e) {
clicked = e.target;
const rect = e.target.getBoundingClientRect();
dragOffsetX = e.clientX - rect.left;
dragOffsetY = e.clientY - rect.top;
let entX = document.querySelector("#entities").getBoundingClientRect().x;
let entY = document.querySelector("#entities").getBoundingClientRect().y;
dragOffsetX = e.clientX - rect.left + entX;
dragOffsetY = e.clientY - rect.top + entY;
clickTimeout = setTimeout(() => {dragging = true}, 100)
}



Loading…
Cancel
Save