简体   繁体   中英

Add Posts on Scrolling in Android+PhoneGap

I am working on application that is using JQuery Mobile and PhoneGap API for android My application has a page for news feed that displays 10 news feed at one time and then Below a button for display next 10 news feeds it works fine and display the other 10 untill all news feeds displayed Now i want it that for display next 10 posts user not click on button just scroll down and loads the other 10 posts (It is app for Android OS)

Is there any plugin or anything else that i can use My App Structure is like (in this structure One full post display)

<div id="newsfeed_52" class="postwrapper">
    <div id="post_52" class="feeds-content">
        <div class="feeds-content-header"></div>
        <div class="harvestactivity"></div>
        <div class="hs-post-actions"></div>
    </div>
</div>

Use pull to refresh of iScroll. Demo here


Example:

    <div id="wrapper">
        <div id="scroller">
            //append anything when pull up: div, ul,...
            <ul id="items">
                //Append items when pull up.
            </ul>
            <div>scroll up to add more item</div>
        </div>
    </div>

OR:

    <div id="wrapper">
        <ul id="items">
            //Append items when pull up.
        </ul>
    </div>

And in javascript:

myScroll = new iScroll('wrapper', {
    onScrollMove:function(){
        //do something when scroll move(identify position of scroll)
    },
    onScrollEnd:function(){
        //do something when scroll end(add more items)
    }
});

i did it with custom way as

$(window).scroll(function (e)
{
if( ( $.mobile.activePage[0].id == 'PageIdInWhichYouWantToAppyThis' )
{
    if ( $(document).height() == $(window).scrollTop() + $(window).height() )
    {
        //here you can auto trigger that link which previously Waiting User Click
    }
}
});

This is basic according to demo maybe I need little modifications but not major Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM