$ .mobile.silentScroll在worklight应用程序中不起作用 [英] $.mobile.silentScroll does not work in worklight app

查看:128
本文介绍了$ .mobile.silentScroll在worklight应用程序中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IBM的worklight框架开发一个应用程序,我在其中使用jquery移动库来编写代码。

I am developing an application using worklight framework from IBM in which I use jquery mobile library to code.

不幸的是,当我使用 $。mobile.silentScroll 进行滚动时,它没有任何效果,它不起作用。

Unfortunately, when I use $.mobile.silentScroll to scroll, it has no effect, it does not work.

有没有人遇到过这个问题?在其他工作中,如何在工作灯中滚动页面?

Has anyone met that issue? In other work, How to scroll page in worklight?

推荐答案

我认为你不能用jQuery Mobile的 silentScroll ,因为它基本上使用window.scrollTo,这允许仅在当前视口内滚动(您当前在屏幕上看到的内容)。

I don't think you can do this with jQuery Mobile's silentScroll, as it basically uses window.scrollTo, and this allows to scroll only within the current viewport (what you currently see on the screen).

相反,我建议使用 iScroll 的各种API方法: scrollTo ScrollToElement Snap 等。

Instead I would recommend to use iScroll's various API methods: scrollTo, ScrollToElement or Snap, etc.

我在Android中测试了下面的内容并且它有效。

您当然需要根据您的应用进行调整...

I tested the below in Android and it worked.
You'll of course need to adjust it to your application...

common \ js \ main.js:

common\js\main.js:

var myScroll;

function wlCommonInit(){
    myScroll = new IScroll('#wrapper');
}

common\index.html:

common\index.html:

<body style="display: none;">
        <div id="wrapper">
            <div data-role="page" id="page">
                <div data-role="content" id="content" style="padding: 15px">                
                    <div id="firstDiv">
                        <input type="button" value="scroll to the other div" onclick="myScroll.scrollToElement('#secondDiv', '0s');"/>
                    </div>
                    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
                    <div id="secondDiv">
                        hello
                    </div>
                </div>
            </div>
        </div>
        ...
        ...
</body>

0s 表示没有滚动效果;它基本上会跳到所需的位置。

0s means there will be no scroll effect; it will essentially 'jump' to the desired location.

这篇关于$ .mobile.silentScroll在worklight应用程序中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆