简体   繁体   English

滚动单个项目时强制phonegap / cordova应用反弹

[英]Force phonegap/cordova app to bounce when scrolling even with a single item

This question is similar to this one: Force uiscrollview to bounce scrolling even with a single item but the answer didn't solve my problem as I am using cordova, HTML 5 and Javascript to build my app. 这个问题类似于这个问题: 即使使用单个项目 ,也强制uiscrollview弹跳滚动,但是由于我使用Cordova,HTML 5和Javascript构建我的应用程序,因此答案并没有解决我的问题。

My app uses iScroll to implement bounce effect on scrolling but it is not bouncing when the content fits the whole screen; 我的应用程序使用iScroll在滚动时实现反弹效果,但是当内容适合整个屏幕时它不会反弹。 it is not having the bounce effect when there is no need to scroll. 当不需要滚动时,它没有反弹效果。

Help? 救命? Thanks! 谢谢!

I can't seem to find an alternative that lets me do this so I modified the core iscroll.js (v5.1.1) and added my own code inside iScroll.prototype.refresh : 我似乎找不到让我做到这一点的替代方法,因此我修改了核心iscroll.js(v5.1.1),并在iScroll.prototype.refresh添加了自己的代码:

this.hasHorizontalScroll    = this.options.scrollX && this.maxScrollX < 0;
this.hasVerticalScroll      = this.options.scrollY && this.maxScrollY < 0;

//---- my code starts here
// set default value to 0 if the maxscrolly is greater than 0
//and set hasVerticalScroll to true (always true)
  this.maxScrollY = (this.maxScrollY > 0) ? 0) : this.maxScrollY;
  this.hasVerticalScroll = true;
//---- my code ends here

if ( !this.hasHorizontalScroll ) {
        this.maxScrollX = 0;
        this.scrollerWidth = this.wrapperWidth;
    }

if ( !this.hasVerticalScroll ) {
        this.maxScrollY = 0;
        this.scrollerHeight = this.wrapperHeight;
}

*this will enable the scroll bounce effect even if the page has no content. *即使页面没有内容,这也会启用滚动跳动效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Phonegap + Android:禁用反弹并突出显示滚动效果 - Phonegap + Android: disable bounce and highlight effect on scrolling 单页cordova应用程序,仅在IOS中尝试滚动时内容不滚动并消失 - 由ratchet.css引起 - single page cordova app, content not scrolling and disappears when attempting to scroll in IOS only - caused by ratchet.css PhoneGap/Cordova:无法阻止滚动 - PhoneGap/Cordova: cannot prevent scrolling 滚动时的Phonegap移动应用程序选择不正确的项目 - Phonegap mobile app tapping while scrolling selects incorrect item Cordova - iOS嵌套元素禁用弹跳但保持速度滚动 - Cordova - iOS nested element disable bounce but keep velocity scrolling 加载谷歌图表API时,PhoneGap(Cordova)应用程序崩溃 - PhoneGap (Cordova) app crashes when loading google chart API 使用PhoneGap / Cordova时应用与服务器之间通信的最佳实践 - Best practice for communication between app and server when using PhoneGap/Cordova 滚动时导航栏的跳动/缓动动画 - Bounce/Ease animation for nav bar when scrolling 当呼叫/热点指示器可见时,阻止phonegap应用滚动 - Stop phonegap app from scrolling when call/hotspot indicator is visible 在android phonegap应用中单击“后退”按钮时强制关闭 - force close when clicking the back button in android phonegap app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM