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

Feat: use parent height if height not set #2841

Merged
merged 2 commits into from
Jun 6, 2023
Merged

Feat: use parent height if height not set #2841

merged 2 commits into from
Jun 6, 2023

Conversation

katspaugh
Copy link
Owner

Resolves #2837

It will now use the container height if a height isn't passed in the options, otherwise fall back to 128 px.

@cloudflare-pages
Copy link

cloudflare-pages bot commented Jun 5, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: faab80e
Status: ✅  Deploy successful!
Preview URL: https://efd73922.wavesurfer-js.pages.dev
Branch Preview URL: https://parent-height.wavesurfer-js.pages.dev

View logs

@@ -93,6 +95,11 @@ class Renderer extends EventEmitter<RendererEvents> {
)
}

private getHeight(): number {
const defaultHeight = 128
return this.options.height ?? (this.parent.clientHeight || defaultHeight)

Choose a reason for hiding this comment

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

In your code you are using the default height (128px) only if height doesn't provided in the options and parent.clientHeight is null or undefined
I think it should be: if height isn't provided AND fillParent is true, then don't use the default value

Copy link
Owner Author

Choose a reason for hiding this comment

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

fillParent was meant only for width. I think it’s sufficient that you either pass a height or you have it fill the container. Otherwise the waveform will be just invisible, which is not very useful, is it?

Choose a reason for hiding this comment

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

I don't think so. I think its very useful for responsiveness in scenarios that the parent height is in relative units and you need the wave to be in the same height as the parent.

Copy link
Owner Author

Choose a reason for hiding this comment

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

So I’ll leave as it is then. If someone does NOT want to it to fill the full height, they can pass a specific height.

Choose a reason for hiding this comment

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

Ok, your choice :)

@katspaugh katspaugh merged commit 91f72c2 into beta Jun 6, 2023
2 checks passed
@katspaugh katspaugh deleted the parent-height branch June 6, 2023 09:38
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.

Issue: wavesurfer.js v7@beta - fillParent not working as expected
2 participants