@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013,2016 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -70,15 +70,16 @@ SwipeArea {
7070 property: "targetValue"
7171 duration: 150
7272 velocity: -1
73− to: Direction.isPositive(direction) ? d.startValue + hintDisplacement
74− : d.startValue - hintDisplacement
73+
74+ to: d.incrementTargetProp ? d.startValue + hintDisplacement
75+ : d.startValue - hintDisplacement
7576 property real targetValue
7677 onTargetValueChanged: {
7778 if (!running) {
7879 return;
7980 }
8081
81− if (Direction.isPositive(direction)) {
82+ if (d.incrementTargetProp) {
8283 if (parent[d.targetProp] < targetValue) {
8384 parent[d.targetProp] = targetValue;
8485 }
@@ -93,19 +94,24 @@ SwipeArea {
9394 // Private stuff
9495 QtObject {
9596 id: d
97+
98+ // Whether movement along the designated direction will increment the value of the target property
99+ readonly property bool incrementTargetProp: (Direction.isPositive(direction) && !dragArea.stretch)
100+ || (dragArea.stretch && !d.dragParent.shown)
101+
96102 property real startValue
97103 property real minValue: {
98104 if (direction == Direction.Horizontal) {
99105 return startValue - maxTotalDragDistance;
100− } else if (Direction.isPositive(direction)) {
106+ } else if (incrementTargetProp) {
101107 return startValue;
102108 } else {
103109 return startValue - maxTotalDragDistance;
104110 }
105111 }
106112
107− property real maxValue: Direction.isPositive(direction) ? startValue + maxTotalDragDistance
108− : startValue
113+ property real maxValue: incrementTargetProp ? startValue + maxTotalDragDistance
114+ : startValue;
109115
110116 property var dragParent: dragArea.parent
111117
@@ -127,7 +133,7 @@ SwipeArea {
127133 }
128134
129135 // we should not go behind hintingAnimation's current value
130− if (Direction.isPositive(direction)) {
136+ if (d.incrementTargetProp) {
131137 if (d.startValue + diff < hintingAnimation.targetValue) {
132138 diff = hintingAnimation.targetValue - d.startValue;
133139 }
@@ -180,6 +186,20 @@ SwipeArea {
180186 if (dragging) {
181187 if (!Direction.isPositive(direction))
182188 distance = -distance;
189+
190+ if (dragArea.stretch &&
191+ ((!Direction.isPositive(direction) && !d.dragParent.shown)
192+ ||
193+ (Direction.isPositive(direction) && d.dragParent.shown))
194+ )
195+ {
196+ // This happens when you have a stretching showable being shown from the right or
197+ // top edge (and consequently being hidden when dragged towards the right/top edge)
198+ // In those situations, dimension expansion/retraction happens in the opposite
199+ // sign of the axis direction
200+ distance = -distance;
201+ }
202+
183203 var toAdd = d.limitMovement(distance);
184204 parent[d.targetProp] = d.startValue + toAdd;
185205 }