Skip to content

Commit

Permalink
left and right scrolls through gallery.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaburke91 committed Sep 7, 2017
1 parent b5f6fa9 commit bbf9ed2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion public/js/app.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/app.min.js.map

Large diffs are not rendered by default.

25 changes: 24 additions & 1 deletion react/PhotoGallery/PhotoGallery.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,30 @@ class PhotoGallery extends React.Component {
}

componentDidMount() {
// console.log(this.props.gallery);
$(document.body).on('keydown', this.handleKeyDown.bind(this));
}

componentWillUnmount() {
$(document.body).off('keydown', this.handleKeyDown.bind(this));
}

handleKeyDown(e) {
// let that = this;
if (!this.props.gallery.isVisible) return;

switch(e.which) {
case 37: // left
this.props.previousPhoto();
break;

case 39: // right
this.props.nextPhoto();
break;

default: return; // exit this handler for other keys
}

e.preventDefault(); // prevent the default action (scroll / move caret)
}

render() {
Expand Down

0 comments on commit bbf9ed2

Please sign in to comment.