Skip to content

Instantly share code, notes, and snippets.

@themorgantown
Created November 29, 2017 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themorgantown/2a9fbc8e94ce4aaaa41ccc1cd0c73571 to your computer and use it in GitHub Desktop.
Save themorgantown/2a9fbc8e94ce4aaaa41ccc1cd0c73571 to your computer and use it in GitHub Desktop.
1 second stepper
<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