【问题标题】:Force phonegap/cordova app to bounce when scrolling even with a single item强制 phonegap/cordova 应用程序在滚动时弹跳,即使是单个项目
【发布时间】:2015-03-19 19:21:07
【问题描述】:

这个问题与这个问题类似:Force uiscrollview to bounce scrolling even with a single item 但答案并没有解决我的问题,因为我正在使用 cordova、HTML 5 和 Javascript 来构建我的应用程序。

我的应用使用 iScroll 在滚动时实现弹跳效果,但当内容适合整个屏幕时它不会弹跳;不需要滚动时没有弹跳效果。

帮助?谢谢!

【问题讨论】:

  • 据我所知,iscroll 是不可能的
  • 你知道我能做些什么吗?或者有什么技巧可以实现弹跳效果?

标签: javascript android ios cordova iscroll


【解决方案1】:

我似乎找不到让我这样做的替代方案,所以我修改了核心 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;
}

*这将启用滚动反弹效果,即使页面没有内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多