When I select an partially visible item/row in a vertical Spark List the
item will scroll into view but only the bare minimum. So if there are 5 rows
on the screen and I click row 3, 4 or 5 then that row will expand but it
will usually stay at the Y position it is at leaving rows 1 and 2 visible
above it. I'd like to make sure that the row that is selected is flush
against the top edge of the List.

Is the only way to prevent the List from auto scrolling that item into view
to extend and override that method? I believe the method is that is doing
this is called ensureIndexIsVisible().

I've been able to position it flush against the top without overriding the
above method but then there are two tweens going on and it doesn't always
position correctly or look right.

Here is the code I've been using in the List changing event handler:
var newRow:DisplayObject = list.dataGroup.getChildAt(newIndex);

if (newIndex != contentCount) {
itemY = newRow.y;
itemY -= oldIndex < newIndex ? oldRow.height - newRow.height : 0;
}
else {
itemY = maxVerticalScrollPosition;
}

// move item to the top of the list
TweenLite.to(list.dataGroup, 1.5, {verticalScrollPosition:itemY});

JP

Reply via email to