Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

Commit

Permalink
feat(navigation): add support for page-up and page-down to navigate f…
Browse files Browse the repository at this point in the history
…orward and backward
  • Loading branch information
Philipp Burgmer committed Feb 19, 2015
1 parent d5df568 commit 97320ac
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions src/slides/slides.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,40 +163,36 @@ angular.module('w11k.slides').directive('w11kSlides', [
}

$document.bind('keydown', function (event) {
// right
if (event.keyCode === 39) {
$rootScope.$apply(function () {
goToNext();
});
var action;

// right or page down
if (event.keyCode === 39 || event.keyCode === 34) {
action = goToNext;
}
// left
else if (event.keyCode === 37) {
$rootScope.$apply(function () {
goToPrevious();
});
// left or page up
else if (event.keyCode === 37 || event.keyCode === 33) {
action = goToPrevious;
}
// pos 1
else if (event.keyCode === 36) {
$rootScope.$apply(function () {
SlidesService.navigateToFirst();
});
action = SlidesService.navigateToFirst;
}
// end
else if (event.keyCode === 35) {
$rootScope.$apply(function () {
SlidesService.navigateToLast();
});
action = SlidesService.navigateToLast;
}
// o
else if (event.keyCode === 79) {
$rootScope.$apply(function () {
SlidesService.navigateToOverview();
});
action = SlidesService.navigateToOverview;
}
// e
else if (event.keyCode === 69) {
action = toggleMode;
}

if (action) {
$rootScope.$apply(function () {
toggleMode();
action();
});
}
});
Expand Down

0 comments on commit 97320ac

Please sign in to comment.