@@ -0,0 +1,97 @@
2+import Ubuntu.Components 1.3
3+import "../../Components"
7+ onPressed: mouse.accepted = true;
10+ property bool closeable: true
12+ property bool moving: false
13+ property real distance: 0
14+ readonly property int threshold: units.gu(2)
15+ property int offset: 0
17+ readonly property real minSpeedToClose: units.gu(40)
27+ onDragValueChanged: {
31+ moving = moving || Math.abs(dragValue) > threshold;
33+ distance = dragValue + offset;
39+ offset = (dragValue > 0 ? -threshold: threshold)
46+ if (!root.closeable) {
47+ animation.animate("center")
51+ // velocity and distance values specified by design prototype
52+ if ((dragVelocity < -minSpeedToClose && distance < -units.gu(8)) || distance < -root.height / 2) {
53+ animation.animate("up")
54+ } else if ((dragVelocity > minSpeedToClose && distance > units.gu(8)) || distance > root.height / 2) {
55+ animation.animate("down")
57+ animation.animate("center")
61+ UbuntuNumberAnimation {
63+ objectName: "closeAnimation"
66+ property bool requestClose: false
68+ function animate(direction) {
69+ animation.from = dragArea.distance;
72+ animation.to = -root.height * 1.5;
76+ animation.to = root.height * 1.5;
87+ dragArea.moving = false;
91+ dragArea.distance = 0;