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

Remove transitions for cropped and object-fit contain images from Lightbox #13040

Merged
merged 4 commits into from Jan 26, 2018

Conversation

cathyxz
Copy link
Contributor

@cathyxz cathyxz commented Jan 25, 2018

Take these out because they look broken. Next step, actually implement a reasonable animation for them.

Copy link
Contributor

@cvializ cvializ left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple of suggestions

@@ -208,7 +209,7 @@ export class AmpImageViewer extends AMP.BaseElement {

/**
* Returns the boundaries of the image element.
* @return {!Element}
* @return {?Element}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it nullable? Looks like it asserts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intention was to remove the assertElement. Oops.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reasoning here is that we're technically not guaranteed that this.image_ will be initialized until we return from layout callback. So there's the option between either returning a promise here and forcing the lightbox exit to wait for this to layout, or just to check in lightbox exit and skip the animation if no image has been laid out yet. Since the entire exit animation is dependent on the image actually loading, it is pointless to wait for this image to layout for just an exit animation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, that makes a lot of sense

} else {
const img = elementByTag(dev().assertElement(this.sourceAmpImage_),
'img');
if (img) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: In the rest of the codebase we simplify if statements like this to ternaries.

const elementHeight = ampImage./*OK*/offsetHeight;
const elementWidth = ampImage./*OK*/offsetWidth;
const ampImageAspectRatio = elementWidth / elementHeight;
return Math.abs(naturalAspectRatio - ampImageAspectRatio) > 0.001;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: magic number

@cathyxz cathyxz merged commit 30c58e2 into ampproject:master Jan 26, 2018
@cathyxz cathyxz deleted the bugfix/cropped-images branch January 26, 2018 02:43
gzgogo pushed a commit to gzgogo/amphtml that referenced this pull request Jan 26, 2018
…htbox (ampproject#13040)

* Get natural image width

* No transition for images whose aspect ratios have changed

* Address PR comments
RanAbram pushed a commit to RanAbram/amphtml that referenced this pull request Mar 12, 2018
…htbox (ampproject#13040)

* Get natural image width

* No transition for images whose aspect ratios have changed

* Address PR comments
protonate pushed a commit to protonate/amphtml that referenced this pull request Mar 15, 2018
…htbox (ampproject#13040)

* Get natural image width

* No transition for images whose aspect ratios have changed

* Address PR comments
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.

None yet

3 participants