on xenial help sign in
delayed left alignment.
commit344ec1041e7b132856b128eda129a85ec61f5d4c authorNick Dedekind <nick.dedekind@canonical.com> dateThu 9 Oct 2014, 10:53 (12 years ago) parent45dbe19
2 files changed+38−17
qml/Panel/IndicatorItemRow.qml+20−13 qml/Panel/IndicatorsBar.qml+18−4
qml/Panel/IndicatorItemRow.qml+20−13
@@ -35,15 +35,19 @@ Item {
3535
3636 property real lateralPosition: -1
3737 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;
3945
4046 if (!currentItem) {
4147 selectItemAt(lateralPosition);
4248 return;
4349 }
4450
45− if (!enableLateralChanges) return;
46−
4751 var maximumBufferOffset = selectionChangeBuffer * unitProgress;
4852 var proposedItem = indicatorAt(lateralPosition, 0);
4953 if (proposedItem) {
@@ -177,9 +181,11 @@ Item {
177181
178182 // micromovements of the highlight line when user moves the finger across the items while pulling
179183 // the handle downwards.
180− property real highlightCenterOffset: {
181− if (!currentItem || lateralPosition == -1) return 0;
182− if (!enableLateralChanges) return 0;
184+ function updateHighlightOffset() {
185+ if (!currentItem || lateralPosition == -1) {
186+ highlightCenterOffset = 0;
187+ return;
188+ }
183189
184190 var itemMapped = root.mapToItem(currentItem, lateralPosition, 0);
185191
@@ -191,24 +197,25 @@ Item {
191197 }
192198
193199 if (currentItem && currentItem.ownIndex === 0 && distanceFromCenter < 0) {
194− return 0;
200+ highlightCenterOffset = 0;
195201 } 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);
197206 }
198207
199− var shiftPercentageOffset = (distanceFromCenter / (currentItem.width / 4));
200− return shiftPercentageOffset * units.gu(1);
201208 }
209+ property real highlightCenterOffset: 0
202210 Behavior on highlightCenterOffset {
203− id: highlightCetnerOffsetBehavior
204− SmoothedAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
211+ NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
205212 }
206213
207214 property real currentItemX: currentItem ? currentItem.x : 0 // having Behavior
208215 Behavior on currentItemX {
209216 id: currentItemXBehavior
210217 enabled: !d.firstItemSwitch && expanded
211− SmoothedAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
218+ NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
212219 }
213220 x: currentItemX + highlightCenterOffset
214221 }
qml/Panel/IndicatorsBar.qml+18−4
@@ -36,6 +36,11 @@ Item {
3636 row.selectItemAt(mapped.x);
3737 }
3838
39+ function updateItemFromLateralPosition(position) {
40+ var mapped = root.mapToItem(row, position, 0);
41+ row.updateItemFromLateralPosition(mapped.x);
42+ }
43+
3944 function setCurrentItemIndex(index) {
4045 if (!expanded) {
4146 row.resetCurrentItem();
@@ -43,10 +48,8 @@ Item {
4348 row.setCurrentItemIndex(index);
4449 }
4550
46− function alignLeft() {
47− if (row.x > 0) {
48− d.rowOffsetAdjustment = -row.x;
49− }
51+ function alignIndicatorsToLeft() {
52+ alignmentTimer.start()
5053 }
5154
5255 function addScrollOffset(scrollAmmout) {
@@ -176,6 +179,17 @@ Item {
176179 }
177180 }
178181
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+
179193 states: [
180194 State {
181195 name: "minimized"