-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Potential performance improvements by using passive event listener #42
Comments
@dpraul Thanks for the issue! Actually we don't have performance measurements in this project, and that's the interesting point. But what we can do now is take a look at the Routines class (which is a part of the vscroll API and can bu used to customize DOM-related logic) and see how it can be useful. The Routines is the place where you may add |
Actually, we're using ngx-ui-scroll in our application, but I did manage to test it in a roundabout way (though I wouldn't send this code to production). When creating the adapter, I manually passed in the viewport with an overridden class Component {
@ViewChild('scrollViewport') scrollViewport: ElementRef<HTMLElement>;
datasource = new Datasource({
settings: {
viewportElement: () => ({
...this.scrollViewport.nativeElement,
addEventListener: (eventName: string, handler: EventListener) => {
this.scrollViewport.nativeElement.addEventListener(eventName, handler, { passive: true });
},
}),
},
});
} It definitely works with |
@dpraul Ok, I published v3.0.1-passive release, which contains |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed within seven days if no further activity occurs. If it needs to remain open, add the "permanent" label. |
Hello! I was reading through the
addEventListener
spec on MDN and noticed that there is a whole section dedicated to supposed browser optimizations that can be gained when listening to thescroll
event by applying the{ passive: true }
option.I noticed that this optimization is not applied here in vscroll, and I couldn't find any calls to
event.preventDefault()
in a cursory search, which leads me to believe there would be no side-effects to doing so.Seems like a simple addition, but I'm not certain if you have any benchmarking tools tucked away to measure if there would actually be a performance difference by using it.
The text was updated successfully, but these errors were encountered: