Commit e36bfb1f authored by Niccolò Venerandi's avatar Niccolò Venerandi
Browse files

Move the panel's placeholder instead of the target item and animate all of the...

Move the panel's placeholder instead of the target item and animate all of the items inbetween; also fixes mouse input that gets lost when quickly dragging applet to the very end of the panel.


(cherry picked from commit 58910116)
parent 2becaa4e
Pipeline #247265 passed with stage
in 3 minutes and 30 seconds
......@@ -50,16 +50,16 @@ MouseArea {
currentApplet.x = mouse.x - configurationArea.startDragOffset;
}
var item = currentLayout.childAt(mouse.x, mouse.y);
var item = root.layoutManager.childAtCoordinates(mouse.x, mouse.y);
if (item && item.applet !== placeHolder) {
var posInItem = mapToItem(item, mouse.x, mouse.y);
if ((!root.isHorizontal && posInItem.y < item.height/3) ||
(root.isHorizontal && posInItem.x < item.width/3)) {
root.layoutManager.move(item, placeHolder.parent.index+1)
} else if ((!root.isHorizontal && posInItem.y > 2*item.height/3) ||
(root.isHorizontal && posInItem.x > 2*item.width/3)) {
root.layoutManager.move(item, placeHolder.parent.index)
var posInItem = mapToItem(item, mouse.x, mouse.y)
var pos = root.isHorizontal ? posInItem.x : posInItem.y
var size = root.isHorizontal ? item.width : item.height
if (pos < size / 3) {
root.layoutManager.move(placeHolder.parent, item.index)
} else if (pos > size / 3 * 2) {
root.layoutManager.move(placeHolder.parent, item.index+1)
}
}
......
......@@ -96,7 +96,7 @@ function save() {
updateMargins()
}
function indexAtCoordinates(x, y) {
function childAtCoordinates(x, y) {
if (root.isHorizontal) {
y = layout.height / 2;
} else {
......@@ -120,6 +120,11 @@ function indexAtCoordinates(x, y) {
}
child = layout.childAt(x, y);
}
return child
}
function indexAtCoordinates(x, y) {
let child = childAtCoordinates(x, y)
if ((plasmoid.formFactor === 3 && y < child.y + child.height/2) ||
(plasmoid.formFactor !== 3 && x < child.x + child.width/2)) {
return child.index;
......@@ -144,8 +149,11 @@ function move(applet, end) {
var start = applet.index
var target = end - (start < end)
if (start == target) return;
applet.oldX = applet.x
applet.oldY = applet.y
// Setting oldX,oldY allows for position animations
for (let i = Math.min(start, end); i <= Math.max(start, end-1); i++) {
let el = layout.children[i]
el.oldX = el.x, el.oldY = el.y
}
appletsModel.move(start, target, 1)
save()
}
Supports Markdown
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