@ -29,7 +29,7 @@ export default class MediaModal extends ImmutablePureComponent {
} ;
handleSwipe = ( index ) => {
this . setState ( { index : ( index ) % this . props . media . size } ) ;
this . setState ( { index : index % this . props . media . size } ) ;
}
handleNextClick = ( ) => {
@ -40,6 +40,11 @@ export default class MediaModal extends ImmutablePureComponent {
this . setState ( { index : ( this . props . media . size + this . getIndex ( ) - 1 ) % this . props . media . size } ) ;
}
handleChangeIndex = ( e ) => {
const index = Number ( e . currentTarget . getAttribute ( 'data-index' ) ) ;
this . setState ( { index : index % this . props . media . size } ) ;
}
handleKeyUp = ( e ) => {
switch ( e . key ) {
case 'ArrowLeft' :
@ -67,10 +72,21 @@ export default class MediaModal extends ImmutablePureComponent {
const { media , intl , onClose } = this . props ;
const index = this . getIndex ( ) ;
let pagination = [ ] ;
const leftNav = media . size > 1 && < button tabIndex = '0' className = 'modal-container__nav modal-container__nav--left' onClick = { this . handlePrevClick } aria - label = { intl . formatMessage ( messages . previous ) } > < i className = 'fa fa-fw fa-chevron-left' / > < / b u t t o n > ;
const rightNav = media . size > 1 && < button tabIndex = '0' className = 'modal-container__nav modal-container__nav--right' onClick = { this . handleNextClick } aria - label = { intl . formatMessage ( messages . next ) } > < i className = 'fa fa-fw fa-chevron-right' / > < / b u t t o n > ;
if ( media . size > 1 ) {
pagination = media . map ( ( item , i ) => {
const classes = [ 'media-modal__button' ] ;
if ( i === index ) {
classes . push ( 'media-modal__button--active' ) ;
}
return ( < li className = 'media-modal__page-dot' key = { i } > < button tabIndex = '0' className = { classes . join ( ' ' ) } onClick = { this . handleChangeIndex } data - index = { i } > { i + 1 } < / b u t t o n > < / l i > ) ;
} ) ;
}
const content = media . map ( ( image ) => {
const width = image . getIn ( [ 'meta' , 'original' , 'width' ] ) || null ;
const height = image . getIn ( [ 'meta' , 'original' , 'height' ] ) || null ;
@ -98,6 +114,9 @@ export default class MediaModal extends ImmutablePureComponent {
{ content }
< / R e a c t S w i p e a b l e V i e w s >
< / d i v >
< ul className = 'media-modal__pagination' >
{ pagination }
< / u l >
{ rightNav }
< / d i v >