on xenial help sign in
fixed highlight offset
40122beNick Dedekind
qml/Panel/IndicatorItemRow.qml+16−25
@@ -181,40 +181,31 @@ Item {
181
181
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− Connections {
185− target: root
186− onLateralPositionChanged: {
187− if (!currentItem || lateralPosition == -1) {
188− highlight.highlightCenterOffset = 0;
189− return;
190− }
191− if (!enableLateralChanges) return;
192
184
185+ property real highlightCenterOffset: {
193− var itemMapped = root.mapToItem(currentItem, lateralPosition, 0);
186+ if (!currentItem || lateralPosition == -1 || !enableLateralChanges) return 0;
194
187
195− var distanceFromCenter = itemMapped.x - currentItem.width / 2;
188+ var itemMapped = root.mapToItem(currentItem, lateralPosition, 0);
196− if (distanceFromCenter > 0) {
197− distanceFromCenter = Math.max(0, distanceFromCenter - currentItem.width / 8);
198− } else {
199− distanceFromCenter = Math.min(0, distanceFromCenter + currentItem.width / 8);
200− }
201
189
202− if (currentItem && currentItem.ownIndex === 0 && distanceFromCenter < 0) {
190+ var distanceFromCenter = itemMapped.x - currentItem.width / 2;
203− highlight.highlightCenterOffset = 0;
204− } else if (currentItem && currentItem.ownIndex === repeater.count-1 & distanceFromCenter > 0) {
191+ if (distanceFromCenter > 0) {
205− highlight.highlightCenterOffset = 0;
192+ distanceFromCenter = Math.max(0, distanceFromCenter - currentItem.width / 8);
206− } else {
193+ } else {
207− highlight.highlightCenterOffset = (distanceFromCenter / (currentItem.width / 4)) * units.gu(1);
194+ distanceFromCenter = Math.min(0, distanceFromCenter + currentItem.width / 8);
208− }
209 }
195 }
210− }
211
196
212− property real highlightCenterOffset: 0
197+ if (currentItem && currentItem.ownIndex === 0 && distanceFromCenter < 0) {
198+ return 0;
199+ } else if (currentItem && currentItem.ownIndex === repeater.count-1 & distanceFromCenter > 0) {
200+ return 0;
201+ }
202+ return (distanceFromCenter / (currentItem.width / 4)) * units.gu(1);
203+ }
213 Behavior on highlightCenterOffset {
204 Behavior on highlightCenterOffset {
214 NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
205 NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
215 }
206 }
216
207
217− property real currentItemX: currentItem ? currentItem.x : 0 // having Behavior
208+ property real currentItemX: currentItem ? currentItem.x : 0
218 Behavior on currentItemX {
209 Behavior on currentItemX {
219 id: currentItemXBehavior
210 id: currentItemXBehavior
220 enabled: !d.firstItemSwitch && expanded
211 enabled: !d.firstItemSwitch && expanded