I’m trying to stop my elements from overlapping using interact.js, but I don’t have any idea how to get the n elements to be able to do it. Does anyone have an idea? Or some other way I can validate it.
Try the solution to this question, but I don’t understand how to get the list of elements to go through it. enter link description here
window.dragMoveListener = dragMoveListener;
interact('.signer-box')
.draggable({
onmove: dragMoveListener,
inertia: true,
autoScroll: true,
restrict: {
elementRect: {top: 0, left: 0, bottom: 1, right: 1}
}
})
.resizable({
onmove: resizeMoveListener,
inertia: true,
edges: {left: true, right: true, bottom: true, top: true}
})
const boxes = document.getElementsByClassName("signer-box");
function dragMoveListener(event) {
const self = {
x: event.target.offsetLeft + event.dx,
y: event.target.offsetTop + event.dy,
width: event.target.offsetWidth,
height: event.target.offsetHeight
}
if (!collides(self, event)) {
event.target.style.left = event.target.offsetLeft + event.dx + "px";
event.target.style.top = event.target.offsetTop + event.dy + "px";
var target = event.target;
var x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx;
var y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
target.style.webkitTransform = target.style.transform = 'translate(' + x + 'px, ' + y + 'px)';
target.setAttribute('data-x', x);
target.setAttribute('data-y', y);
computeSignerBoxPosition();
}
}
function resizeMoveListener(event) {
const self = {
x: event.target.offsetLeft + event.deltaRect.left,
y: event.target.offsetTop + event.deltaRect.top,
width: event.target.offsetWidth + event.deltaRect.width,
height: event.target.offsetHeight + event.deltaRect.height
}
if (!collides(self, event)) {
var target = event.target;
var x = (parseFloat(target.getAttribute('data-x')) || 0);
var y = (parseFloat(target.getAttribute('data-y')) || 0);
x += event.deltaRect.left;
y += event.deltaRect.top;
target.style.width = event.rect.width + 'px';
target.style.height = event.rect.height + 'px';
target.style.webkitTransform = target.style.transform = 'translate(' + x + 'px,' + y + 'px)';
target.setAttribute('data-x', x);
target.setAttribute('data-y', y);
computeSignerBoxPosition();
}
}
function collides(self, event) {
for (const box of boxes) {
if (box == event.target) {
continue;
}
const other = {
x: box.offsetLeft,
y: box.offsetTop,
width: box.offsetWidth,
height: box.offsetHeight
}
const collisionX = Math.max(self.x + self.width, other.x + other.width) - Math.min(self.x, other.x) < self.width + other.width;
const collisionY = Math.max(self.y + self.height, other.y + other.height) - Math.min(self.y, other.y) < self.height + other.height;
if (collisionX && collisionY) {
return true;
}
}
return false;
}
function computeSignerBoxPosition() {
var $signatureBox = $('.signer-box');
var sbDataX = parseFloat($signatureBox.attr('data-x'));
var sbDataY = parseFloat($signatureBox.attr('data-y'));
var sbOuterWidth = $signatureBox.outerWidth();
var sbOuterHeight = $signatureBox.outerHeight();
var w = $('#pdf-page').width();
var h = $('#pdf-page').height();
var top = sbDataX / w;
var left = sbDataY / h;
var width = sbOuterWidth / w;
var height = sbOuterHeight / h;
document.getElementById("widthValue").value = width;
document.getElementById("heightValue").value = height;
document.getElementById("coorX").value = top;
document.getElementById("coorY").value = left;
}
@charset "UTF-8";
#pdf-container {
display: inline-block;
width: 100%;
user-select: none;
}
#pdf-page {
width: 100%;
}
.signer-box {
top: 0;
left: 0;
position: absolute;
background: #29e no-repeat 50% 50%;
background-size: 50%;
color: white;
font-size: 20px;
font-family: sans-serif;
border-radius: 8px;
width: 180px;
height: 150px;
opacity: 0.8;
box-sizing: border-box;
box-shadow: rgb(0, 0, 0, 0.7) 0.2em 0.2em 0.5em;
-ms-touch-action: none;
touch-action: none;
}
#values {
position: fixed;
bottom: 0;
height: 40;
}
<!DOCTYPE html>
<html>
<head></head>
<body>
<div id="pdf-container">
<img id="pdf-page" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABMgAAAYwCAIAAAAI8uQFAAAzRklEQVR42uzdf2SV/f/A8Q8zySQxyUwykiTJSJLMjMncMhkzkyQxk1uSSJIkMZN8JJEkk0RmJkkkmUziNpNMYjLJJCZJMn1fevu+XZ+zH/dpq+67ejz+yDnvc/2uc7ue93XOdf7zGQAAABbhPw4BAAAAwhIAAABhCQAAgLAEAABAWAIAAICwBAAAQFgCAAAgLAEAABCWAAAAICwBAAAQlgAAAAhLAAAAhCUAAAAISwAAAIQlA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ADCWAAAAYCwBAAAwlgAAABhLAAAAjCUAAADGEgAAAIwlAAAAxhIAAABjCQAAgLEEAAAAYwkAAICxBAAAwFgCAABgLAEAAMBYAgAAYCwBAAAwlgAAABhLAAAAMJYAAAAYSwAAAIwlAAAAxhIAAABjCQAAAMYSAAAAYwkAAICxBAAAwFgCAACAsQQAAMBYAgAAYCwBAAAwlgAAAGAsAQAAMJYAAAAYSwAAAIwlAAAAGEsAAACMJQAAAMYSAAAAYwkAAICxBAAAAGMJAACAsQQAAMBYAgAAYCwBAADAWAIAAGAsAQAAMJYAAAAYSwAAADCWAAAAGEsAAACMJQAAAMYSAAAAjCUAAADGEgAAAGMJAACAsQQAAABjCQAAgLEEAADAWAIAAGAsAQAAMJYAAABgLAEAADCWAAAAGEsAAACMJQAAABhLAAAAjCUAAADGEgAAAGMJAAAAxhIAAABjCQAAgLEEAADAWAIAAICxBAAAwFgCAABgLAEAADCWAAAAGEsAAAAwlgAAABhLAAAAjCUAAADGEgAAAIwlAAAAxhIAAABjCQAAgLEEAAAAYwkAAICxBAAAwFgCAABgLAEAAMBYAgAAYCwBAAAwlgAAABhLAAAAjCUAAAAYSwAAAIwlAAAAxhIAAABjCQAAAMYSAAAAYwkAAICxBAAAwFgCAACAsQQAAMBYAgAAYCwBAAAwlgAAAGAsAQAAMJYAAAAYSwAAAIwlAAAAGEsAAACMJQAAAMYSAAAAYwkAAICxBAAAAGMJAACAsQQAAMBYAgAAsBF9Ip71RRoBHwAAAABJRU5ErkJggg=="
/>
<div id="signer-1" class="signer-box" data-x="379" data-y="279" style="position: absolute; transform: translate(379px, 279px); width: 148px; height: 90px; --content:"Firma número 1" ;"></div>
<div id="signer-2" class="signer-box" data-x="17" data-y="30" style="position: absolute; transform: translate(17px, 30px); width: 238px; height: 121px; --content:"Firma número 2" ;"></div>
</div>
<div id="values">
<label>X:
<input id="coorX" readonly>
</label>
<label>Y:
<input id="coorY" readonly>
</label>
<label>Width:
<input id="widthValue" readonly>
</label>
<label>Height:
<input id="heightValue" readonly>
</label>
</div>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.0.943/pdf.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/interact.js/1.2.9/interact.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.0.943/pdf.worker.min.js'></script>
</body>
</html>
2
Answers
What you are looking for is collision detection. When you move or resize your box you can check if the new dimensions/position does collide with other boxes. If that is the case then you can ignore the movement/resize.
Because your code snippet contained a lot of invalid HTML I had to strip most of it to make it work. Please do spend some time making valid HTML when/if you ask your next question. Some errors that were present in your HTML code:
<head>
element<br/>
is valid but<div/>
is not and the proper way of writing some HTML tags like input is<input>
(without closing tag)</tag>
without any starting tags<tag>
Below is the solution i came up with:
Note that collision detection is done with the so-called AABB collision detection algorithm. It might not be the most efficient collision detection algorithm but it’s one of the simplest to implement. And since you have only 2 boxes this algorithm is sufficient. If you need more boxes this algorithm will become exponentially slower and you might want to invest time researching for a better algorithm, for example, a quadtree.
Since you need an answer that uses the CSS transform property I have made a new answer based on your changed code snippet with parts of my old answer. The collisions will be detected on the transform offsets and not the top and left properties. I hope you are helped with this answer.