gpt4 book ai didi

ios - ionic 2-手指离开屏幕时不会触发滚动事件

转载 作者:行者123 更新时间:2023-12-01 18:05:54 24 4
gpt4 key购买 nike

我有一个Ionic应用,其标题要基于scrollTop调整大小。我在IonScroll上使用Ionic的滚动事件:

import { Scroll } from 'ionic-angular';  

@ViewChild(Scroll) scroll: Scroll;

...

ionViewDidLoad() {
this.scroll.addScrollEventListener((ev) => {
console.log('scroll');
});
}

在iOS上,当我将手指放在屏幕上时,滚动事件会完美触发,但是当手指不在屏幕上时(但由于惯性而继续滚动)时,仅在滚动停止时才触发该事件。

当手指离开屏幕时,有没有办法收听滚动事件(或其他类似事件)?

我发现了这个问题,似乎很相似,但是没有任何答案: iOS scroll event not firing as often when finger is off of the screen

最佳答案

几个月前,我遇到了类似的问题(在我的情况下,我想在向下滚动列表时显示/隐藏“scrollToTop”按钮。当手指在屏幕上时,该按钮可以正常工作,但如果您放开它,则不会。

最重要的是,UIWebView在滚动方面有一些限制,滚动检测似乎是这些问题之一。另请:https://github.com/ionic-team/ionic/issues/10630

Ionic-Team建议的解决方案是使用WKWebView,因为那里不存在这些问题。

https://github.com/ionic-team/cordova-plugin-wkwebview-engine

您可以尝试做的最后一件事,尽管我非常确定这不会对您的情况有所影响,但是您可以在NgZone中运行代码:

import { NgZone } from '@angular/core';

export class myPage {
zone: NgZone;

constructor() {
this.zone = new NgZone({enableLongStackTrace: false});

this.content.ionScroll.subscribe(($event) => {
this.zone.run(() => {
// console.log($event);
});
});
}
}

关于ios - ionic 2-手指离开屏幕时不会触发滚动事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44820109/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com