Skip to content
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

perf: call tippy outside of the Angular zone and optimize IntersectionObserver #44

Merged
merged 1 commit into from
Jun 6, 2021
Merged

Conversation

arturovt
Copy link
Contributor

@arturovt arturovt commented Jun 5, 2021

Hey, I've noticed dozens of change detections when the tippy directive is used.

Before (the page has been opened and Angular already has run 500 change detections)

image

After

image

instance.popper.style.maxWidth = this.hostWidth;
(instance.popper.firstElementChild as HTMLElement).style.maxWidth = this.hostWidth;
// Don't access `hostWidth` multiple times since it's a getter that calls `getBoundingClientRect()`,
// which triggers the whole layout update.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch 🔥

subscriber.complete();
}
}, options);
return ngZone.runOutsideAngular(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was pretty sure I already run everything outside the zone. I guess I was wrong. Thanks!

@NetanelBasal NetanelBasal merged commit 3cc6557 into ngneat:master Jun 6, 2021
@arturovt arturovt deleted the perf/tippy branch June 6, 2021 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants