Permalink
Browse files

keyboard

  • Loading branch information...
1 parent 81d7aa7 commit 3f49cb456d91d00b332ff7c30fc65a4f3532ea7b @taboca committed Apr 16, 2012
Showing with 57 additions and 14 deletions.
  1. +23 −2 index.html
  2. +34 −12 lib/tagvisor.js
View
@@ -7,13 +7,33 @@
<script type="text/javascript" src="lib/tagvisor.js"></script>
<script>
-$.scPlayer.defaults.autoPlay = true;
-$.scPlayer.defaults.randomize = true;
+var on = false;
function start() {
tv.add($('#animation li'));
+ tv.tickMode = true;
tv.play();
}
+
+function startKeys() {
+ tv.tickMode = false;
+
+ tv.add($('#animation li'));
+ tv.play(1);
+ on = true;
+ document.body.addEventListener("keydown", function (e) {
+ if(e.keyCode==37) {
+ tv.tick(-1);
+ e.preventDefault();
+ }
+ if(e.keyCode==39) {
+ tv.tick(1);
+ e.preventDefault();
+ }
+ }, false);
+
+}
+
</script>
<style>
@@ -65,6 +85,7 @@
<div class='header' style='text-align:center;margin-top:1em'>
<a href='javascript:' style='font-size:150%' onclick='start()'>Start Couch Mode</a>
+<a href='javascript:' style='font-size:150%' onclick='startKeys()'>Keyboard mode</a>
<br />tip: you can also edit the text boxes. :)
</div>
View
@@ -46,6 +46,7 @@ var tv = {
recordScale: 1,
itemsByTicks: new Array(),
sortedItems: new Array(),
+ tickMode: true,
dataStyle: ".slide { position:relative; } ",
dumpTransform: function (property) {
@@ -121,7 +122,13 @@ var tv = {
play: function () {
if(this.playMode==false) {
this.setup();
- }
+ }
+ var these = this;
+ setTimeout(function () { these.startPlay() }, 500);
+
+ },
+
+ startPlay: function () {
this.playMode=true;
this.sortedItems = this.sortArray(this.itemsByTicks);
var i=0;
@@ -132,15 +139,24 @@ var tv = {
this.ticksSerialized[i]=-1;
this.currentTick=0;
this.counterSequential=0;
- this.tick();
- } ,
+ this.tick(1);
+ },
- tick: function () {
+ tick: function (dir) {
if(this.playMode) {
try {
+ if(!this.tickMode) {
+ if(dir==1) this.counterSequential++;
+ if(dir==-1) this.counterSequential--;
+ }
var nextTick = this.ticksSerialized[this.counterSequential];
if(nextTick > -1) {
- if(nextTick==this.currentTick) {
+ if(nextTick==this.currentTick || this.tickMode == false) {
+
+ if(this.tickMode == false ) {
+ this.currentTick = nextTick;
+ }
+
var lookUpElement = this.itemsByTicks[this.currentTick];
if(lookUpElement) {
@@ -202,22 +218,30 @@ try {
if(fEffect == "movecenter") {
this.effects_animateNext(targetElement, currDoc,dur, true);
}
- this.counterSequential++;
+ if(this.tickMode ) {
+ this.counterSequential++;
+ }
}
}
- this.currentTick++;
+ if(this.tickMode) {
+ this.currentTick++;
+ }
var stampThis = this;
- setTimeout(function () { stampThis.tick() } ,500);
+ if(this.tickMode) {
+ setTimeout(function () { stampThis.tick(1) } ,500);
+ }
} else {
- //end
}
} catch (i) {
+ if(this.tickMode) {
+ this.currentTick++;
+ }
this.currentTick++;
var stampThis = this;
- setTimeout(function () { stampThis.tick() } ,500);
+ setTimeout(function () { stampThis.tick(1) } ,500);
}
}
} ,
@@ -301,8 +325,6 @@ try {
var www = window.innerWidth;
var scale = www/(ww+800);
- //document.getElementById("pagescale").setAttribute("style"," -moz-transition-property: -moz-transform; -moz-transform:scale("+scale+"); -moz-transition-duration:3s; -webkit-transition-property: -webkit-transform; -webkit-transform:scale("+scale+"); -webkit-transition-duration:3s; -o-transition-property: -o-transform; -o-transform:scale("+scale+"); -o-transition-duration:3s;");
-
x-=0;
d.getElementById("pagetranslate").setAttribute("style","-moz-transition-property: -moz-transform; -moz-transform:translate("+-1*x+","+-1*y+"); -moz-transition-duration:"+t+"s; -webkit-transition-property: -webkit-transform; -webkit-transform:translate("+parseInt(-1*x)+"px,"+parseInt(-1*y)+"px); -webkit-transition-duration:"+t+"s; -o-transition-property: -o-transform; -o-transform:translate("+parseInt(-1*x)+"px,"+parseInt(-1*y)+"px); -o-transition-duration:"+t+"s;");
}

0 comments on commit 3f49cb4

Please sign in to comment.