move anchors around

This commit is contained in:
2026-06-22 17:42:09 -04:00
parent 68d4baee61
commit 04b01dbf27
3 changed files with 24 additions and 2 deletions
+1
View File
@@ -172,6 +172,7 @@
</div> </div>
</div> </div>
<script src="/static/javascript/helpers.js" type="text/javascript"></script>
<script src="/static/javascript/cursor.js" type="text/javascript"></script> <script src="/static/javascript/cursor.js" type="text/javascript"></script>
<script <script
src="/static/javascript/resize_photo_dialouge.js" src="/static/javascript/resize_photo_dialouge.js"
+13
View File
@@ -0,0 +1,13 @@
function min(a, b) {
if (a < b) {
return a;
}
return b;
}
function max(a, b) {
if (a > b) {
return a;
}
return b;
}
+10 -2
View File
@@ -58,11 +58,14 @@ document.body.addEventListener("mouseup", () => {
// handle anchors // handle anchors
resize_anchors = document.getElementsByClassName("resize_anchor"); resize_anchors = document.getElementsByClassName("resize_anchor");
var handleBeingHeld = [false, false, false, false]; var handleBeingHeld = [false, false, false, false];
var startX, startY;
for (var i = 0; i < resize_anchors.length; i++) { for (var i = 0; i < resize_anchors.length; i++) {
const index = i; const index = i;
resize_anchors[index].addEventListener("mousedown", (e) => { resize_anchors[index].addEventListener("mousedown", (e) => {
e.stopPropagation(); e.stopPropagation();
handleBeingHeld[index] = true; handleBeingHeld[index] = true;
startX = currentX;
startY = currentY;
}); });
document.body.addEventListener("mouseup", () => { document.body.addEventListener("mouseup", () => {
@@ -77,7 +80,12 @@ document.body.addEventListener("mousemove", () => {
for (var i = 0; i < handleBeingHeld.length; i++) { for (var i = 0; i < handleBeingHeld.length; i++) {
if (!handleBeingHeld[i]) continue; if (!handleBeingHeld[i]) continue;
resize_anchors[i].style.setProperty("--x-offset", "100px"); newX = startX - currentX;
resize_anchors[i].style.setProperty("--y-offset", "100px"); newY = currentY - startY;
moveAmount = max(min(newX, newY), 0);
resize_anchors[i].style.setProperty("--x-offset", moveAmount + "px");
resize_anchors[i].style.setProperty("--y-offset", moveAmount + "px");
} }
}); });