Inspired a bit by Windows 8 "Modern UI" applications, I would like to apply an animation to all QML elements in a page when the page loads. This way each individual element on the page animates when it appears.
I can't seem to find anything in the QML documentation that would help. In XAML, I could accomplish this with:
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<StackPanel.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition FromHorizontalOffset="100"/>
</TransitionCollection>
</StackPanel.ChildrenTransitions>
[...]
</StackPanel>
Is there a QML equivalent?
I've figured out how to do this for a single element, but I would like an easy way to apply the animation to every element of some parent like in the XAML example above. Here's my single-element implementation:
Rectangle {
id: foobar
opacity: 0.001
anchors.centerIn: parent
anchors.horizontalCenterOffset: -100
Component.onCompleted: {
foobar.anchors.horizontalCenterOffset = 0
foobar.opacity = 1
}
Behavior on anchors.horizontalCenterOffset { PropertyAnimation{ duration: 250; easing.type: Easing.OutQuad } }
Behavior on opacity { NumberAnimation { property: "opacity"; to: 1; duration: 250; } }
}