]> littlesong.place Git - poll.git/commitdiff
Fix drag-and-drop in iOS Safari
authorChris Fulljames <christian.fulljames@gmail.com>
Sun, 31 May 2026 14:27:28 +0000 (10:27 -0400)
committerChris Fulljames <christian.fulljames@gmail.com>
Sun, 31 May 2026 14:27:28 +0000 (10:27 -0400)
index.php

index c62c0324998a9339d07bd5d4aca1f83e2c4cda54..019f5a39a0f12c162c5a3730a08a62bf69ea32f7 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -309,10 +309,13 @@ if (isset($qid) && $view == "vote"): ?>
     document.querySelectorAll("li[draggable='true']").forEach((item) => {
         item.addEventListener("dragstart", (e) => {
             draggedElement = item;
+            e.dataTransfer.setData("text/plain", ""); // Safari needs this, but we don't use it
         });
 
-        item.addEventListener("dragenter", (e) => {
+        // Prevent weird end animation in Safari
+        item.addEventListener("dragover", (e) => {e.preventDefault();});
 
+        item.addEventListener("dragenter", (e) => {
             // No need to replace item with itself
             if (draggedElement === item) return;