1

I need a blinking animation for an icon, I did this so far:

Icon{
                    id: bigLike
                    name: "like"
                    color: "white"
                    opacity: 0
                    width: parent.width / 2.5
                    height: parent.height / 2.5
                    anchors.centerIn: parent
                    PropertyAnimation { id: animationOne; target: bigLike;alwaysRunToEnd: true; property: "opacity"; to: 1; duration: 1000 }
                    PropertyAnimation { id: animationTwo; target: bigLike;alwaysRunToEnd: true; property: "opacity"; to: 0; duration: 1000 }
                }

and here I start animatons:

animationOne.start()
animationTwo.start()

But Nothing happens.

After changing parameters to this:

PropertyAnimation { id: animationOne; target: bigLike;alwaysRunToEnd: true; property: "opacity"; to: 1; duration: 1000 }
PropertyAnimation { id: animationTwo; target: bigLike;alwaysRunToEnd: true; property: "opacity"; to: 0.5; duration: 1000 }

the animation played and it changed the opacity to 0.5 without changing it to 1 first.

So it seems the problem is the animation calculate the final outcome and plays it.

The question is how to achieve the blinking animation ?

1
  • 2
    Close voters: This most certainly is about Ubuntu, it is about QML development for Ubuntu and/or Ubuntu Touch. May 7, 2015 at 9:27

1 Answer 1

1

I found a workaround, although it may not be the best way to do it but it works.

first, animations should be changed to

PropertyAnimation { id: animationOne; target: bigLike;alwaysRunToEnd: true; property: "opacity"; to: 1; duration: 500
                        onStopped: animationTwo.start()}
PropertyAnimation { id: animationTwo; target: bigLike;alwaysRunToEnd: true; property: "opacity"; to: 0; duration: 300 }

this way we are sure that the second animation (fading animation) starts after the completion of first animation.

the when starting animations we need to just start the first one:

animationOne.start()
1
  • Just to add more details, I had to add onStopped: animationOne.start() to get this working end to end - PropertyAnimation { id: animationOne; target: bigLike;alwaysRunToEnd: true; property: "opacity"; to: 1; duration: 500 onStopped: animationTwo.start()} PropertyAnimation { id: animationTwo; target: bigLike;alwaysRunToEnd: true; property: "opacity"; to: 0; duration: 300 onStopped: animationOne.start()}
    – Manohar
    Dec 24, 2019 at 11:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .