【发布时间】:2019-02-18 05:10:52
【问题描述】:
我正在使用 nativescript angular 开发 android 和 ios 应用程序。我正在使用滚动视图来显示列表项。有没有办法检测用户是否停止在滚动视图中滚动?请为此提供任何解决方案。
【问题讨论】:
标签: nativescript nativescript-angular
我正在使用 nativescript angular 开发 android 和 ios 应用程序。我正在使用滚动视图来显示列表项。有没有办法检测用户是否停止在滚动视图中滚动?请为此提供任何解决方案。
【问题讨论】:
标签: nativescript nativescript-angular
您可以收听touch 事件并确保event.action 是TouchAction.up。
编辑:如果您想在 iOS 上附加您自己的 UIScrollViewDelegate 实现,您可以这样做。我的委托版本接受原始委托作为参数,因此我不会丢失原始委托中已经实现的任何内容。
(<any>ScrollView.prototype).originalAttachNative = (<any>ScrollView.prototype).attachNative;
(<any>ScrollView.prototype).attachNative = function () {
this.originalAttachNative();
const newDelegate = MyUIScrollViewDelegateImpl.initWithOriginalDelegate(this._delegate);
this._delegate = newDelegate;
this.nativeViewProtected.delegate = newDelegate;
};
【讨论】:
scroll 事件并添加一个延迟,比如说 300 毫秒,如果你在这段时间内收到下一个滚动事件,它仍然是滚动,否则滚动停止。