diff --git a/js/navbar/tabActivity.js b/js/navbar/tabActivity.js index cb729c4e8..8cf226b4b 100644 --- a/js/navbar/tabActivity.js +++ b/js/navbar/tabActivity.js @@ -4,6 +4,28 @@ var tabBar = require('navbar/tabBar.js') var tabActivity = { minFadeAge: 330000, + refreshInterval: 7500, + tabSelected: function() { + var selected = tabs.getSelected() + if (tabBar.getTab(selected).classList.contains('fade')) { + // check to see if it is still has been selected in .500 seconds + setTimeout(function (tabID) { + if (tabs.getSelected() != tabID) { + var tab = tabs.get(tabID) + if (tab) { + tabBar.getTab(tabID).classList.add('fade') + tabs.update(tabID, {'lastActivity':tab.lastActivity - tabActivity.minFadeAge}) + } + + } + }, 500, selected); + } + + // never fade the current tab + tabBar.getTab(selected).classList.remove('fade') + + + }, refresh: function () { requestAnimationFrame(function () { var tabSet = tabs.get() @@ -11,11 +33,10 @@ var tabActivity = { var time = Date.now() tabSet.forEach(function (tab) { - if (selected === tab.id) { // never fade the current tab - tabBar.getTab(tab.id).classList.remove('fade') - return - } - if (time - tab.lastActivity > tabActivity.minFadeAge) { // the tab has been inactive for greater than minActivity, and it is not currently selected + if (selected == tab.id) { return } + + //else + if ((time - tab.lastActivity > tabActivity.minFadeAge)) { // the tab has been inactive for greater than minActivity, and it is not currently selected tabBar.getTab(tab.id).classList.add('fade') } else { tabBar.getTab(tab.id).classList.remove('fade') @@ -24,9 +45,9 @@ var tabActivity = { }) }, initialize: function () { - setInterval(tabActivity.refresh, 7500) + setInterval(tabActivity.refresh, this.refreshInterval) - tasks.on('tab-selected', this.refresh) + tasks.on('tab-selected', this.tabSelected) } }