Skip to content

✨ Update FixedLayer on Element Hidden Toggle#18797

Merged
jridgewell merged 8 commits intoampproject:masterfrom
jridgewell:fixed-layer-mutation-observer
Oct 23, 2018
Merged

✨ Update FixedLayer on Element Hidden Toggle#18797
jridgewell merged 8 commits intoampproject:masterfrom
jridgewell:fixed-layer-mutation-observer

Conversation

@jridgewell
Copy link
Copy Markdown
Contributor

Now when an element is toggled (hidden or un-hidden), the FixedLayer will run an update.

Fixes #17475
Fixes #16554
Fixes #16933
Depends on #18788

Copy link
Copy Markdown

@dreamofabear dreamofabear left a comment

Choose a reason for hiding this comment

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

Looks good. Will approve after rebase.

}

/**
* Clears the mutation observer and it's pass queue.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: its

}

/**
* @return {?MutationObserver}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

!MutationObserver

for (let i = 0; i < mutations.length; i++) {
const mutation = mutations[i];
if (mutation.attributeName === 'hidden') {
this.updatePass_.schedule(16);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Explain magic number in a comment?

@aghassemi
Copy link
Copy Markdown
Contributor

@jridgewell @choumx would this make it to Canary tomorrow of 10/30 release?

@jridgewell jridgewell force-pushed the fixed-layer-mutation-observer branch from 3d8ff81 to ce11c0d Compare October 23, 2018 03:14
Copy link
Copy Markdown

@dreamofabear dreamofabear left a comment

Choose a reason for hiding this comment

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

Let's gate this under an default-enabled experiment so we can easily turn it off if needed.

const mutation = mutations[i];
if (mutation.attributeName === 'hidden') {
// Wait one animation frame so that other mutations may arrive.
this.updatePass_.schedule(16);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For a follow-up: bit of a waste to run the whole update() on a single element's hidden attribute change, no? Can we constrain the operation to just the mutated elements?

@jridgewell
Copy link
Copy Markdown
Contributor Author

would this make it to Canary tomorrow of 10/30 release?

Yah, I'll wait for this to land before cutting canary. I'm on duty this week, so it's lucky.

@jridgewell jridgewell force-pushed the fixed-layer-mutation-observer branch from 74fd22d to a0366af Compare October 23, 2018 19:31
@jridgewell jridgewell merged commit f9e8147 into ampproject:master Oct 23, 2018
@jridgewell jridgewell deleted the fixed-layer-mutation-observer branch October 23, 2018 20:51
Enriqe pushed a commit to Enriqe/amphtml that referenced this pull request Nov 28, 2018
* Initial fixed-layer mutaiton observer

* Unobserve if possible

* Fake mutation observer class

* Tests

* Review comments

* Guard mutation-observer behind an experiment

* Add experiment

* Fix tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants