on xenial help sign in
delayed left alignment.
344ec10Nick Dedekind
qml/Panel/IndicatorItemRow.qml+20−13
@@ -35,15 +35,19 @@ Item {
35
35
36 property real lateralPosition: -1
36 property real lateralPosition: -1
37 onLateralPositionChanged: {
37 onLateralPositionChanged: {
38− if (lateralPosition == -1) return;
38+ if (currentItem && !enableLateralChanges) return;
39+ updateItemFromLateralPosition(lateralPosition);
40+ highlight.updateHighlightOffset();
41+ }
42+
43+ function updateItemFromLateralPosition(lateralPosition) {
44+ if (lateralPosition === -1) return;
39
45
40 if (!currentItem) {
46 if (!currentItem) {
41 selectItemAt(lateralPosition);
47 selectItemAt(lateralPosition);
42 return;
48 return;
43 }
49 }
44
50
45− if (!enableLateralChanges) return;
46−
47 var maximumBufferOffset = selectionChangeBuffer * unitProgress;
51 var maximumBufferOffset = selectionChangeBuffer * unitProgress;
48 var proposedItem = indicatorAt(lateralPosition, 0);
52 var proposedItem = indicatorAt(lateralPosition, 0);
49 if (proposedItem) {
53 if (proposedItem) {
@@ -177,9 +181,11 @@ Item {
177
181
178 // 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
179 // the handle downwards.
183 // the handle downwards.
180− property real highlightCenterOffset: {
184+ function updateHighlightOffset() {
181− if (!currentItem || lateralPosition == -1) return 0;
185+ if (!currentItem || lateralPosition == -1) {
182− if (!enableLateralChanges) return 0;
186+ highlightCenterOffset = 0;
187+ return;
188+ }
183
189
184 var itemMapped = root.mapToItem(currentItem, lateralPosition, 0);
190 var itemMapped = root.mapToItem(currentItem, lateralPosition, 0);
185
191
@@ -191,24 +197,25 @@ Item {
191 }
197 }
192
198
193 if (currentItem && currentItem.ownIndex === 0 && distanceFromCenter < 0) {
199 if (currentItem && currentItem.ownIndex === 0 && distanceFromCenter < 0) {
194− return 0;
200+ highlightCenterOffset = 0;
195 } else if (currentItem && currentItem.ownIndex === repeater.count-1 & distanceFromCenter > 0) {
201 } else if (currentItem && currentItem.ownIndex === repeater.count-1 & distanceFromCenter > 0) {
196− return 0;
202+ highlightCenterOffset = 0;
203+ } else {
204+ var shiftPercentageOffset = (distanceFromCenter / (currentItem.width / 4));
205+ highlightCenterOffset = shiftPercentageOffset * units.gu(1);
197 }
206 }
198
207
199− var shiftPercentageOffset = (distanceFromCenter / (currentItem.width / 4));
200− return shiftPercentageOffset * units.gu(1);
201 }
208 }
209+ property real highlightCenterOffset: 0
202 Behavior on highlightCenterOffset {
210 Behavior on highlightCenterOffset {
203− id: highlightCetnerOffsetBehavior
204− SmoothedAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
211+ NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
205 }
212 }
206
213
207 property real currentItemX: currentItem ? currentItem.x : 0 // having Behavior
214 property real currentItemX: currentItem ? currentItem.x : 0 // having Behavior
208 Behavior on currentItemX {
215 Behavior on currentItemX {
209 id: currentItemXBehavior
216 id: currentItemXBehavior
210 enabled: !d.firstItemSwitch && expanded
217 enabled: !d.firstItemSwitch && expanded
211− SmoothedAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
218+ NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
212 }
219 }
213 x: currentItemX + highlightCenterOffset
220 x: currentItemX + highlightCenterOffset
214 }
221 }
qml/Panel/IndicatorsBar.qml+18−4
@@ -36,6 +36,11 @@ Item {
36 row.selectItemAt(mapped.x);
36 row.selectItemAt(mapped.x);
37 }
37 }
38
38
39+ function updateItemFromLateralPosition(position) {
40+ var mapped = root.mapToItem(row, position, 0);
41+ row.updateItemFromLateralPosition(mapped.x);
42+ }
43+
39 function setCurrentItemIndex(index) {
44 function setCurrentItemIndex(index) {
40 if (!expanded) {
45 if (!expanded) {
41 row.resetCurrentItem();
46 row.resetCurrentItem();
@@ -43,10 +48,8 @@ Item {
43 row.setCurrentItemIndex(index);
48 row.setCurrentItemIndex(index);
44 }
49 }
45
50
46− function alignLeft() {
51+ function alignIndicatorsToLeft() {
47− if (row.x > 0) {
52+ alignmentTimer.start()
48− d.rowOffsetAdjustment = -row.x;
49− }
50 }
53 }
51
54
52 function addScrollOffset(scrollAmmout) {
55 function addScrollOffset(scrollAmmout) {
@@ -176,6 +179,17 @@ Item {
176 }
179 }
177 }
180 }
178
181
182+ Timer {
183+ id: alignmentTimer
184+ interval: UbuntuAnimation.SnapDuration // enough for row animation.
185+ repeat: false
186+ onTriggered: {
187+ if (expanded && row.x > 0) {
188+ d.rowOffsetAdjustment = -row.x;
189+ }
190+ }
191+ }
192+
179 states: [
193 states: [
180 State {
194 State {
181 name: "minimized"
195 name: "minimized"