question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add parameters to define width and height for modal

See original GitHub issue

How to define variable width/height for modal? Looks like it can’t calculate things properly it these are used. Eg.: width: '50%' , width: '5vw' etc.

Furthermore, I think max-width and max-height are also important to have, especially for images.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
acupofjosecommented, Aug 27, 2016

@limonte I can think of a few use cases. With the additional parameters and event bindings that swal2 supports now, it’s becoming more than just a dialog modal. You could use swal2 to display videos or dynamic content, videos, iframes, images, etc. that it could be useful to have sized to a specific standard.

I do realize these use cases go beyond what the original use cases for what swal and swal2 were, but I don’t necessarily think that’s a bad thing.

Thoughts?

1reaction
Rikkcommented, Aug 27, 2016

Important for mobile, fixed-widths usually will be cut on small screens. And having no overflow: auto, user can’t scroll modal contents using scrollbar, when contents are large; for example, a large image or an image with imageWidth set too high. A good ability for a popup is to automatically adapt itself to the environment it is present, even if it is unknown. I see swal2 (maybe also original swal) uses margin-left and a px value for width to calculate its position…

modal.style.width = params.width + 'px';
modal.style.marginLeft = -params.width / 2 + 'px';

Instead, why doesn’t it calculate window.width, get its own width, then find the center? And because it is position: fixed, maybe top and left values are the only things it needs to calculate for positioning itself. I think the title you set for this issue is not really accurate, while we can’t define height we can already define width, but as fixed pixels.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change Bootstrap Modal Width and Height - 3 Examples
In order to increase or decrease the modal window height and width properties of Bootstrap, you need to get the modal related classes...
Read more >
Specify/Set width and height on a react-boostrap modal
I have checked the react-bootstrap docs here but could not figure out how to do that. Actually the value of width and height...
Read more >
Bootstrap Modal Sizing - free examples & tutorial
Responsive popup window sizing with Bootstrap 5. Modal width, modal height, fullscreen modal, large modal with lg & xl modal classes and more....
Read more >
Set width of modal window of lightning action
The "Large" modal changes width to occupy 90% of the viewport. It uses a wider minimum width and no maximum width. It's height...
Read more >
Modal · Bootstrap v5.0
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for ... Due to how HTML5 defines its semantics, the autofocus HTML...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found