mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-28 00:11:37 +01:00
Prevent scrolling main frame when navigating in image gallery with arrow keys
This commit is contained in:
parent
02326a4322
commit
82ab5aacb2
1 changed files with 7 additions and 3 deletions
|
@ -48,23 +48,27 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
window.removeEventListener('keyup', this.handleKeyUp);
|
window.removeEventListener('keydown', this.handleKeyDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndex () {
|
getIndex () {
|
||||||
|
|
Loading…
Reference in a new issue