-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: tap click activates buttons without scrollEvents, but scrollEvents introduces perf issues #22030
Comments
Same issuse on ios |
Any update on this? Issue still exists. |
I found a fix. Just add the empty attribute 'scroll-events' to the ion-content e.g.: ionic-framework/core/src/components/content/content.tsx Lines 86 to 90 in 181fc59
ionic-framework/core/src/utils/tap-click.ts Lines 143 to 149 in 181fc59
UpdateHere is another workaround without performance regression import { AfterContentInit, Component, ViewChild } from "@angular/core";
import { IonContent } from "@ionic/angular";
export let supportsPassiveListener = (function checkPassiveListener() {
let supportsPassive = false;
try {
const opts = Object.defineProperty({}, 'passive', {
// eslint-disable-next-line
get() {
supportsPassive = true;
}
});
window.addEventListener('testPassiveListener', null, opts);
window.removeEventListener('testPassiveListener', null, opts)
} catch (e) {
// No support
}
return supportsPassive;
}());
export const fixIonContentScrollEvents = (ionContent: IonContent) => {
const scrollStuff = {isScrolling: false, watchDog: null, lastScroll: 0};
const onScrollEnd = () => {
clearInterval(scrollStuff.watchDog);
scrollStuff.watchDog = null;
if (scrollStuff.isScrolling) {
scrollStuff.isScrolling = false;
// @ts-ignore
ionContent.el.dispatchEvent(new CustomEvent('ionScrollEnd', {bubbles: true, detail: {isScrolling: false}}));
}
};
const onScrollStart = () => {
scrollStuff.isScrolling = true;
// @ts-ignore
ionContent.el.dispatchEvent(new CustomEvent('ionScrollStart', {bubbles: true, detail: {isScrolling: true}}));
if (scrollStuff.watchDog) {
clearInterval(scrollStuff.watchDog);
}
scrollStuff.watchDog = setInterval(() => {
if (scrollStuff.lastScroll < Date.now() - 120) {
onScrollEnd();
}
}, 100);
};
const options = supportsPassiveListener ? {passive: true, capture: false} : false;
ionContent.getScrollElement().then((element) => {
element.addEventListener('scroll', () => {
const timeStamp = Date.now();
const shouldStart = !scrollStuff.isScrolling;
scrollStuff.lastScroll = timeStamp;
if (shouldStart) {
onScrollStart();
}
}, options);
});
};
@Component({
templateUrl: 'list.html',
styleUrls: ['list.css']
})
export class ListPage implements AfterContentInit {
@ViewChild(IonContent, {static: true}) ionContent: IonContent;
ngAfterContentInit(): void {
// remove when this issue is closed https://github.com/ionic-team/ionic-framework/issues/22030
fixIonContentScrollEvents(this.ionContent);
}
} BTW @liamdebeasi you may refactor all the tap-click stuff and the scroll listeners to work with passive listeners where possible (keep ssr in mind while refactoring, update: here https://github.com/ionic-team/ionic-framework/blob/dea9248763737164e17678119c775cdfc0e53ccd/core/src/utils/gesture/listener.ts you will have all the functionality you will need) |
Any news about this bug? |
Yes please fix this :/ |
Still there. For such a basic building block of a mobile-first UI framework, it should rather be considered quite important to fix. |
I can confirm the bug and a fix would be great. As @maciejgoscinski mentioned, this seems pretty important as the user UI experience is not so nice right now. |
This is also the issue for ripple effect, if a component has a <IonItem routerLink={`/edit-customer/${customerRec._id}`}> Ripple effect is activated whenever I scroll a list of IonItem's. Very ugly. |
Similar issue for |
Thanks for the issue. If you enable set the |
@liamdebeasi yes this will resolves the problem but will introduce the performance problems you mentioned. See my comments above for more information #22030 (comment) enabling scroll events is not an option to resolve this issue because of the performance impact. An passive listener may also resolve some performance issues for the scroll event part. |
Thanks for the update. We are looking into updating the tap click utility for modern browsers, so this context helps. |
@liamdebeasi Will this be resolved in v6 or v5 as well? |
@liamdebeasi any updates? |
Any Updates? |
Hi everyone, I have an experimental fix that I am working on to resolve this issue. Can you all give this a try and let me know if you run into any issues? Using the new PointerEvents API, we can listen for the
This build works on all Ionic packages ( Note: This is an Ionic 6 build and is subject to all Ionic 6 breaking changes. |
Thanks for the issue. This has been resolved via #25352, and a fix will be available in an upcoming release of Ionic Framework. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Bug Report
Ionic version:
[ ] 4.x
[x] 5.x
Current behavior:
When scrolling an
ion-list
with clickableion-item
s (button="true"
), the item the user touches in order to scroll plays its "activated" style or animation (i.e. ripple effect on Android, darkened background on iOS). This happens even if the user is not "clicking" on that item.Expected behavior:
When scrolling the list, the touched item should not change in appearance (play the ripple effect or change the background). These styles should only activate when the user taps/clicks an item to select it.
Steps to reproduce:
ionic start
)ion-list
to one of the pages containing enoughion-item
s to enable scrollingRelated code:
StackBlitz: https://stackblitz.com/edit/ionic-list-ripple-bug
Snippet from Angular template:
Other information:
This bug seems similar/identical to that identified in #15752. That issue references 7f38d37 as fixing the problem, but since I can reproduce it in a recent Ionic version, it seems to have reappeared(?).
Ionic info:
The text was updated successfully, but these errors were encountered: