Created
July 10, 2012 17:56
-
-
Save DrewDahlman/3085142 to your computer and use it in GitHub Desktop.
waypoints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onkeydown = function(event){ | |
keyboard.press(event.keyCode); | |
} | |
}()); | |
var $panes = $(".waypoint").length-1; | |
var $currentPane = $(".waypoint").first(); | |
var keyboard = { | |
press:function(keycode){ | |
console.log(keycode); | |
switch(keycode){ | |
case 74: | |
//model_nav.killWaypoint(); | |
if($currentPane.index()>=$panes){ | |
$currentPane = $currentPane.next('.waypoint'); | |
} | |
else { | |
$currentPane = $(".waypoint").first(); | |
} | |
var go = $currentPane.offset().top-65; | |
$('html,body').stop().animate({scrollTop:go},function(){ | |
//model_nav.listenWaypoint(); | |
}); | |
break; | |
case 75: | |
//model_nav.killWaypoint(); | |
if($currentPane.index()<=-1){ | |
$currentPane = $(".waypoint").last(); | |
} | |
else { | |
$currentPane = $currentPane.prev('.waypoint'); | |
} | |
var go = $currentPane.offset().top-65; | |
$('html,body').stop().animate({scrollTop:go},function(){ | |
//model_nav.listenWaypoint(); | |
}); | |
break; | |
case 40: | |
//model_nav.killWaypoint(); | |
if($currentPane.index()>=$panes){ | |
$currentPane = $currentPane.next('.waypoint'); | |
} | |
else { | |
$currentPane = $(".waypoint").first(); | |
} | |
var go = $currentPane.offset().top-65; | |
$('html,body').stop().animate({scrollTop:go},function(){ | |
//model_nav.listenWaypoint(); | |
}); | |
break; | |
case 38: | |
//model_nav.killWaypoint(); | |
if($currentPane.index()<=-1){ | |
$currentPane = $(".waypoint").last(); | |
} | |
else { | |
$currentPane = $currentPane.prev('.waypoint'); | |
} | |
var go = $currentPane.offset().top-65; | |
$('html,body').stop().animate({scrollTop:go},function(){ | |
//model_nav.listenWaypoint(); | |
}); | |
break; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment