Skip to content

Commit

Permalink
rework the transitions for the modal a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
fat committed Sep 11, 2011
1 parent 57a8672 commit 9c76070
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 25 deletions.
21 changes: 16 additions & 5 deletions bootstrap-1.3.0.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* http://www.apache.org/licenses/LICENSE-2.0
*
* Designed and built with all the love in the world @twitter by @mdo and @fat.
* Date: Sat Sep 10 15:29:50 PDT 2011
* Date: Sat Sep 10 18:12:41 PDT 2011
*/
/* Reset.less
* Props to Eric Meyer (meyerweb.com) for his CSS reset file. We're using an adapted version here that cuts out some of the reset HTML elements we will never need here (i.e., dfn, samp, etc).
Expand Down Expand Up @@ -1977,10 +1977,10 @@ button.btn::-moz-focus-inner, input[type=submit].btn::-moz-focus-inner {
opacity: 0;
}
.modal-backdrop, .modal-backdrop.fade.in {
filter: alpha(opacity=50);
-khtml-opacity: 0.5;
-moz-opacity: 0.5;
opacity: 0.5;
filter: alpha(opacity=70);
-khtml-opacity: 0.7;
-moz-opacity: 0.7;
opacity: 0.7;
}
.modal {
position: fixed;
Expand Down Expand Up @@ -2008,6 +2008,17 @@ button.btn::-moz-focus-inner, input[type=submit].btn::-moz-focus-inner {
.modal .close {
margin-top: 7px;
}
.modal.fade {
-webkit-transition: opacity .25s linear, top .25s ease-out;
-moz-transition: opacity .25s linear, top .25s ease-out;
-ms-transition: opacity .25s linear, top .25s ease-out;
-o-transition: opacity .25s linear, top .25s ease-out;
transition: opacity .25s linear, top .25s ease-out;
top: -50%;
}
.modal.fade.in {
top: 50%;
}
.modal-header {
border-bottom: 1px solid #eee;
padding: 5px 15px;
Expand Down
4 changes: 3 additions & 1 deletion bootstrap-1.3.0.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 22 additions & 13 deletions js/bootstrap-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@
this.isShown = true

_.escape.call(this)
_.backdrop.call(this)
_.backdrop.call(this, function () {

this.$element
.appendTo(document.body)
.show()
that.$element
.appendTo(document.body)
.show()

setTimeout(function () {
that.$element.addClass('in').trigger('modal:shown')
that.$backdrop && that.$backdrop.addClass('in')
}, 1)
setTimeout(function () {
that.$element.addClass('in').trigger('modal:shown')
}, 1)

})

return this
}
Expand All @@ -81,19 +82,19 @@
this.isShown = false

_.escape.call(this)
_.backdrop.call(this)

this.$element.removeClass('in')

function removeElement () {
_.backdrop.call(that)

that.$element
.unbind(transitionEnd)
.detach()
.trigger('modal:hidden')
}

$.support.transition && this.$element.hasClass('fade') ?
this.$element.bind(transitionEnd, removeElement) :
this.$element.one(transitionEnd, removeElement) :
removeElement()

return this
Expand All @@ -107,13 +108,21 @@

var _ = {

backdrop: function () {
backdrop: function ( callback ) {
var that = this
, animate = this.$element.hasClass('fade') ? 'fade' : ''
if ( this.isShown && this.settings.backdrop ) {
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.click($.proxy(this.hide, this))
.appendTo(document.body)

setTimeout(function () {
that.$backdrop && that.$backdrop.addClass('in')

$.support.transition && that.$backdrop.hasClass('fade')?
that.$backdrop.one(transitionEnd, callback) :
callback()
})
} else if ( !this.isShown && this.$backdrop ) {
this.$backdrop.removeClass('in')

Expand All @@ -123,7 +132,7 @@
}

$.support.transition && this.$element.hasClass('fade')?
this.$backdrop.bind(transitionEnd, removeElement) :
this.$backdrop.one(transitionEnd, removeElement) :
removeElement()
}
}
Expand Down
13 changes: 7 additions & 6 deletions lib/patterns.less
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,7 @@ input[type=submit].btn {

.modal-backdrop {
background-color:#000;
&.fade {
opacity: 0;
}
&.fade { opacity: 0; }
position: fixed;
top: 0;
left: 0;
Expand All @@ -737,7 +735,7 @@ input[type=submit].btn {
}

.modal-backdrop, .modal-backdrop.fade.in {
.opacity(50);
.opacity(70);
}

.modal {
Expand All @@ -754,9 +752,12 @@ input[type=submit].btn {
.border-radius(6px);
.box-shadow(0 3px 7px rgba(0,0,0,0.3));
.background-clip(padding-box);
.close {
margin-top: 7px;
.close { margin-top: 7px; }
&.fade {
.transition(e('opacity .25s linear, top .25s ease-out'));
top:-50%;
}
&.fade.in { top: 50%;}
}
.modal-header {
border-bottom: 1px solid #eee;
Expand Down

0 comments on commit 9c76070

Please sign in to comment.