feat: support passive events by define global variables in zone.js config file#34503
feat: support passive events by define global variables in zone.js config file#34503JiaLiPassion wants to merge 1 commit intoangular:masterfrom
Conversation
|
@mhevery, please check whether this temp solution is ok, thank you! |
|
Looks like a reasonable approach. Needs documentation explaining how to use it. |
b543ecb to
d2909ca
Compare
|
@mhevery, thanks for the review, I have updated the PR and add the document. |
3525ed1 to
203918b
Compare
623fe10 to
feb7db8
Compare
|
@kara, I have rebased the PR, please review, thanks. |
kara
left a comment
There was a problem hiding this comment.
Can we also add a descriptive commit message that explains why this change is necessary?
There was a problem hiding this comment.
before import zone.js => before importing zone.js
There was a problem hiding this comment.
Got it, updated, thanks.
There was a problem hiding this comment.
This is a somewhat large increase. Do we know why? Can we find out how much is just accumulation?
There was a problem hiding this comment.
I agree, this seems excessive especially for the diff in this PR. Let's find out how did we accumulate this much (I've reset the polyfills limits recently so it seems like a recent accumulation of code)
|
This was accidentally merged. Reverting until we have better docs review. |
063165d to
87b34e0
Compare
87b34e0 to
3806892
Compare
There was a problem hiding this comment.
| Angular also supports passive event listeners. For example, you can use the following steps to make scroll event passive. | |
| Angular also supports passive event listeners. For example, you can use the following steps to make the scroll event passive. |
There was a problem hiding this comment.
Got it, thanks, updated.
There was a problem hiding this comment.
| 3. In the `src/polyfills.ts` file, before importing zone.js, import the new created `zone-flags`. | |
| 3. In the `src/polyfills.ts` file, before importing zone.js, import the newly created `zone-flags`. |
There was a problem hiding this comment.
Got it, updated, thanks.
Now Angular doesn't support add event listeners as passive very easily.
User needs to use `elem.addEventListener('scroll', listener, {passive: true});`
or implements their own EventManagerPlugin to do that.
Angular may finally support new template syntax to support passive event, for now,
this commit introduces a temp solution to allow user to define the passive event names
in zone.js configurations.
User can define a global varibale like this.
```
(window as any)['__zone_symbol__PASSIVE_EVENTS'] = ['scroll'];
```
to let all `scroll` event listeners passive.
3806892 to
d46182b
Compare
|
@kara, thank you for the review, I have updated the doc and the commit message. Please review. |
kara
left a comment
There was a problem hiding this comment.
LGTM, thanks for updating the PR @JiaLiPassion!
|
What's the release schedule for zone.js? I ask as I saw quite some changes over time, but the last release was 8 months ago (0.10.2 from August 14, 2019 - https://yarnpkg.com/package/zone.js). Quite interesting that all changes are mentioned in the angular changelog anyway. |
|
@sod, there should be a new version very soon. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #8866
It is not easy to
addEventListenerwithpassiveoption. We may need to discuss to add something like in this PR, #21681 in the future.What is the new behavior?
For now, this PR is just a temp solution until we can add a new
template syntaxinevent listener.In this PR, we can define a global variable before importing zone.js
and then all event listeners defined here will be automatically be
passive: true.Does this PR introduce a breaking change?
If this idea is ok, I will update the document. And of course we still need to discuss the formal way to resolve this issue by introducing some new options in
template event bindingsyntax.