$.mobile.silentScroll does not work in worklight app

血红的双手。 提交于 2019-12-20 05:52:29

问题


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

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?


回答1:


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).

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

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

common\js\main.js:

var myScroll;

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

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 means there will be no scroll effect; it will essentially 'jump' to the desired location.



来源:https://stackoverflow.com/questions/24282802/mobile-silentscroll-does-not-work-in-worklight-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!