hide UI when it's not needed
authorRobert Kaiser <kairo@kairo.at>
Fri, 14 Sep 2012 01:38:46 +0000 (03:38 +0200)
committerRobert Kaiser <kairo@kairo.at>
Fri, 14 Sep 2012 01:38:46 +0000 (03:38 +0200)
js/map.js
js/ui.js
manifest.appcache [deleted file]
style/lantea.css

index f27b0191c51efa38c6108e7cae000a3d56d22a75..d07cd743682289b924cc6142399eee4c5b688291 100644 (file)
--- a/js/map.js
+++ b/js/map.js
@@ -145,6 +145,7 @@ function resizeAndDraw() {
   gCanvas.width = canvasWidth;
   gCanvas.height = canvasHeight;
   drawMap();
+  showUI();
 }
 
 function zoomIn() {
@@ -369,6 +370,7 @@ var mapEvHandler = {
         }
         gLastMouseX = x;
         gLastMouseY = y;
+        showUI();
         break;
       case "mousemove":
       case "touchmove":
@@ -380,6 +382,7 @@ var mapEvHandler = {
           gPos.x -= dX * gZoomFactor;
           gPos.y -= dY * gZoomFactor;
           drawMap();
+          showUI();
         }
         gLastMouseX = x;
         gLastMouseY = y;
@@ -387,6 +390,7 @@ var mapEvHandler = {
       case "mouseup":
       case "touchend":
         gDragging = false;
+        showUI();
         break;
       case "mouseout":
       case "touchcancel":
index 8efe4c052ffbb1840340357b02d4a35a62929385..65992f77411bb1b0e1608514a15ea04f6bf2b2ab 100644 (file)
--- a/js/ui.js
+++ b/js/ui.js
@@ -6,6 +6,8 @@
 var iDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.msIndexedDB;
 var mainDB;
 
+var gUIHideCountdown = 0;
+
 window.onload = function() {
   var mSel = document.getElementById("mapSelector");
   for (var mapStyle in gMapStyles) {
@@ -15,6 +17,21 @@ window.onload = function() {
     mSel.add(opt, null);
   }
 
+  var areas = document.getElementsByClassName('overlayArea');
+  for (var i = 0; i <= areas.length - 1; i++) {
+    areas[i].addEventListener("mouseup", uiEvHandler, false);
+    areas[i].addEventListener("mousemove", uiEvHandler, false);
+    areas[i].addEventListener("mousedown", uiEvHandler, false);
+    areas[i].addEventListener("mouseout", uiEvHandler, false);
+
+    areas[i].addEventListener("touchstart", uiEvHandler, false);
+    areas[i].addEventListener("touchmove", uiEvHandler, false);
+    areas[i].addEventListener("touchend", uiEvHandler, false);
+    areas[i].addEventListener("touchcancel", uiEvHandler, false);
+    areas[i].addEventListener("touchleave", uiEvHandler, false);
+  }
+
+
   initDB();
   initMap();
   resizeAndDraw();
@@ -52,10 +69,35 @@ function initDB() {
   };
 }
 
+function showUI() {
+  if (gUIHideCountdown <= 0) {
+    var areas = document.getElementsByClassName('overlayArea');
+    for (var i = 0; i <= areas.length - 1; i++) {
+      areas[i].classList.remove("hidden");
+    }
+    setTimeout(maybeHideUI, 1000);
+  }
+  gUIHideCountdown = 5;
+}
+
+function maybeHideUI() {
+  gUIHideCountdown--;
+  if (gUIHideCountdown <= 0) {
+    var areas = document.getElementsByClassName('overlayArea');
+    for (var i = 0; i <= areas.length - 1; i++) {
+      areas[i].classList.add("hidden");
+    }
+  }
+  else {
+    setTimeout(maybeHideUI, 1000);
+  }
+}
+
 function toggleTrackArea() {
   var fs = document.getElementById("trackArea");
   if (fs.style.display != "block") {
     fs.style.display = "block";
+    showUI();
   }
   else {
     fs.style.display = "none";
@@ -66,12 +108,30 @@ function toggleSettings() {
   var fs = document.getElementById("settingsArea");
   if (fs.style.display != "block") {
     fs.style.display = "block";
+    showUI();
   }
   else {
     fs.style.display = "none";
   }
 }
 
+var uiEvHandler = {
+  handleEvent: function(aEvent) {
+    var touchEvent = aEvent.type.indexOf('touch') != -1;
+
+    switch (aEvent.type) {
+      case "mousedown":
+      case "touchstart":
+      case "mousemove":
+      case "touchmove":
+      case "mouseup":
+      case "touchend":
+        showUI();
+        break;
+    }
+  }
+};
+
 function makeISOString(aTimestamp) {
   // ISO time format is YYYY-MM-DDTHH:mm:ssZ
   var tsDate = new Date(aTimestamp);
diff --git a/manifest.appcache b/manifest.appcache
deleted file mode 100644 (file)
index a9b23fc..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-CACHE MANIFEST
-
-# /
-index.html
-manifest.webapp
-js/map.js
-js/ui.js
-style/lantea.css
-style/loading.png
-style/lanteaIcon16.png
-style/lanteaIcon32.png
-style/lanteaIcon64.png
-style/lanteaIcon128.png
-
-NETWORK:
-
index b358a1d83deda6d7b510deab2f4c1225863aca74..823745ad7cff0d9baf1ee985f36422c6bc4bb13c 100644 (file)
@@ -27,6 +27,16 @@ h1 {
   text-align: center;
 }
 
+.overlayArea {
+  transition-property: opacity;
+  transition-duration: .2s;
+}
+
+.overlayArea.hidden {
+  opacity: 0;
+  transition-duration: 1s;
+}
+
 .overlayArea:-moz-system-metric(touch-enabled) {
   font-size: 3mozmm;
 }