iScroll ipad 问题

发布于 2025-01-07 18:50:58 字数 856 浏览 3 评论 0原文

在本网站 (http://www.bigideaadv.com/adaptive/people.php)。

我已经安装了它,但它无法正常运行。下面的 JS 代码:

    <script type="text/javascript">     
    var myScroll;
    function loaded() {
        myScroll = new iScroll('ipad_container');
    }

    document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
    document.addEventListener('DOMContentLoaded', loaded, false);
</script>

折叠的 HTML 结构:

    <div id="ipad_container">
            <div id="scroller">
            </div>
    </div>
    <div id="bio_section">
    </div>
    <div id="nav_section_people">
    </div>

CSS 太大,无法在此处发布。

当我尝试滚动时,它会弹回到顶部位置。有人有什么想法吗?

Using iScroll (http://cubiq.org/iscroll-4) on this website (http://www.bigideaadv.com/adaptive/people.php).

I have it installed but it is not functioning correctly. JS code below:

    <script type="text/javascript">     
    var myScroll;
    function loaded() {
        myScroll = new iScroll('ipad_container');
    }

    document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
    document.addEventListener('DOMContentLoaded', loaded, false);
</script>

Collapsed HTML structure:

    <div id="ipad_container">
            <div id="scroller">
            </div>
    </div>
    <div id="bio_section">
    </div>
    <div id="nav_section_people">
    </div>

CSS is too big to post here.

When I try and scroll, it snaps back to the top position. Anyone have any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只等公子 2025-01-14 18:50:58

你看过文档吗?

ONLOAD 有时 DOMContentLoaded 有点仓促并且会被解雇
当内容没有准备好时。如果你有一些奇怪的行为
(例如:橡皮筋效果),请尝试以下操作:

<script type="application/javascript" src="iscroll.js"></script>
 <script type="text/javascript"> 
  var myScroll; 
  function loaded() {
    setTimeout(function () {        
    myScroll = new iScroll('wrapper');  
   },
 100); } 
 window.addEventListener('load', loaded, false); </script>

在这种情况下,iScroll 仅在页面打开 100 毫秒后启动
完全加载(包括图形)。这可能是最安全的
调用 iScroll 的方法。

来源:cubiq

Have you looked at the documentation?

ONLOAD Sometimes the DOMContentLoaded is a bit hasty and get fired
when the contents are not ready. If you slip into some weird behaviors
(eg: rubber band effect), try the following:

<script type="application/javascript" src="iscroll.js"></script>
 <script type="text/javascript"> 
  var myScroll; 
  function loaded() {
    setTimeout(function () {        
    myScroll = new iScroll('wrapper');  
   },
 100); } 
 window.addEventListener('load', loaded, false); </script>

In this case iScroll is started only 100ms after the page is
completely loaded (graphics included). This is probably the safest
way to call the iScroll.

source: cubiq

浪漫之都 2025-01-14 18:50:58

我也遇到过同样的事情。我添加了参数“snap:true”,它解决了问题。

所以,你的台词:

myScroll = new iScroll('ipad_container');

将变成:

myScroll = new iScroll('ipad_container', {snap:true});

希望有帮助。

I had the exact thing happen to me. I added the parameter 'snap:true' and it fixed the problem.

So, your line:

myScroll = new iScroll('ipad_container');

would become:

myScroll = new iScroll('ipad_container', {snap:true});

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文