scrollTo gets overridden when using jQuery Mobile

后端 未结 1 1302
小蘑菇
小蘑菇 2021-01-28 16:29

I am creating a mobile web app with jQuery Mobile and would like to hide the search bar above the visible area. So the user would need to pull the page down to see the search ba

1条回答
  •  遥遥无期
    2021-01-28 17:07

    jQuery Mobile has a special scroll function $.mobile.silentScroll(). It scrolls without animation but at the same time it doesn't trigger scroll event.

    You also need to wait until page is fully loaded into DOM before calling this function. You can bind it to pagebeforeshow or pageshow.

    $(document).on("pagebeforeshow", "#page", function () {
        setTimeout(function () {
            $.mobile.silentScroll(100);
        }, 10);
    });
    

    Demo

    0 讨论(0)
提交回复
热议问题