簡體   English   中英

iScroll繼續向上滾動(Phonegap)

[英]iScroll keeps scrolling back up (Phonegap)

程序:Eclipse(Phonegap)

電話:HTC Desire(2.2.2)

我已經使用iscroll插件玩了一段時間了,但是看來我無法正常工作。 當我在android模擬器和手機中對其進行測試時,它會一直滾動回到頂部。 LogCat也提供以下行:

“在等待webcore對降落的響應時,這很拖累”

Javascript:

<script type="text/javascript">
    var theScroll;
    function scroll() {
       theScroll = new iScroll('scroll-content', { snap:true, momentum:false, hScrollbar:false, vScrollbar:false});
       setTimeout(function () { theScroll.refresh() }, 0); 
    }
    document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
    document.addEventListener('DOMContentLoaded', scroll, false);
</script>

HTML:

    <div id="wrapper">

            <div id="main-content">
                <div id="pages">

                    <div id="map" class="current">  

                    </div>

                    <div id="camera">
                        <button class="camera-control" onclick="capturePhoto();">Capture Photo</button>

                        <div style="text-align:center; margin:20px 0 0 0;">
                            <img id="cameraPic" src="" style="width:50%; height: 50%;"/>
                        </div>
                    </div>

                    <div id="buzz"> 
                           <div id="scroll-content">                
                            <ul id="your-tweets"></ul>
                           </div>                           
                    </div>

                    <div id="info">
                        <p>Informatie Evident</p>
                    </div>  
                </div>
            </div>

    </div>

我正在用JSON調用的推文填充列表。 希望有人能為您服務!

完整的iScroll語法為:iScroll(element_id,對象選項)。 選項在這里 在選項中,有bounceLock(如果設置為true,則滾動條將在內容小於可見區域時停止彈跳。默認值為false)。

希望這是您正在尋找的

為了避免滾動到頂部,您需要在第一次“顯示”元素之后創建滾動對象。 要將數據動態添加到此元素並使用滾動條保持適當的滾動,則可以在每次將數據添加到列表之后使用以下腳本:

    var myScroll = null; //set this initially
    // Check if scroll has been created, if so, destroy and recreate
    if (myScroll != null){
            myScroll.destroy();
        }
        myScroll = new iScroll('call-list', { desktopCompatibility: true, vScroll: true, hScroll: false, hScrollbar: false, lockDirection: true });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM