2012-09-03 28 views
1

计划:月食(PhoneGap的)iScroll不断向上滚动回(PhoneGap的)

电话:HTC渴望(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调用推文来填充列表。希望somebodey可以帮助!

+0

同样的问题。我的解决方法描述如下: http://stackoverflow.com/questions/14348530/initializing-iscroll-with-phonegap-and-jquery-mobile/18726683#18726683 – Plamen

回答

0

完整的iScroll语法是:iScroll(element_id,对象选项)。 选项是here。 在我们有bounceLock的选项中(如果设置为true,如果内容小于可见区域,则滚动停止反弹,默认值为false)。

希望这是你正在寻找

+0

谢谢你的评论。仍然当我添加bounceLock时,只要我收到我的手指屏幕,它就会回到顶部 –

+0

您正在使用哪个iScroll,iScroll旧版本还是iScroll4? –

+0

我使用iScroll4 –

0

为了防止它滚动到你需要在你第一次“秀”的元素之后创建滚动对象的顶部。要动态地将数据添加到此元素并使用滚动条保持正确的滚动,可以在每次将数据添加到列表后使用以下脚本:

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 });