@@ -18,14 +18,14 @@ Item {
1818 keys: ['workspace']
1919
2020 onEntered: {
21− var index = listView.getDropIndex(drag);
21+ var index = listView.getWorkspaceDropIndex(drag);
2222 listView.model.insert(index, {text: drag.source.text})
2323 listView.dropItemIndex = index;
2424 drag.source.inDropArea = true;
2525 }
2626
2727 onPositionChanged: {
28− var index = listView.getDropIndex(drag);
28+ var index = listView.getWorkspaceDropIndex(drag);
2929 if (listView.dropItemIndex == index) return;
3030 listView.model.move(listView.dropItemIndex, index, 1);
3131 listView.dropItemIndex = index;
@@ -42,6 +42,18 @@ Item {
4242 drag.source.inDropArea = false;
4343 }
4444 }
45+ DropArea {
46+ anchors.fill: parent
47+ keys: ["application"]
48+
49+ onPositionChanged: {
50+ listView.progressiveScroll(drag.x)
51+ listView.hoveredWorkspaceIndex = listView.getApplicationDropIndex(drag)
52+ }
53+ onExited: {
54+ listView.hoveredWorkspaceIndex = -1
55+ }
56+ }
4557
4658 ListView {
4759 id: listView
@@ -59,8 +71,18 @@ Item {
5971 property int foldingAreaWidth: units.gu(10)
6072 property real realContentX: contentX - originX + leftMargin
6173 property int dropItemIndex: -1
74+ property int hoveredWorkspaceIndex: -1
75+
76+ function getWorkspaceDropIndex(drag) {
77+ var coords = mapToItem(listView.contentItem, drag.x, drag.y)
78+ var index = Math.floor((drag.x + listView.realContentX) / (listView.itemWidth + listView.spacing));
79+ if (index < 0) index = 0;
80+ var upperLimit = dropItemIndex == -1 ? listView.count : listView.count - 1
81+ if (index > upperLimit) index = upperLimit;
82+ return index;
83+ }
6284
63− function getDropIndex(drag) {
85+ function getApplicationDropIndex(drag) {
6486 var coords = mapToItem(listView.contentItem, drag.x, drag.y)
6587 var index = Math.floor((drag.x + listView.realContentX) / (listView.itemWidth + listView.spacing));
6688 if (index < 0) index = 0;
@@ -69,6 +91,12 @@ Item {
6991 return index;
7092 }
7193
94+ function progressiveScroll(mouseX) {
95+ var progress = Math.max(0, Math.min(1, (mouseX - listView.foldingAreaWidth) / (width - listView.leftMargin * 2 - listView.foldingAreaWidth * 2)))
96+ print("p", progress, mouseX)
97+ listView.contentX = listView.originX + (listView.contentWidth - listView.width + listView.leftMargin + listView.rightMargin) * progress - listView.leftMargin
98+ }
99+
72100 displaced: Transition { UbuntuNumberAnimation { properties: "x" } }
73101
74102 delegate: Item {
@@ -164,6 +192,7 @@ Item {
164192 width: listView.itemWidth
165193 background: root.background
166194 screenHeight: root.screen.physicalSize.height
195+ containsDrag: listView.hoveredWorkspaceIndex == index
167196
168197 Label {
169198 anchors.centerIn: parent
@@ -189,8 +218,7 @@ Item {
189218
190219 onMouseXChanged: {
191220 if (!pressed || dragging) {
192− var progress = Math.max(0, Math.min(1, (mouseX - listView.foldingAreaWidth) / (width - listView.foldingAreaWidth * 2)))
193− listView.contentX = listView.originX + (listView.contentWidth - listView.width + listView.leftMargin + listView.rightMargin) * progress - listView.leftMargin
221+ listView.progressiveScroll(mouseX)
194222 }
195223 }
196224 onMouseYChanged: {