on xenial help sign in
initial try on progressive scrolling while dragging
d980c29Michael Zanetti
Launcher/LauncherPanel.qml+40−5
@@ -28,7 +28,7 @@ Item {
28 rotation: inverted ? 180 : 0
28 rotation: inverted ? 180 : 0
29
29
30 property var model
30 property var model
31− property bool inverted: true
31+ property bool inverted: false
32 property bool dragging: false
32 property bool dragging: false
33 property bool moving: launcherListView.moving || launcherListView.flicking || dndArea.draggedItem !== undefined
33 property bool moving: launcherListView.moving || launcherListView.flicking || dndArea.draggedItem !== undefined
34 property int dragPosition: 0
34 property int dragPosition: 0
@@ -42,9 +42,9 @@ Item {
42
42
43 var hiddenContentHeight = launcherListView.contentHeight - launcherListView.height
43 var hiddenContentHeight = launcherListView.contentHeight - launcherListView.height
44 // Shortening scrollable height because the first/last item needs to be fully expanded before reaching the top/bottom
44 // Shortening scrollable height because the first/last item needs to be fully expanded before reaching the top/bottom
45− var scrollableHeight = launcherListView.height - (launcherListView.itemSize + launcherColumn.spacing) *2
45+ var scrollableHeight = launcherListView.height - (launcherListView.itemSize + launcherListView.spacing) *2
46 // As we shortened the scrollableHeight, lets move everything down by the itemSize
46 // As we shortened the scrollableHeight, lets move everything down by the itemSize
47− var shortenedEffectiveDragPosition = effectiveDragPosition - launcherListView.itemSize - launcherColumn.spacing
47+ var shortenedEffectiveDragPosition = effectiveDragPosition - launcherListView.itemSize - launcherListView.spacing
48 var newContentY = shortenedEffectiveDragPosition * hiddenContentHeight / scrollableHeight
48 var newContentY = shortenedEffectiveDragPosition * hiddenContentHeight / scrollableHeight
49
49
50 // limit top/bottom to prevent overshooting
50 // limit top/bottom to prevent overshooting
@@ -54,7 +54,7 @@ Item {
54 // > the current mouse position + the hidden/scolled content on top is the mouse position in the averall view
54 // > the current mouse position + the hidden/scolled content on top is the mouse position in the averall view
55 // > adjust that removing all the margins
55 // > adjust that removing all the margins
56 // > divide by itemSize to get index
56 // > divide by itemSize to get index
57− highlightIndex = (effectiveDragPosition + launcherListView.contentY - mainColumn.anchors.margins*3 - launcherColumn.spacing/2) / (launcherListView.itemSize + launcherColumn.spacing)
57+// highlightIndex = (effectiveDragPosition + launcherListView.contentY - mainColumn.anchors.margins*3 - launcherListView.spacing/2) / (launcherListView.itemSize + launcherColumn.spacing)
58 }
58 }
59
59
60 BorderImage {
60 BorderImage {
@@ -236,6 +236,8 @@ Item {
236 draggedIndex = -1;
236 draggedIndex = -1;
237 drag.target = undefined
237 drag.target = undefined
238 launcherListView.interactive = true;
238 launcherListView.interactive = true;
239+
240+ progressiveScrollingTimer.stop();
239 }
241 }
240
242
241 onPressAndHold: {
243 onPressAndHold: {
@@ -279,7 +281,7 @@ Item {
279 }
281 }
280
282
281 //launcherPanel.dragPosition = inverted ? launcherListView.height - y : y
283 //launcherPanel.dragPosition = inverted ? launcherListView.height - y : y
282− //launcherPanel.dragPosition = mouseY
284+ //root.dragPosition = mouseY
283
285
284 var realContentY = launcherListView.contentY + launcherListView.topMargin
286 var realContentY = launcherListView.contentY + launcherListView.topMargin
285 var realItemSize = launcherListView.itemSize + launcherListView.spacing
287 var realItemSize = launcherListView.itemSize + launcherListView.spacing
@@ -288,6 +290,20 @@ Item {
288 // Move it down by the the missing size to compensate index calculation with only expanded items
290 // Move it down by the the missing size to compensate index calculation with only expanded items
289 itemCenterY += selectedItem.height / 2
291 itemCenterY += selectedItem.height / 2
290
292
293+ print("mouseY", mouseY, launcherListView.height - launcherListView.topMargin - launcherListView.bottomMargin - realItemSize)
294+ if (mouseY > launcherListView.height - launcherListView.topMargin - launcherListView.bottomMargin - realItemSize) {
295+ print("entered bottom area")
296+ progressiveScrollingTimer.downwards = false
297+ progressiveScrollingTimer.start()
298+ } else if (mouseY < realItemSize) {
299+ progressiveScrollingTimer.downwards = true
300+ progressiveScrollingTimer.start()
301+ print("entered top area")
302+ } else {
303+ progressiveScrollingTimer.stop()
304+ print("not in any area")
305+ }
306+
291 var newIndex = (itemCenterY + realContentY) / realItemSize
307 var newIndex = (itemCenterY + realContentY) / realItemSize
292
308
293 if (newIndex > draggedIndex + 1) {
309 if (newIndex > draggedIndex + 1) {
@@ -306,6 +322,25 @@ Item {
306 }
322 }
307 }
323 }
308 }
324 }
325+ Timer {
326+ id: progressiveScrollingTimer
327+ interval: 5
328+ repeat: true
329+ running: false
330+ property bool downwards: true
331+ onTriggered: {
332+ if (downwards) {
333+ if (launcherListView.contentY > launcherListView.contentHeight - launcherListView.height) {
334+ launcherListView.contentY -= 2
335+ }
336+ } else {
337+ if (launcherListView.contentY < 0) {
338+ launcherListView.contentY += 2
339+ }
340+ }
341+ }
342+ }
343+
309 MouseArea {
344 MouseArea {
310 id: topFoldingArea
345 id: topFoldingArea
311 anchors {
346 anchors {