[TASK] Implement basic drag&drop feature.
This commit is contained in:
parent
ec85bee1ac
commit
52f2f2bf54
24
js/main.js
24
js/main.js
|
@ -1,6 +1,6 @@
|
||||||
$(function() {
|
$(function() {
|
||||||
//setup the draggable content containers
|
//setup the draggable content containers
|
||||||
$(".content-container").draggable({
|
$(".content-container-bounding-box").draggable({
|
||||||
"distance": 10,
|
"distance": 10,
|
||||||
"handle": "h1",
|
"handle": "h1",
|
||||||
"helper": "clone",
|
"helper": "clone",
|
||||||
|
@ -29,16 +29,15 @@ $(function() {
|
||||||
"scope": "widget",
|
"scope": "widget",
|
||||||
"tolerance": "pointer",
|
"tolerance": "pointer",
|
||||||
"drop": function(event, ui) {
|
"drop": function(event, ui) {
|
||||||
$(event.target).css("background-color", "");
|
$("#draggable-temporary-clone").remove();
|
||||||
console.log(["drop", event, ui]);
|
$(ui.draggable[0]).prependTo(event.target);
|
||||||
},
|
},
|
||||||
"over": function(event, ui) {
|
"over": function(event, ui) {
|
||||||
$(event.target).css("background-color", "hsla(0, 100%, 100%, 0.4);");
|
$("#draggable-temporary-clone").remove();
|
||||||
console.log(["over", event, ui]);
|
$(ui.draggable[0]).clone(true).attr("id", "draggable-temporary-clone").prependTo(event.target);
|
||||||
},
|
},
|
||||||
"out": function(event, ui) {
|
"out": function(event, ui) {
|
||||||
$(event.target).css("background-color", "");
|
$("#draggable-temporary-clone").remove();
|
||||||
console.log(["out", event, ui]);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -47,16 +46,15 @@ $(function() {
|
||||||
"scope": "widget",
|
"scope": "widget",
|
||||||
"tolerance": "pointer",
|
"tolerance": "pointer",
|
||||||
"drop": function(event, ui) {
|
"drop": function(event, ui) {
|
||||||
$(event.target).css("background-color", "");
|
$("#draggable-temporary-clone").remove();
|
||||||
console.log(["drop", event, ui]);
|
$(ui.draggable[0]).insertAfter(event.target);
|
||||||
},
|
},
|
||||||
"over": function(event, ui) {
|
"over": function(event, ui) {
|
||||||
$(event.target).css("background-color", "hsla(0, 100%, 50%, 0.4);");
|
$("#draggable-temporary-clone").remove();
|
||||||
console.log(["over", event, ui]);
|
$(ui.draggable[0]).clone(true).attr("id", "draggable-temporary-clone").insertAfter(event.target);
|
||||||
},
|
},
|
||||||
"out": function(event, ui) {
|
"out": function(event, ui) {
|
||||||
$(event.target).css("background-color", "");
|
$("#draggable-temporary-clone").remove();
|
||||||
console.log(["out", event, ui]);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ h5 { font-size: 11pt; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-column {
|
.content-column {
|
||||||
padding: 2em 1em 2em 1em;
|
padding: 2em 1em 0em 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-container-bounding-box {
|
.content-container-bounding-box {
|
||||||
|
|
Loading…
Reference in New Issue