@@ -14,8 +14,8 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17−import QtQuick 2.1
17+import QtQuick 2.2
18−import Ubuntu.Components 0.1
18+import Ubuntu.Components 1.1
@@ -35,9 +35,8 @@ Item {
36 property real lateralPosition: -1
36 property real lateralPosition: -1
37 onLateralPositionChanged: {
37 onLateralPositionChanged: {
38− if (currentItem && !enableLateralChanges) return;
38+ if (currentItem || !enableLateralChanges) return;
39 updateItemFromLateralPosition(lateralPosition);
39 updateItemFromLateralPosition(lateralPosition);
40− highlight.updateHighlightOffset();
43 function updateItemFromLateralPosition(lateralPosition) {
42 function updateItemFromLateralPosition(lateralPosition) {
@@ -54,9 +53,10 @@ Item {
54 var bufferExceeded = false;
53 var bufferExceeded = false;
56 if (proposedItem !== currentItem) {
55 if (proposedItem !== currentItem) {
56+ // Proposed item is not directly adjacent to current?
57 if (Math.abs(currentItem.ownIndex - currentItem.ownIndex) > 1) {
57 if (Math.abs(currentItem.ownIndex - currentItem.ownIndex) > 1) {
58 bufferExceeded = true;
58 bufferExceeded = true;
59− } else {
59+ } else { // no
60 var currentItemLateralPosition = root.mapToItem(proposedItem, lateralPosition, 0).x;
60 var currentItemLateralPosition = root.mapToItem(proposedItem, lateralPosition, 0).x;
62 // Is the distance into proposed item greater than max buffer?
62 // Is the distance into proposed item greater than max buffer?
@@ -103,7 +103,7 @@ Item {
103 currentItem = item;
103 currentItem = item;
105 // Select default item.
105 // Select default item.
106− var searchIndex = lateralPosition > width ? repeater.count-1 : 0;
106+ var searchIndex = lateralPosition > width ? repeater.count - 1 : 0;
108 for (var i = 0; i < row.children.length; i++) {
108 for (var i = 0; i < row.children.length; i++) {
109 if (row.children[i].hasOwnProperty("ownIndex") && row.children[i].ownIndex === searchIndex) {
109 if (row.children[i].hasOwnProperty("ownIndex") && row.children[i].ownIndex === searchIndex) {
@@ -170,7 +170,7 @@ Item {
170 anchors.bottom: row.bottom
170 anchors.bottom: row.bottom
171 height: units.dp(2)
171 height: units.dp(2)
172 color: root.hightlightColor
172 color: root.hightlightColor
173− visible: root.currentItem !== null
173+ visible: currentItem !== null
174 opacity: 0.0
174 opacity: 0.0
176 width: currentItem ? currentItem.width : 0
176 width: currentItem ? currentItem.width : 0
@@ -181,31 +181,34 @@ Item {
182 // micromovements of the highlight line when user moves the finger across the items while pulling
182 // micromovements of the highlight line when user moves the finger across the items while pulling
183 // the handle downwards.
183 // the handle downwards.
184− function updateHighlightOffset() {
184+ Connections {
186+ onLateralPositionChanged: {
185− if (!currentItem || lateralPosition == -1) {
187+ if (!currentItem || lateralPosition == -1) {
186− highlightCenterOffset = 0;
188+ highlight.highlightCenterOffset = 0;
191+ if (!enableLateralChanges) return;
190− var itemMapped = root.mapToItem(currentItem, lateralPosition, 0);
193+ var itemMapped = root.mapToItem(currentItem, lateralPosition, 0);
192− var distanceFromCenter = itemMapped.x - currentItem.width / 2;
195+ var distanceFromCenter = itemMapped.x - currentItem.width / 2;
193− if (distanceFromCenter > 0) {
196+ if (distanceFromCenter > 0) {
194− distanceFromCenter = Math.max(0, distanceFromCenter-currentItem.width / 8);
197+ distanceFromCenter = Math.max(0, distanceFromCenter - currentItem.width / 8);
195− } else {
198+ } else {
196− distanceFromCenter = Math.min(0, distanceFromCenter+currentItem.width / 8);
199+ distanceFromCenter = Math.min(0, distanceFromCenter + currentItem.width / 8);
199− if (currentItem && currentItem.ownIndex === 0 && distanceFromCenter < 0) {
202+ if (currentItem && currentItem.ownIndex === 0 && distanceFromCenter < 0) {
200− highlightCenterOffset = 0;
203+ highlight.highlightCenterOffset = 0;
201− } else if (currentItem && currentItem.ownIndex === repeater.count-1 & distanceFromCenter > 0) {
204+ } else if (currentItem && currentItem.ownIndex === repeater.count-1 & distanceFromCenter > 0) {
202− highlightCenterOffset = 0;
205+ highlight.highlightCenterOffset = 0;
203− } else {
206+ } else {
204− var shiftPercentageOffset = (distanceFromCenter / (currentItem.width / 4));
207+ highlight.highlightCenterOffset = (distanceFromCenter / (currentItem.width / 4)) * units.gu(1);
205− highlightCenterOffset = shiftPercentageOffset * units.gu(1);
208+ }
209 property real highlightCenterOffset: 0
212 property real highlightCenterOffset: 0
210 Behavior on highlightCenterOffset {
213 Behavior on highlightCenterOffset {
211 NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
214 NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
@@ -236,7 +239,7 @@ Item {
236 Transition {
239 Transition {
237 PropertyAnimation {
240 PropertyAnimation {
238 properties: "opacity";
241 properties: "opacity";
239− duration: UbuntuAnimation.SnapDuration;
242+ duration: UbuntuAnimation.SnapDuration
240 easing: UbuntuAnimation.StandardEasing
243 easing: UbuntuAnimation.StandardEasing