简体   繁体   中英

iScroll works only after rotating to landscape and back to portarit

I have a Twitter bootstrap 3 site, it works well except Android 2.3 browsers.
In my fixed navbar I have a button that opens a div (collapsible) and a list of links appear. But in Android 2.3 list is opened, but all list is not visible, only the half of them visible. Scrollbar doesn't appear and touching the menu doesn't respond.

So after some research I started to use iScroll 5 . But Scrolling doesn't work when the page loaded. iScroll works when I flip device to landscape and then back to portrait.

<script type="text/javascript" src="/scripts/iscroll.js"></script>
<div class="my_polyfill">
    <ul>
        <li>...</li>
        <li>...</li>
        ...
    </ul>
</div>

I added viewport:

<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">

I added a timeout like this:

$(window).load(function() {
    setTimeout( function() {  var myScroll = new IScroll('.my_polyfill'); }, 4000);
}

But still iScroll works when I make a portrait-landscape-portrait flip. How can I fix this ? Or debug the problem.

页面渲染完成后,添加myScroll.refresh()。

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