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

Responsive issue with ScriptYouTubePlayer component #327

Open
Youhan opened this issue Dec 3, 2024 · 2 comments
Open

Responsive issue with ScriptYouTubePlayer component #327

Youhan opened this issue Dec 3, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Youhan
Copy link

Youhan commented Dec 3, 2024

🐛 The bug

Hi team!

The ScriptYouTubePlayer component accepts width and height (or defaults to 640 and 480). From that it calculates aspect-ratio and then sets these styles on it

maxWidth: '100%',
width: `${props.width}px`,
height: 'auto',
aspectRatio: `${props.width}/${props.height}`,

This could potentially cause some responsive troubles when it is inside a container that has min-width:auto like a grid column.
I am providing a reproduction showing it.
The issue on the reproduction can be solved by adding min-w-0 to the grid cols, as the grid cols by default want to follow the width of their content, their default is min-width: auto.

🛠️ To reproduce

https://stackblitz.com/edit/nuxt-starter-s1pw6n?file=app.vue

🌈 Expected behavior

As a possible solution, I am wondering if the following could be a friendlier?

minWidth: 100px, // to have minimum width
width: `100%`;
height: `auto`;
aspectRatio: `${props.width}/${props.height}`,

Also we could let the user handle the width and height and just get the aspect ratio in the props?

ℹ️ Additional context

No response

@Youhan Youhan added the bug Something isn't working label Dec 3, 2024
@codeflorist
Copy link

I would also suggest to set width always to 100% and let the user control the width (or maximum width) of the video via it's parent container.

Currently this is a workaround:

<ScriptYouTubePlayer  :root-attrs="{ style: { width: '100%' } }">

@devinschumacher
Copy link

devinschumacher commented Dec 21, 2024

And what about the "object:contain" vs. "object:cover" situation?

mine is defaulting to object:contain which makes it look wonky

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants