Skip to content

Instantly share code, notes, and snippets.

@themorgantown
Forked from pauginer/hype-slides
Last active April 12, 2016 10:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themorgantown/130fd781c68608815390 to your computer and use it in GitHub Desktop.
Save themorgantown/130fd781c68608815390 to your computer and use it in GitHub Desktop.
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
// http://mikemurko.com/general/jquery-keycode-cheatsheet/
var speed = 0.8; //transition speed
var transition = "push"; //types of transition: instant, fade, swap, push
var nextKeys= [39, 40, 34];
var prevKeys= [37, 38, 33];
$(function(){
$( "body" ).keyup(function(e){
var hypeDocument = getHypeDocument();
var t = transitionType(hypeDocument, transition);
if($.inArray(e.which, nextKeys) > -1){
hypeDocument.showNextScene(t[0], speed);
}else if ($.inArray(e.which, prevKeys) > -1){
hypeDocument.showPreviousScene(t[1], speed)
}
});
});
function transitionType(hypeDocument,type){
var result = [hypeDocument.kSceneTransitionInstant, hypeDocument.kSceneTransitionInstant];
if(type == "fade"){
result = [hypeDocument.kSceneTransitionCrossfade, hypeDocument.kSceneTransitionCrossfade];
} else if (type == "swap") {
result = [hypeDocument.kSceneTransitionSwap, hypeDocument.kSceneTransitionSwap];
} else if (type = "push") {
result = [hypeDocument.kSceneTransitionPushRightToLeft, hypeDocument.kSceneTransitionPushLeftToRight];
}
return result;
}
function getHypeDocument(){
var name = "index";
for(var key in HYPE.documents){
name = key;
}
return HYPE.documents[name];
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment