开发者

Is there a way to disable the scrollbar / list bounce effect in flex 4.5 (mobile)?

I'm trying to make my own component that behaves like a list and supports infinite scrolling (in 1-dimension : vertical or horizontal) - both directions. For eg, a vertically laid out list which the user can scroll up or down forever - without ever hitting the 'last' or 'first' item. A good use for this: a calendar that displays each month as a list item.

Anyway, there are a bunch of things to overcome. The first of which, I think,开发者_高级运维 is to disable the scrollbar's bounce effects (introduced in the latest Flex 4.5 (mobile) SDK).

If I can disable the bounce effects, I'm guessing I can then add/remove items as needed to the list and it would scroll infinitely.

Any ideas?

Krishna


Personally, an infinite list would mean a lot of rework of the core List component. It's a lot of work to reverse engineer and you'll probably hit a wall. I think what you want to do is create a component from scratch and extends SkinnableContainer.

From here on out, you need to decide how to implement and what's the user interaction for an infinite list, then need to implement proper practices and reuse your item renderers.


From my experience, you can simply implement the lazy loading on the List component by adding property change event to the viewport of the list's dataGroup

list.dataGroup.addEventListener( PropertyChangeEvent.PROPERTY_CHANGE, onScrollPropertyChangeHandler );

Then in the event, listen to the vertical scroll position

if ( event.property == "verticalScrollPosition" ){
    var listHeight:Number = itemList.height;
    var curAnchorPoint:Number = event.newValue + listHeight; 
    var bottomPositionToLoad:Number = 200; // Start loading when the list nearly reach the bottom minus 200
    var anchorToLoadNextPage:Number = itemList.dataGroup.contentHeight - bottomPositionToLoad;

    if(curAnchorPoint >= anchorToLoadNextPage){
    loadNextPage(); 
    }
}

When loadNextPage() is running, remember to remove the property change event so the loadNextPage will not be called multiple times.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜