简体   繁体   English

iScroll继续向上滚动(Phonegap)

[英]iScroll keeps scrolling back up (Phonegap)

Program: Eclipse (Phonegap) 程序:Eclipse(Phonegap)

Phone: HTC Desire (2.2.2) 电话:HTC Desire(2.2.2)

I've been playing around with the iscroll plugin for some time now but it seems i can't get it to work. 我已经使用iscroll插件玩了一段时间了,但是看来我无法正常工作。 When i test it in both the android emulator and my phone it keeps scrolling back to the the top. 当我在android模拟器和手机中对其进行测试时,它会一直滚动回到顶部。 Also the LogCat gives the following line: LogCat也提供以下行:

"Miss a drag as we are waiting for webcore's response for touch down" “在等待webcore对降落的响应时,这很拖累”

Javascript: 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: 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>

I'm populating the list with tweets called in with JSON. 我正在用JSON调用的推文填充列表。 Hope somebodey can help! 希望有人能为您服务!

The full iScroll syntax is: iScroll(element_id, object options). 完整的iScroll语法为:iScroll(element_id,对象选项)。 Options are here . 选项在这里 Among the options we have bounceLock (if set to true the scroller stops bouncing if the content is smaller than the visible area. Default value is false). 在选项中,有bounceLock(如果设置为true,则滚动条将在内容小于可见区域时停止弹跳。默认值为false)。

Hope this is what you were searching for 希望这是您正在寻找的

To keep it from scrolling to the top you will need to create the scroll object after the first time you "show" your element. 为了避免滚动到顶部,您需要在第一次“显示”元素之后创建滚动对象。 To dynamically add data to this element and maintain a proper scroll with scrolling bars, you can use the following script after each time you add data to the list: 要将数据动态添加到此元素并使用滚动条保持适当的滚动,则可以在每次将数据添加到列表之后使用以下脚本:

    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