javascript - Add an element to a repeater with animation -
i have repeater elements animated when created.
repeater { model : 0 image { ... animation { ... } } }
everything working if add element model after previous element's animation finished. dowsn't work if add eleent before. example, if had gun shoots bullet, if wait until animation of bullet ends works. if want shoot bullet before first ends, first disappears , see animation of second.
what should see animations?
maybe have issue model or delegate, or layouting (items overlapping...), cause here, works fine :
import qtquick 2.0; rectangle { width: 400; height: 300; timer { running: true; repeat: true; interval: 1000; ontriggered: { modeltest.append ({ "bg" : qt.hsla (math.random (), 0.85, 0.45, 1.0).tostring () }); } } flow { anchors.fill: parent; repeater { model: listmodel { id: modeltest; } delegate: rectangle { id: rect; color: model.bg; width: 50; height: width; scale: 0.0; propertyanimation { target: rect; property: "scale"; from: 0.0; to: 1.0; duration: 450; running: true; loops: 1; } } } } }
remember listmodel , qabstractlistmodel able add dynamically new items without resetting whole delegates, other (variant list, js array, numbers) cause delegates re-instanciated @ each model modification...
Comments
Post a Comment