Details
-
Suggestion
-
Resolution: Done
-
P2: Important
-
5.0.0
-
None
-
79608d6f72ea5963aed2fa161b9ef6781adbc41e
Description
The purpose of the code below is to show how the movement of the items in a
grid could be staggered. There are currently two problems preventing this from working:
1) the "index" of the item that the Transition is applied to is not available in the scope of the Transition
2) the Transition is only executed once, rather than once per item that moves
import QtQuick 2.0 Rectangle { width: 320 height: 480 property int deletedItemIndex: 0 ListModel { id: theModel } Component.onCompleted: { for(var i = 0; i < 20; i++) { theModel.append( {} ); } } Grid { anchors.centerIn: parent spacing: 10 move: Transition { SequentialAnimation { ScriptAction { script: print("#### Grid's move-transition item index: " + index) } NumberAnimation { properties: "x, y"; duration: 300 + Math.max(index-deletedItemIndex, 0)*50 } } } Repeater { model: theModel delegate: Rectangle { width: 60; height: 60; color: "blue" MouseArea { anchors.fill: parent onClicked: { deletedItemIndex = index; theModel.remove(index); } } } } } }