Skip to content

FlyingCarpet: Ensure unbuilt elements eventually layout#6742

Merged
jridgewell merged 3 commits intoampproject:masterfrom
jridgewell:flying-carpet-unbuilt
Dec 20, 2016
Merged

FlyingCarpet: Ensure unbuilt elements eventually layout#6742
jridgewell merged 3 commits intoampproject:masterfrom
jridgewell:flying-carpet-unbuilt

Conversation

@jridgewell
Copy link
Copy Markdown
Contributor

Fixes #6735.

@jridgewell
Copy link
Copy Markdown
Contributor Author

Assigning to @zhouyx, since you dealt with similar issues in <amp-sticky-ad>.

amp-fx-flying-carpet > .-amp-fx-flying-carpet-clip > .-amp-fx-flying-carpet-container {
position: fixed !important;
top: 0 !important;
width: 100%;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Defaults to 100% width, so that fixed-height elements get a width during initial measure. This will be updated in the next mutate phase to match the flying-carpet's width exactly.

throw e;
}
this.scheduleLayout(this.children_);
listen(this.element, 'amp:built', this.layoutBuiltChild_.bind(this));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should listen to 'amp:built' from each child here. As this.element is promised to have been built when we call #layoutCallback. Also I think '#listenOnce` is more appropriate as an element will only be built once.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we should listen to 'amp:built' from each child here.

That would register n callbacks, when only one is needed.

As this.element is promised to have been built when we call #layoutCallback.

I'm counting on that. That way, I know the target of the event is never this element, so it must be one of the children that just built.

Also I think '#listenOnce` is more appropriate as an element will only be built once.

I would like this, but I can't reconcile it with the first point.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see, unlike things in sticky-ad, flying-carpet can have multiple different elements as children, which makes it not possible to use listenOnce.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Exactly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One last question, does scheduleLayout has any async sub call before checking for isBuilt? My concern is in that way we may schedule layout twice for one element.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, everything is sync. Even if it were scheduled twice, the task system handles that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cool!

@zhouyx
Copy link
Copy Markdown
Contributor

zhouyx commented Dec 20, 2016

LGTM

@jridgewell jridgewell merged commit 4e3e973 into ampproject:master Dec 20, 2016
Lith pushed a commit to Lith/amphtml that referenced this pull request Dec 22, 2016
…6742)

*  FlyingCarpet: Ensure unbuilt elements eventually layout

 Fixes ampproject#6735.

* Ensure only directly owned elements get layout

* Linting
Lith pushed a commit to Lith/amphtml that referenced this pull request Dec 22, 2016
…6742)

*  FlyingCarpet: Ensure unbuilt elements eventually layout

 Fixes ampproject#6735.

* Ensure only directly owned elements get layout

* Linting
torch2424 pushed a commit to torch2424/amphtml that referenced this pull request Jan 3, 2017
…6742)

*  FlyingCarpet: Ensure unbuilt elements eventually layout

 Fixes ampproject#6735.

* Ensure only directly owned elements get layout

* Linting
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