|
|
@ -54,19 +54,23 @@ export default class MediaModal extends ImmutablePureComponent { |
|
|
|
this.setState({ index: index % this.props.media.size }); |
|
|
|
this.setState({ index: index % this.props.media.size }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handleKeyUp = (e) => { |
|
|
|
handleKeyDown = (e) => { |
|
|
|
switch(e.key) { |
|
|
|
switch(e.key) { |
|
|
|
case 'ArrowLeft': |
|
|
|
case 'ArrowLeft': |
|
|
|
this.handlePrevClick(); |
|
|
|
this.handlePrevClick(); |
|
|
|
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
e.stopPropagation(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'ArrowRight': |
|
|
|
case 'ArrowRight': |
|
|
|
this.handleNextClick(); |
|
|
|
this.handleNextClick(); |
|
|
|
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
e.stopPropagation(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
componentDidMount () { |
|
|
|
componentDidMount () { |
|
|
|
window.addEventListener('keyup', this.handleKeyUp, false); |
|
|
|
window.addEventListener('keydown', this.handleKeyDown, false); |
|
|
|
if (this.context.router) { |
|
|
|
if (this.context.router) { |
|
|
|
const history = this.context.router.history; |
|
|
|
const history = this.context.router.history; |
|
|
|
history.push(history.location.pathname, previewState); |
|
|
|
history.push(history.location.pathname, previewState); |
|
|
@ -77,7 +81,7 @@ export default class MediaModal extends ImmutablePureComponent { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
componentWillUnmount () { |
|
|
|
componentWillUnmount () { |
|
|
|
window.removeEventListener('keyup', this.handleKeyUp); |
|
|
|
window.removeEventListener('keydown', this.handleKeyDown); |
|
|
|
if (this.context.router) { |
|
|
|
if (this.context.router) { |
|
|
|
this.unlistenHistory(); |
|
|
|
this.unlistenHistory(); |
|
|
|
|
|
|
|
|
|
|
|