On Thu, Feb 3, 2011 at 5:39 PM, <[email protected]> wrote: > Ah yes, > > It seems so simple now. I actually did not know (or had forgotten) that QML > generates onSomePropertyChanged on property someProperty. And so in my > particular predicament you write something like this: > > Component { > id: listDelegate > > Item { > ... > property bool isVisible : (((index * height) >= > ListView.view.contentY && > (index * height) <= > ListView.view.contentBottom) || > ((index * height) + height >= > ListView.view.contentY && > (index * height) + height <= > ListView.view.contentBottom)) > > onIsVisibleChanged: { if (isVisible && ListView.view.moving) > triggerSomeAction(); } > } > } > > Note that you can't match list item's y property against ListView's contentY, > as both are in their local coordinates.
Keep in mind that the javascript monster (sorry :D) will get evaluated on every frame of the scrolling animation as many times as there are instantiated delegates (having cacheBuffer naturally makes things worse). I don't know what platform you're targeting, but at least on Symbian you have to be careful in order to get good performance. I think it might be feasible to do these types of things also in c++ side. All the properties you can use in javascript are also available in the c++ side by using the metaobject system and pointers of qml elements can be passed as parameters to c++ methods. I guess the delegates should get an insideListViewBounds attached property or something (don't know though what the overhead is for cases where it's not needed). If you take into consideration what Adriano said about the coordinates you should be able to simplify the logic a bit. Also wouldn't it be simpler to organize the logic so that you're checking for non-visibility rather than visibility? I mean check that the delegate y + height is less than contentY or delegate y is more than the content bottom and then do a ! in the onChanged handler. Juha _______________________________________________ Qt-qml mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt-qml
