[英]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.