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

Dynamically calculate card height for embeds instead of padding #5265

Merged
merged 1 commit into from Oct 8, 2017

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Oct 8, 2017

The padding trick was hard-coded to a 16:9 ratio, but we can use width and height provided from OEmbed information and width of the card itself to calculate a new height

Unfortunately, imgur's embeds seem generally broken in terms of height, I can observe that on birdsite as well

The padding trick was hard-coded to a 16:9 ratio, but we can use
width and height provided from OEmbed information and width
of the card itself to calculate a new height
@Gargron Gargron added bug Something isn't working ui Front-end, design labels Oct 8, 2017
@@ -75,14 +79,25 @@ export default class Card extends React.PureComponent {
);
}

setRef = c => {
if (c) {
this.setState({ width: c.offsetWidth });
Copy link
Contributor

Choose a reason for hiding this comment

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

So unfortunately offsetWidth triggers layout… but this is only for video embeds right? Basically YouTube and whatnot?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. YouTube, Vimeo, Soundcloud, Imgur, Twitch Clip, etc

Copy link
Member Author

Choose a reason for hiding this comment

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

Mind you, StatusCard is only ever mounted from DetailedStatus!

@Gargron Gargron merged commit 684001d into master Oct 8, 2017
@Gargron Gargron deleted the fix-card-embed-height branch October 8, 2017 00:34
rutan pushed a commit to rutan/mastodon that referenced this pull request Oct 11, 2017
…odon#5265)

The padding trick was hard-coded to a 16:9 ratio, but we can use
width and height provided from OEmbed information and width
of the card itself to calculate a new height
cobodo pushed a commit to cobodo/mastodon that referenced this pull request Oct 20, 2017
…odon#5265)

The padding trick was hard-coded to a 16:9 ratio, but we can use
width and height provided from OEmbed information and width
of the card itself to calculate a new height
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ui Front-end, design
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants