Created
November 29, 2017 15:56
-
-
Save themorgantown/2a9fbc8e94ce4aaaa41ccc1cd0c73571 to your computer and use it in GitHub Desktop.
1 second stepper
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
<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 CurrentTime = hypeDocument.currentTimeInTimelineNamed('Main Timeline'); | |
var StepAmount = 1000 // number of milliseconds each step represents | |
var t = transitionType(hypeDocument, transition); | |
if($.inArray(e.which, nextKeys) > -1){ | |
hypeDocument.continueTimelineNamed('Main Timeline', hypeDocument.kDirectionForward, false); | |
window.setTimeout(function() { | |
hypeDocument.pauseTimelineNamed('Main Timeline') | |
}, StepAmount); | |
//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