Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone
Accepted Solution

animation code works only once

[ Edited ]

Hi all,

 

import bb.cascades 1.2


Container {
    Container {
        layout: StackLayout {
            orientation: LayoutOrientation.LeftToRight
        }
        
        Label{
            overlapTouchPolicy: OverlapTouchPolicy.Allow
            text:"Initial Text"
            minWidth: 600
            animations: parallelAnimation
        }
        Container {
            overlapTouchPolicy: OverlapTouchPolicy.Allow
            layout: DockLayout {
            
            }
            ImageView {
                overlapTouchPolicy: OverlapTouchPolicy.Allow
                imageSource: "asset:///images/hotels.png"
            }
            ImageView {
                overlapTouchPolicy: OverlapTouchPolicy.Allow
                id:imgsource
                imageSource: "asset:///images/hotels.png"
                opacity: 1.0
                
                
            }
        }
        gestureHandlers: TapHandler {
            onTapped: {
                if(parallelAnimation.isPlaying()){
                    parallelAnimation.stop();
                }
                parallelAnimation.play();
            }
        }
        
        animations: [
            ParallelAnimation {
                id:parallelAnimation
                TranslateTransition {
                    id:translate
                    toX: -20
                    toY: -300
                    //duration: 1000
                }
                ScaleTransition {
                    id:scaletransition
                    toX: .2
                    toY: .2
                    //duration: 1000
                }
                FadeTransition {
                    id:fadetransition
                    toOpacity: 0
                   // duration: 1000
                }
                
                onEnded: {
                    console.log("On ended parallel animation");
                    translate.toX = 0
                    translate.toY = 0
                    scaletransition.toX=1
                    scaletransition.toY=1
                    fadetransition.toOpacity=1
                    //parallelAnimation.stop();
                }
            }
        ]
    }

}

I making the image to translate back to original poision in onEnded of ParallelAnimation but its not working. The label is visible only after tapping the container again. And further taps not playing the animation. 

 

Please help me with this.

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: animation code works only once

use a Sequential Animation:

at first run your ParallelAnimation

then the next one resetting translations

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Highlighted
Developer
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Re: animation code works only once

Yeah, its working now as your suggestion. Thanks.