[Interest] Customized scrolling

jensbw at gmail.com jensbw at gmail.com
Tue Nov 25 10:56:24 CET 2014


> On 24 Nov 2014, at 20:14, Federico Buti <bacarozzo at gmail.com> wrote:
> 
> Hi all.
> 
> The "add", "remove" and the other Transition properties of the Views enable a nice customization for the animation of items w.r.t. their view.
> What about scrolling? Is is possible to customize the way items behave on View scroll? Something like this for instance. 
> 
> What elements to be used? I had an example (which I modified) that applys transformations on the currently selected item, so no gradual transformations like in the example. 
> 
> I think that it is necessary to define a Behaviour on the y property of each item to apply a specific Transition. But how to obtain the y poisiton w.r.t. to the view? MapfromItem()? Where to store it, since saving it as a property inside the delegate seems not a good idea at all?

It’s not a problem declaring such properties inside your delegate. Delegates are are unique objects with theirs own state in QML. A fairly simple way of doing it is like this:

     ListView {
        id: list
        model: 100
        anchors.fill: parent
        delegate: Rectangle {
            property int listY: y - list.contentY
            scale: Math.min(1, listY/100)
            width: parent.width ; height: 30
            border.color: "lightgray"
        }
    }

Regards,

Jens


More information about the Interest mailing list