From: Robert Kaiser Date: Fri, 14 Sep 2012 01:38:46 +0000 (+0200) Subject: hide UI when it's not needed X-Git-Tag: legacy-preGL~64 X-Git-Url: https://git-public.kairo.at/?a=commitdiff_plain;h=7a54914850a97c86e9fb4a550a88ce5744d3e7eb;p=lantea.git hide UI when it's not needed --- diff --git a/js/map.js b/js/map.js index f27b019..d07cd74 100644 --- 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": diff --git a/js/ui.js b/js/ui.js index 8efe4c0..65992f7 100644 --- 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 index a9b23fc..0000000 --- a/manifest.appcache +++ /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: - diff --git a/style/lantea.css b/style/lantea.css index b358a1d..823745a 100644 --- a/style/lantea.css +++ b/style/lantea.css @@ -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; }