-
Notifications
You must be signed in to change notification settings - Fork 810
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
Dynamic sizing of the modal #62
Comments
Here is a hack I used to do a similar thing, vertically rather than horizontally.
Note that use requestAnimationFrame here - the ref was not yet defined otherwise. Maybe this has to do with the DOM magic react-modal does... At any rate this is a hack and I'm sure there is a better way to do this.
Hope this helps. |
Thanks @davidmfoley. |
Nice @davidmfoley |
No problem. We are now using pure CSS to size the modal, which works as long as you style the components in the modal so that they result in proper width/height, relieving the need for any requestAnimationFrame/manual coordinate math:
|
Thanks for the pure CSS solution! |
It's been a while since there was any discussion on this issue. I'm assuming that it isn't a problem anymore. If it is, feel free to re-open the issue. |
Hello guys, |
@amangeot As David pointed out, the layout breaks if the children inside the modal exceed the dimensions of the viewport, but defining maximum dimensions for a child container in viewport units should take care of that. Using his code I ended up doing this: .modalClass {
position: fixed;
top: 50%;
right: auto;
bottom: auto;
left: 50%;
transform: translate(-50%,-50%);
outline: 0;
}
.childDiv {
max-height: 90vh;
max-width: 90vw;
} At least for the image previews I am using it for, it seems to work really well, even on mobile. |
I get this fixed by writing HOC where i am using Link - https://gist.github.com/mohandere/b563d19f5f1c7bf027fd7129592e9ab8 |
Here's how I do it with my modals.
|
|
It would seem there are enough people asking for this feature. It's not sufficient to declare static CSS classes as this doesn't meet the needs of the OP - i.e. dynamic modal sizes. It would be relatively trivial to implement additional props on the |
Late to the game but not following how to dynamically size the modal. What I see is that the dialog width is set to 50%, (.popup-content width:50%). That ends up being 50% of the viewport. If I constrain the width of the contents that makes the content smaller but there is still a bounding rect that is 50% of the viewport. div class="popup-content " style="position: relative; background: rgb(255, 255, 255); width: 50%; margin: auto; border: 1px solid rgb(187, 187, 187); padding: 5px;" |
What about dynamic sizing of the modal in typescript? |
my solution is |
I'm still having issues getting modal to auto-expand when react-datepicker is clicked on within the modal. Posted a question here: https://stackoverflow.com/questions/72890966/react-modal-how-to-get-modal-to-auto-expand-when-react-datepicker-is-clicked |
@callagga you can try to define de height as |
thanks - I've tried but did note"
then |
I don't have any other options how to do it ((( .ReactModal__Content--after-open { |
@polixisNG Actually, you do!! You can use the |
Does anyone know how to dynamically size the modal? For example, if I hard-coded the width of some content to be 100px wide, and the app element that the modal is bound to is 200px wide, I want the modal to be centered in the window at 100px wide. Any ideas?
The text was updated successfully, but these errors were encountered: