diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2011-09-09 14:15:41 +0200 |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2011-09-09 14:15:41 +0200 |
commit | 96dbfb9d9d239d9fe957d8b8a889a708e83014d1 (patch) | |
tree | 89c1ad36fb75d49e42f0ae0d176d1b11c14cf229 | |
parent | 3962bb5474d0cabf52d202eea6e1afdfd1a61981 (diff) |
Make it possible to implement forward and backward transition.
-rw-r--r-- | examples/customtransition/OpacityTransitionPresentation.qml | 43 | ||||
-rw-r--r-- | examples/customtransition/SlideDeck.qml | 2 | ||||
-rw-r--r-- | src/Presentation.qml | 8 |
3 files changed, 30 insertions, 23 deletions
diff --git a/examples/customtransition/OpacityTransitionPresentation.qml b/examples/customtransition/OpacityTransitionPresentation.qml index 71dece7..17cd546 100644 --- a/examples/customtransition/OpacityTransitionPresentation.qml +++ b/examples/customtransition/OpacityTransitionPresentation.qml @@ -62,32 +62,36 @@ Presentation { } SequentialAnimation { - id: transition - ScriptAction { script: { - deck.inTransition = true - fromSlide.opacity = 0 - toSlide.visible = true - } - } - + id: forwardTransition + PropertyAction { target: deck; property: "inTransition"; value: true } + PropertyAction { target: toSlide; property: "visible"; value: true } ParallelAnimation { NumberAnimation { target: fromSlide; property: "opacity"; from: 1; to: 0; duration: deck.transitionTime; easing.type: Easing.OutQuart } NumberAnimation { target: fromSlide; property: "scale"; from: 1; to: 1.1; duration: deck.transitionTime; easing.type: Easing.InOutQuart } NumberAnimation { target: toSlide; property: "opacity"; from: 0; to: 1; duration: deck.transitionTime; easing.type: Easing.InQuart } NumberAnimation { target: toSlide; property: "scale"; from: 0.7; to: 1; duration: deck.transitionTime; easing.type: Easing.InOutQuart } } - - ScriptAction { script: { - deck.inTransition = false - fromSlide.visible = false - fromSlide.opacity = 0 - fromSlide.scale = 1 - toSlide.opacity = 1 - } + PropertyAction { target: fromSlide; property: "visible"; value: false } + PropertyAction { target: fromSlide; property: "scale"; value: 1 } + PropertyAction { target: deck; property: "inTransition"; value: false } + } + SequentialAnimation { + id: backwardTransition + running: false + PropertyAction { target: deck; property: "inTransition"; value: true } + PropertyAction { target: toSlide; property: "visible"; value: true } + ParallelAnimation { + NumberAnimation { target: fromSlide; property: "opacity"; from: 1; to: 0; duration: deck.transitionTime; easing.type: Easing.OutQuart } + NumberAnimation { target: fromSlide; property: "scale"; from: 1; to: 0.7; duration: deck.transitionTime; easing.type: Easing.InOutQuart } + NumberAnimation { target: toSlide; property: "opacity"; from: 0; to: 1; duration: deck.transitionTime; easing.type: Easing.InQuart } + NumberAnimation { target: toSlide; property: "scale"; from: 1.1; to: 1; duration: deck.transitionTime; easing.type: Easing.InOutQuart } } + PropertyAction { target: fromSlide; property: "visible"; value: false } + PropertyAction { target: fromSlide; property: "scale"; value: 1 } + PropertyAction { target: deck; property: "inTransition"; value: false } } - function switchSlides(from, to) + function switchSlides(from, to, forward) { if (deck.inTransition) return false @@ -95,7 +99,10 @@ Presentation { deck.fromSlide = from deck.toSlide = to - transition.running = true; + if (forward) + forwardTransition.running = true + else + backwardTransition.running = true return true } diff --git a/examples/customtransition/SlideDeck.qml b/examples/customtransition/SlideDeck.qml index 69f6827..0a994cc 100644 --- a/examples/customtransition/SlideDeck.qml +++ b/examples/customtransition/SlideDeck.qml @@ -41,7 +41,7 @@ OpacityTransitionPresentation { Slide { title: "Custom Transitions, 1" - centeredText: "The Presentation {} Element has a 'switchSlides(from, to)' function which will be called whenever a transition between slides should take place." + centeredText: "The Presentation {} Element has a 'switchSlides(from, to, forward)' function which will be called whenever a transition between slides should take place." } Slide { diff --git a/src/Presentation.qml b/src/Presentation.qml index ef788b5..c850408 100644 --- a/src/Presentation.qml +++ b/src/Presentation.qml @@ -66,7 +66,7 @@ Item { } } - function switchSlides(from, to) { + function switchSlides(from, to, forward) { from.visible = false to.visible = true return true @@ -79,7 +79,7 @@ Item { if (root.currentSlide + 1 < root.slides.length) { var from = slides[currentSlide] var to = slides[currentSlide + 1] - if (switchSlides(from, to)) { + if (switchSlides(from, to, true)) { currentSlide = currentSlide + 1; root.focus = true; } @@ -93,7 +93,7 @@ Item { if (root.currentSlide - 1 >= 0) { var from = slides[currentSlide] var to = slides[currentSlide - 1] - if (switchSlides(from, to)) { + if (switchSlides(from, to, false)) { currentSlide = currentSlide - 1; root.focus = true; } @@ -109,7 +109,7 @@ Item { else if (root.currentSlide != userNum) { var from = slides[currentSlide] var to = slides[userNum] - if (switchSlides(from, to)) { + if (switchSlides(from, to, userNum > currentSlide)) { currentSlide = userNum; root.focus = true; } |