Verified Commit f0f2a5fd authored by Marco Kellershoff's avatar Marco Kellershoff 🤸
Browse files

Fix Drag and Drop Bugs

- Fix hostnames getting lost on drag and drop (new node, no save)
- Disable bubbling of drag and drop from input fields
parent 7c20e860
screenshot-1280.png

55.9 KB | W: | H:

screenshot-1280.png

80.9 KB | W: | H:

screenshot-1280.png
screenshot-1280.png
screenshot-1280.png
screenshot-1280.png
  • 2-up
  • Swipe
  • Onion skin
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Gorilla Script- and Style-Loader", "name": "Gorilla Script- and Style-Loader",
"version": "3.0.0", "version": "3.0.1",
"description": "Enables you to load Javascript and CSS into websites.", "description": "Enables you to load Javascript and CSS into websites.",
"default_locale": "en", "default_locale": "en",
"icons": { "icons": {
......
...@@ -163,9 +163,22 @@ ...@@ -163,9 +163,22 @@
} }
}; };
const stopDrag = (node) => {
node.setAttribute("draggable", "true");
node.addEventListener(
"dragstart",
(evt) => {
evt.preventDefault();
evt.stopPropagation();
},
{ passive: false }
);
};
const addEventsToListItem = (node) => { const addEventsToListItem = (node) => {
const input = node.querySelector(".input-file-url"); const input = node.querySelector(".input-file-url");
const select = node.querySelector("select"); const select = node.querySelector("select");
const hostnames = node.querySelector(".input-file-hostnames");
const checkboxEnabled = node.querySelector(".checkbox-file-enabled"); const checkboxEnabled = node.querySelector(".checkbox-file-enabled");
const btnAdd = node.querySelector(".btn-file-add"); const btnAdd = node.querySelector(".btn-file-add");
const btnRemove = node.querySelector(".btn-file-remove"); const btnRemove = node.querySelector(".btn-file-remove");
...@@ -222,6 +235,14 @@ ...@@ -222,6 +235,14 @@
{ passive: true } { passive: true }
); );
hostnames.addEventListener(
"keyup",
function() {
this.setAttribute("value", this.value);
},
{ passive: true }
);
checkboxEnabled.addEventListener( checkboxEnabled.addEventListener(
"change", "change",
setVisualsBasedOnCheckboxEnabled, setVisualsBasedOnCheckboxEnabled,
...@@ -249,6 +270,14 @@ ...@@ -249,6 +270,14 @@
{ passive: true } { passive: true }
); );
// drag and drop
// -------------
// disable bubbling for these elements
stopDrag(input);
stopDrag(hostnames);
// enable drag and drop for the list element
node.addEventListener("dragstart", onDragStartCallback, { node.addEventListener("dragstart", onDragStartCallback, {
passive: true passive: true
}); });
......
...@@ -49,6 +49,7 @@ h1 span { ...@@ -49,6 +49,7 @@ h1 span {
li.file { li.file {
position: relative; position: relative;
margin-bottom: 10px; margin-bottom: 10px;
transition: opacity ease 0.3s;
&.disabled { &.disabled {
opacity: 0.3; opacity: 0.3;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment