LoopingViewPager icon indicating copy to clipboard operation
LoopingViewPager copied to clipboard

Request: add support for case where multiple items visible

Open stevep99 opened this issue 12 years ago • 1 comments

It is possible to use ViewPager to create a "carousel" effect, by having multiple items visible at the same time . This is typically done by setting e.g. ViewPager.setOffscreenPageLimit(3) and setting some appropriate margins.

In this mode, LoopingViewPager no longer works correctly at the transition between first and last items. This is because LoopViewPager has an internal fixed offset of 1 item, so if any more than one item is visible at once, these will not be shown correctly.

This can be fixed by allowing an arbitrary offset value to be set and changing the various hardcoded 1s to the new value, for example:

    public static int toRealPosition( int position, int count ){
        position = position-OFFSET;
        if( position < 0 ){
            position += count;
        }else{
            position = position%count;
        }
        return position;
    }

I have this working in my case, can send patch if interested.

stevep99 avatar Dec 04 '13 11:12 stevep99

stevepugh99, i'm facing the same issue. Managed to archieve the carousel effect and it works just fine, the only issue is the lag when changing between first and last items. Can you give me more info and help me implement your solution? Thanks in advance.

thalisvilela avatar Jul 03 '14 12:07 thalisvilela