-
Notifications
You must be signed in to change notification settings - Fork 4.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
Animate directive #12067
Animate directive #12067
Conversation
👋 Hi, |
} | ||
} | ||
|
||
ngOnDestroy() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, you also need to unsubscribe from IntersecrtionObserver(use method unobserve)
this.observer.observe(this.host.nativeElement); | ||
} | ||
|
||
isVisible(element) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this code should run out of ngzone (since IntersectionObserver can throw events frequently).
this.observer.observe(this.host.nativeElement); | ||
} | ||
|
||
isVisible(element) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add types here?
|
||
bindDocumentScrollListener() { | ||
if (!this.documentScrollListener) { | ||
this.documentScrollListener = this.renderer.listen(window, 'scroll', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all listeners for scroll|load also should invoke outside zone
const [intersectionObserverEntry] = element; | ||
this.entered = intersectionObserverEntry.isIntersecting; | ||
|
||
if (this.entered || this.isInViewport()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should call this method once and save(the result) it in a variable, because using the getBoundingClientRect
method causes reflow
in browser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's about isInViewport
|
||
animate() { | ||
if (this.loaded) { | ||
if (this.isInViewport() && !this.entered) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same store variable from isInViewport
👋 Hi, |
👋 Hi, |
👋 Hi, |
2 similar comments
👋 Hi, |
👋 Hi, |
Add pAnimate directive to handle animations on a scroll by adding/removing PrimeFlex Animation classes.