Skip to content

Conversation

@nathanpeck
Copy link

Adds a new option called "center", which if true will automatically center the modal on first display, and recenter it nicely if the window resizes. Destroys the resizing binding nicely when removing the view.

Specify center: true to automatically center the modal on first display, and recenter it on window resizing. Destroys the resizing binding nicely when removing the view.
Quick and dirty code to add a "modalClass" option which allows you to attack the modal-lg class to the modal dialog, or whatever other custom class you might what.
@rafaelfaria
Copy link

I tried to apply your code on my project, and it only center it when resize the window. At first load the following code returns margin-top and margin-left equals 0.

      $el.find('.modal-dialog').css({
        'margin-top': function () {
          return -($(this).outerHeight() / 2);
        },
        'margin-left': function () {
          return -($(this).outerWidth() / 2);
        }
      });

@nathanpeck
Copy link
Author

Are you using Bootstrap 3? And which browser were you using? If you can give me a minimum page that demonstrates the issue I'll see if I can fix it. In the meantime I haven't experienced any issues with the automatic centering of any of my views.

@rafaelfaria
Copy link

Yeah. Bootstrap 3. Backbone JS 1.1.0. Chrome 33.

If i trigger resize after the page has loaded, the modal window snap to the center.

I'm trying to debug as well, but it might be something related to time it is trying to compute the width and height. If i find anything i post it in here too.

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.

2 participants