on xenial help sign in
improve snapping after dragging

This fixes an issue that the listView was doing some weird bounce effect when dropping items at the top or bottom because of some flicking that tried to make sure the dropped item is completely visible. This didn't work reliably and introduced the above issue. The new code uses some animation to move around contentY which seems to be much more reliable and avoids the issue.

commit7666f34a1aac121c419e187ba5f7376f2197caad authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 13 Nov 2014, 14:12 (12 years ago) parent973e468
1 file changed+17−4
qml/Launcher/LauncherPanel.qml+17−4
qml/Launcher/LauncherPanel.qml+17−4
@@ -49,7 +49,6 @@ Rectangle {
4949 width: parent.width
5050 height: units.gu(7)
5151 color: UbuntuColors.orange
52− z: 1
5352
5453 Image {
5554 objectName: "dashItem"
@@ -131,6 +130,20 @@ Rectangle {
131130 property bool draggingTransitionRunning: false
132131 property int scheduledMoveTo: -1
133132
133+ UbuntuNumberAnimation {
134+ id: snapToBottomAnimation
135+ target: launcherListView
136+ property: "contentY"
137+ to: launcherListView.originY
138+ }
139+
140+ UbuntuNumberAnimation {
141+ id: snapToTopAnimation
142+ target: launcherListView
143+ property: "contentY"
144+ to: launcherListView.contentHeight - launcherListView.height + launcherListView.originY
145+ }
146+
134147 displaced: Transition {
135148 NumberAnimation { properties: "x,y"; duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
136149 }
@@ -336,10 +349,10 @@ Rectangle {
336349 progressiveScrollingTimer.stop();
337350 launcherListView.interactive = true;
338351 if (droppedIndex >= launcherListView.count - 2 && postDragging) {
339− launcherListView.flick(0, -launcherListView.clickFlickSpeed);
352+ snapToBottomAnimation.start();
340353 }
341− if (droppedIndex == 0 && postDragging) {
342− launcherListView.flick(0, launcherListView.clickFlickSpeed);
354+ if (droppedIndex < 2 && postDragging) {
355+ snapToTopAnimation.start();
343356 }
344357 }
345358