Reworked preview animation
[harmattan/cameraplus] / qml / PreviewImage.qml
index e70509e..31d6234 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
-import com.nokia.meego 1.1
+import QtQuick 2.0
 import QtCamera 1.0
 
 Image {
     id: image
-    anchors.fill: parent
+    x: 0
+    y: 0
+    width: parent.width
+    height: parent.height
     property alias animationRunning: animation.running
 
-    visible: opacity != 0
-
     cache: false
     fillMode: Image.PreserveAspectFit
 
@@ -41,16 +41,24 @@ Image {
 
     SequentialAnimation {
         id: animation
+
+        onRunningChanged: {
+            if (!running) {
+                image.visible = false
+                image.x = 0
+            }
+        }
+
         PauseAnimation {
-            duration: 500
+            duration: 250
             alwaysRunToEnd: true
         }
 
         NumberAnimation {
-            target: preview
-            property: "opacity"
-            from: 1
-            to: 0
+            target: image
+            property: "x"
+            from: 0
+            to: parent.width
             duration: 250
             alwaysRunToEnd: true
         }
@@ -58,7 +66,8 @@ Image {
 
     function setPreview(preview) {
         image.source = preview
-        image.opacity = 1
+        image.x = 0
+        image.visible = true
         animation.start()
     }
 }