@@ -4,11 +4,11 @@ import React, { cloneElement } from 'react';
44import classNames from 'classnames' ;
55import createChainedFunction from './utils/createChainedFunction' ;
66import BootstrapMixin from './BootstrapMixin' ;
7- import FadeMixin from './FadeMixin' ;
87import domUtils from './utils/domUtils' ;
98import EventListener from './utils/EventListener' ;
109
1110import Portal from './Portal' ;
11+ import Fade from './Fade' ;
1212
1313import Body from './ModalBody' ;
1414import Header from './ModalHeader' ;
@@ -90,12 +90,17 @@ function getScrollbarSize(){
9090 document . body . removeChild ( scrollDiv ) ;
9191
9292 scrollDiv = null ;
93+ return scrollbarSize ;
9394}
9495
9596
9697const ModalMarkup = React . createClass ( {
9798
99+ < << < << < HEAD
98100 mixins : [ BootstrapMixin , FadeMixin ] ,
101+ = === ===
102+ mixins : [ BootstrapMixin ] ,
103+ > >>> >>> [ added ] Fade Component , replaces FadeMixin
99104
100105 propTypes: {
101106
@@ -166,8 +171,7 @@ const ModalMarkup = React.createClass({
166171
167172 let classes = {
168173 modal : true ,
169- fade : this . props . animation ,
170- 'in' : ! this . props . animation
174+ in : this . props . show && ! this . props . animation
171175 } ;
172176
173177 let modal = (
@@ -206,18 +210,22 @@ const ModalMarkup = React.createClass({
206210 } ,
207211
208212 renderBackdrop ( modal ) {
209- let classes = {
210- 'modal-backdrop' : true ,
211- fade : this . props . animation ,
212- 'in' : ! this . props . animation
213- } ;
214-
215- let onClick = this . props . backdrop === true ?
216- this . handleBackdropClick : null ;
213+ let { animation } = this . props ;
214+ let duration = Modal . BACKDROP_TRANSITION_DURATION ; //eslint-disable-line no-use-before-define
215+
216+ let backdrop = (
217+ < div ref = "backdrop"
218+ className = { classNames ( 'modal-backdrop' , { in : this . props . show && ! animation } ) }
219+ onClick = { this . handleBackdropClick }
220+ />
221+ ) ;
217222
218223 return (
219224 < div >
220- < div className = { classNames ( classes ) } ref = "backdrop" onClick = { onClick } />
225+ { animation
226+ ? < Fade transitionAppear in = { this . props . show } duration = { duration } > { backdrop } </ Fade >
227+ : backdrop
228+ }
221229 { modal }
222230 </ div >
223231 ) ;
@@ -381,16 +389,40 @@ const Modal = React.createClass({
381389 ...ModalMarkup . propTypes
382390 } ,
383391
392+ getDefaultProps ( ) {
393+ return {
394+ show : false ,
395+ animation : true
396+ } ;
397+ } ,
398+
384399 render ( ) {
385- let { show, ...props } = this . props ;
400+ let { children, ...props } = this . props ;
401+
402+ let show = ! ! props . show ;
386403
387404 let modal = (
388- < ModalMarkup { ...props } ref = 'modal' > { this . props . children } </ ModalMarkup >
405+ < ModalMarkup { ...props } ref = 'modal' >
406+ { children }
407+ </ ModalMarkup >
389408 ) ;
390409
391410 return (
392- < Portal container = { props . container } >
393- { show && modal }
411+ < Portal container = { props . container } >
412+ { props . animation
413+ ? (
414+ < Fade
415+ in = { show }
416+ transitionAppear = { show }
417+ duration = { Modal . TRANSITION_DURATION }
418+ unmountOnExit
419+ >
420+ { modal }
421+ </ Fade >
422+ )
423+ : show && modal
424+ }
425+
394426 </ Portal >
395427 ) ;
396428 }
@@ -401,4 +433,7 @@ Modal.Header = Header;
401433Modal . Title = Title ;
402434Modal . Footer = Footer ;
403435
436+ Modal . TRANSITION_DURATION = 300 ;
437+ Modal . BACKDROP_TRANSITION_DURATION = 150 ;
438+
404439export default Modal ;
0 commit comments