繁体   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