Skip to content

Commit

Permalink
Temp hotfix for scroll while dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
GhzGarage committed Nov 7, 2023
1 parent 5b06f0d commit 38f3443
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
11 changes: 7 additions & 4 deletions html/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
}

body {
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
overflow: hidden;
background: none !important;
font-family: "Roboto", sans-serif;
}
Expand Down Expand Up @@ -130,8 +135,7 @@ input[type="number"]::-webkit-outer-spin-button {
width: 28%;
height: 47.16%;
float: left;
overflow-x: hidden;
overflow-y: scroll;
overflow-y: auto;
}

.other-inventory {
Expand All @@ -145,8 +149,7 @@ input[type="number"]::-webkit-outer-spin-button {
width: 28%;
height: 47.16%;
float: left;
overflow-x: hidden;
overflow-y: scroll;
overflow-y: auto;
}

.item-slot {
Expand Down
25 changes: 24 additions & 1 deletion html/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,34 @@ function FormatItemInfo(itemData) {
}
}

$(document).on("wheel", function (e) {
if (IsDragging) {
var delta = e.originalEvent.deltaY;
var $playerInventory = $(".player-inventory");
var $otherInventory = $(".other-inventory");

var playerInventoryOffset = $playerInventory.offset();
var otherInventoryOffset = $otherInventory.offset();
var mouseX = e.originalEvent.clientX;
var mouseY = e.originalEvent.clientY;

if (mouseX > playerInventoryOffset.left && mouseX < playerInventoryOffset.left + $playerInventory.width() && mouseY > playerInventoryOffset.top && mouseY < playerInventoryOffset.top + $playerInventory.height()) {
$playerInventory.scrollTop($playerInventory.scrollTop() + delta);
} else if (mouseX > otherInventoryOffset.left && mouseX < otherInventoryOffset.left + $otherInventory.width() && mouseY > otherInventoryOffset.top && mouseY < otherInventoryOffset.top + $otherInventory.height()) {
$otherInventory.scrollTop($otherInventory.scrollTop() + delta);
}

if ((mouseX > playerInventoryOffset.left && mouseX < playerInventoryOffset.left + $playerInventory.width() && mouseY > playerInventoryOffset.top && mouseY < playerInventoryOffset.top + $playerInventory.height()) || (mouseX > otherInventoryOffset.left && mouseX < otherInventoryOffset.left + $otherInventory.width() && mouseY > otherInventoryOffset.top && mouseY < otherInventoryOffset.top + $otherInventory.height())) {
e.preventDefault();
}
}
});

function handleDragDrop() {
$(".item-drag").draggable({
helper: "clone",
appendTo: "body",
scroll: true,
scroll: false,
revertDuration: 0,
revert: "invalid",
cancel: ".item-nodrag",
Expand Down

0 comments on commit 38f3443

Please sign in to comment.