andreyzenkov
andreyzenkov

Reputation: 91

cordova window.pageYOffset always return 0

It is possible to get window.pageYOffset at cordova? Are there alternatives $(window).scrollTop?

Can I scroll to a concrete position in pixels using cordova?

For example like $(window).scrollTop(100)?

Upvotes: 1

Views: 644

Answers (1)

Hashan Seneviratne
Hashan Seneviratne

Reputation: 1177

After spending so many hours found the solution for this. You can use $(document).scrollTop(). But this applies to all the pages in the app. So you can make it happen to the specific page you want as shown below.

$(document).scroll(function(){
    var activePage = $.mobile.pageContainer.pagecontainer("getActivePage");
    if(activePage[0].id == "pageID");{
        var ypos = $(this).scrollTop();
        alert(ypos);        
    }   
});

You can scroll to a concrete position using the same way.

Hope this helps.

Upvotes: 1

Related Questions