on xenial help sign in
Update animations on open/close
e6c8496Andrea Cimitan
qml/Dash/Previews/PreviewImageGallery.qml+22−8
@@ -67,9 +67,9 @@ PreviewWidget {
67 anchors.fill: parent
67 anchors.fill: parent
68 onClicked: {
68 onClicked: {
69 slideShowListView.currentIndex = index;
69 slideShowListView.currentIndex = index;
70− slideShow.initialX = rootItem.mapFromItem(parent, 0, 0).x
70+ slideShow.initialX = rootItem.mapFromItem(parent, 0, 0).x;
71− slideShow.initialY = rootItem.mapFromItem(parent, 0, 0).y
71+ slideShow.initialY = rootItem.mapFromItem(parent, 0, 0).y;
72− slideShow.visible = true;
72+ slideShow.open();
73 }
73 }
74 }
74 }
75 }
75 }
@@ -83,13 +83,15 @@ PreviewWidget {
83 readonly property real scaleProgress: (scale - initialScale) / (1.0 - initialScale)
83 readonly property real scaleProgress: (scale - initialScale) / (1.0 - initialScale)
84 property real initialX: 0
84 property real initialX: 0
85 property real initialY: 0
85 property real initialY: 0
86+ property bool opened: false
87+ property bool opening: false
86
88
87 parent: rootItem
89 parent: rootItem
88 width: parent.width
90 width: parent.width
89 height: parent.height
91 height: parent.height
90− visible: false
92+ visible: scale > initialScale
91 clip: visible && scale < 1.0
93 clip: visible && scale < 1.0
92− scale: visible ? 1.0 : initialScale
94+ scale: opened ? 1.0 : initialScale
93 transformOrigin: Item.TopLeft
95 transformOrigin: Item.TopLeft
94 transform: Translate {
96 transform: Translate {
95 x: slideShow.initialX - slideShow.initialX * slideShow.scaleProgress
97 x: slideShow.initialX - slideShow.initialX * slideShow.scaleProgress
@@ -98,9 +100,21 @@ PreviewWidget {
98 color: "black"
100 color: "black"
99 radius: units.gu(1) - units.gu(1) * slideShow.scaleProgress
101 radius: units.gu(1) - units.gu(1) * slideShow.scaleProgress
100
102
103+ function open() {
104+ opening = true;
105+ opened = true;
106+ }
107+
108+ function close() {
109+ opening = false;
110+ opened = false;
111+ }
112+
101 Behavior on scale {
113 Behavior on scale {
102− enabled: !slideShow.visible
114+ UbuntuNumberAnimation {
115+ duration: slideShow.opening ? UbuntuAnimation.FastDuration :
103− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
116+ UbuntuAnimation.FastDuration / 3
117+ }
104 }
118 }
105
119
106 Flickables.ListView {
120 Flickables.ListView {
@@ -160,7 +174,7 @@ PreviewWidget {
160 width: units.gu(8)
174 width: units.gu(8)
161 height: width
175 height: width
162
176
163− onClicked: slideShow.visible = false
177+ onClicked: slideShow.close()
164
178
165 Rectangle {
179 Rectangle {
166 anchors.fill: parent
180 anchors.fill: parent
qml/Dash/Previews/PreviewZoomableImage.qml+22−8
@@ -46,9 +46,9 @@ PreviewWidget {
46 id: mouseArea
46 id: mouseArea
47 anchors.fill: parent
47 anchors.fill: parent
48 onClicked: {
48 onClicked: {
49− zoomableImageContainer.initialX = rootItem.mapFromItem(parent, 0, 0).x
49+ zoomableImageContainer.initialX = rootItem.mapFromItem(parent, 0, 0).x;
50− zoomableImageContainer.initialY = rootItem.mapFromItem(parent, 0, 0).y
50+ zoomableImageContainer.initialY = rootItem.mapFromItem(parent, 0, 0).y;
51− zoomableImageContainer.visible = true;
51+ zoomableImageContainer.open();
52 }
52 }
53 }
53 }
54 }
54 }
@@ -61,13 +61,15 @@ PreviewWidget {
61 readonly property real scaleProgress: (scale - initialScale) / (1.0 - initialScale)
61 readonly property real scaleProgress: (scale - initialScale) / (1.0 - initialScale)
62 property real initialX: 0
62 property real initialX: 0
63 property real initialY: 0
63 property real initialY: 0
64+ property bool opened: false
65+ property bool opening: false
64
66
65 parent: rootItem
67 parent: rootItem
66 width: parent.width
68 width: parent.width
67 height: parent.height
69 height: parent.height
68− visible: false
70+ visible: scale > initialScale
69 clip: visible && scale < 1.0
71 clip: visible && scale < 1.0
70− scale: visible ? 1.0 : initialScale
72+ scale: opened ? 1.0 : initialScale
71 transformOrigin: Item.TopLeft
73 transformOrigin: Item.TopLeft
72 transform: Translate {
74 transform: Translate {
73 x: zoomableImageContainer.initialX - zoomableImageContainer.initialX * zoomableImageContainer.scaleProgress
75 x: zoomableImageContainer.initialX - zoomableImageContainer.initialX * zoomableImageContainer.scaleProgress
@@ -76,9 +78,21 @@ PreviewWidget {
76 color: "black"
78 color: "black"
77 radius: units.gu(1) - units.gu(1) * zoomableImageContainer.scaleProgress
79 radius: units.gu(1) - units.gu(1) * zoomableImageContainer.scaleProgress
78
80
81+ function open() {
82+ opening = true;
83+ opened = true;
84+ }
85+
86+ function close() {
87+ opening = false;
88+ opened = false;
89+ }
90+
79 Behavior on scale {
91 Behavior on scale {
80− enabled: !zoomableImageContainer.visible
92+ UbuntuNumberAnimation {
93+ duration: zoomableImageContainer.opening ? UbuntuAnimation.FastDuration :
81− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
94+ UbuntuAnimation.FastDuration / 3
95+ }
82 }
96 }
83
97
84 ZoomableImage {
98 ZoomableImage {
@@ -114,7 +128,7 @@ PreviewWidget {
114 width: units.gu(8)
128 width: units.gu(8)
115 height: width
129 height: width
116
130
117− onClicked: zoomableImageContainer.visible = false
131+ onClicked: zoomableImageContainer.close()
118
132
119 Rectangle {
133 Rectangle {
120 anchors.fill: parent
134 anchors.fill: parent
tests/qmltests/Dash/Previews/tst_PreviewImageGallery.qml+2−1
@@ -53,7 +53,8 @@ Rectangle {
53 property Item slideShowListView: findChild(slideShow, "slideShowListView")
53 property Item slideShowListView: findChild(slideShow, "slideShowListView")
54
54
55 function cleanup() {
55 function cleanup() {
56− slideShow.visible = false;
56+ slideShow.close();
57+ tryCompare(slideShow, "visible", false);
57 imageGallery.widgetData = sourcesModel1;
58 imageGallery.widgetData = sourcesModel1;
58 waitForRendering(imageGallery);
59 waitForRendering(imageGallery);
59 }
60 }
tests/qmltests/Dash/Previews/tst_PreviewZoomableImage.qml+2−1
@@ -53,7 +53,8 @@ Rectangle {
53 }
53 }
54
54
55 function cleanup() {
55 function cleanup() {
56− zoomableImageContainer.visible = false;
56+ zoomableImageContainer.close();
57+ tryCompare(zoomableImageContainer, "visible", false);
57 zoomableImage.widgetData = widgetData0;
58 zoomableImage.widgetData = widgetData0;
58 }
59 }
59
60