I want an animation to be painted when an element becomes visible (is should appear smoothly, not the whole at all)
I tried this
states: State
{
name
visibility
can be used in NumberAnimation
, but to get the needed fading result, opacity
animation could be used; like turning visibility ON from function like the following example:
Rectangle{
id:fadingRect
anchors.fill: parent
visible: false
opacity: 0.00
color: "red"
Component.onCompleted: {
animRect.start()
}
}
SequentialAnimation{
id:animRect
NumberAnimation { target: fadingRect; property: "visible"; from: 0; to:1; duration: 20}
NumberAnimation { target: fadingRect; property: "opacity"; from: 0.00; to:1.00; duration: 4000 }
onStopped: console.log(fadingRect.visible)
}
Or :
Rectangle{
id:fadingRect
anchors.fill: parent
visible: false
opacity: 1
color: "red"
Component.onCompleted: {
animRect.start()
}
NumberAnimation { id:animRect; target: fadingRect; property: "opacity"; from: 0; to:1; duration: 2000;
onStarted: { fadingRect.visible=true; console.log(fadingRect.visible)}
}
}