From 7de0a547d38cdb135c56591096345cecf1f90c2c Mon Sep 17 00:00:00 2001 From: piro Date: Wed, 8 Apr 2009 09:16:39 +0000 Subject: [PATCH] =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=9E=E3=83=BC=E3=82=92?= =?UTF-8?q?=E4=B8=80=E7=AE=87=E6=89=80=E3=81=AB=E3=81=BE=E3=81=A8=E3=82=81?= =?UTF-8?q?=E3=81=A6=E3=80=81=E3=82=A2=E3=83=8B=E3=83=A1=E3=83=BC=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=81=AE=E8=B2=A0=E8=8D=B7=E3=82=92=E8=BB=BD?= =?UTF-8?q?=E3=81=8F=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4077 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 63 ++++++++++++++++++--- content/treestyletab/treestyletabbrowser.js | 44 ++++++++------ 2 files changed, 82 insertions(+), 25 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 7b12c851..6d959af7 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -32,7 +32,7 @@ var TreeStyleTabService = { kDROP_MARKER_CONTAINER : 'treestyletab-drop-marker-container', kCOUNTER : 'treestyletab-counter', kCOUNTER_CONTAINER : 'treestyletab-counter-container', - kSPLITTER : 'treestyletab-splitter', + kSPLITTER : 'treestyletab-splitter', kTABBAR_TOGGLER : 'treestyletab-tabbar-toggler', kSTRINGBUNDLE : 'treestyletab-stringbundle', @@ -84,7 +84,7 @@ var TreeStyleTabService = { kSHOWN_BY_UNKNOWN : 0, kSHOWN_BY_SHORTCUT : 1 << 0, kSHOWN_BY_MOUSEMOVE : 1 << 1, - kSHOWN_BY_FEEDBACK : 1 << 2, + kSHOWN_BY_FEEDBACK : 1 << 2, kKEEP_SHOWN_ON_MOUSEOVER : (1 << 0) | (1 << 1) | (1 << 2), kTRANSPARENT_NONE : 0, @@ -963,6 +963,50 @@ var TreeStyleTabService = { useTMPSessionAPI : false, kTMP_SESSION_DATA_PREFIX : 'tmp-session-data-', + +/* animation */ + animationTasks : [], + animationInterval : 10, + animationTimer : null, + + addAnimationTask : function(aTask) + { + if (!aTask) return; + this.animationTasks.push(aTask); + if (this.animationTasks.length > 1) return; + this.endAnimations(); + this.animationTimer = window.setInterval( + this.animationCallback, + this.animationInterval, + this + ); + }, + + removeAnimationTask : function(aTask) + { + if (!aTask) return; + var index = this.animationTasks.indexOf(aTask); + if (index > -1) this.animationTasks.splice(index, 1); + if (!this.animationTasks.length) + this.endAnimations(); + }, + + endAnimations : function() + { + if (!this.animationTimer) return; + window.clearInterval(this.animationTimer); + this.animationTimer = null; + }, + + animationCallback : function(aSelf) + { + // task should return true if it finishes. + aSelf.animationTasks = aSelf.animationTasks.filter(function(aTask) { + return !aTask(); + }); + if (!aSelf.animationTasks.length) + aSelf.endAnimations(); + }, /* Initializing */ @@ -1506,12 +1550,12 @@ catch(e) { var treeStyleTab = gBrowser.treeStyleTab; if (gBrowser.getAttribute(treeStyleTab.kTABBAR_POSITION) != 'top') { treeStyleTab.autoHideMode = treeStyleTab.getTreePref(window.fullScreen ? 'tabbar.autoHide.mode.fullscreen' : 'tabbar.autoHide.mode' ); - treeStyleTab.endAutoHide(); + treeStyleTab.endAutoHide(); treeStyleTab.autoHideMode = treeStyleTab.getTreePref(window.fullScreen ? 'tabbar.autoHide.mode' : 'tabbar.autoHide.mode.fullscreen' ); if (window.fullScreen) treeStyleTab.checkTabsIndentOverflow(); if (treeStyleTab.autoHideMode != treeStyleTab.kAUTOHIDE_MODE_DISABLED) - treeStyleTab.startAutoHide(); + treeStyleTab.startAutoHide(); } ]]> ) @@ -1541,6 +1585,7 @@ catch(e) { { window.removeEventListener('unload', this, false); + this.endAnimations(); this.destroyTabBrowser(gBrowser); this.endListenKeyEvents(); @@ -1713,12 +1758,12 @@ catch(e) { this.keyEventListening = false; }, keyEventListening : false, - get shouldListenKeyEvents() - { + get shouldListenKeyEvents() + { return this.getTreePref('tabbar.autoShow.accelKeyDown') || - this.getTreePref('tabbar.autoShow.tabSwitch') || - this.getTreePref('tabbar.autoShow.feedback'); - }, + this.getTreePref('tabbar.autoShow.tabSwitch') || + this.getTreePref('tabbar.autoShow.feedback'); + }, onTabbarResized : function(aEvent) { diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index ce045bb6..dca584b3 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -2821,7 +2821,9 @@ TreeStyleTabBrowser.prototype = { var delta = aIndent - startIndent; var delay = this.indentDelay; var startTime = Date.now(); - aTab.__treestyletab__updateTabIndentTimer = window.setInterval(function(aSelf) { + + var self = this; + aTab.__treestyletab__updateTabIndentTask = function() { var power = Math.min(1, (Date.now() - startTime) / delay); var powerForStyle = Math.sin(90 * power * Math.PI / 180); var indent = (power == 1) ? @@ -2834,14 +2836,19 @@ TreeStyleTabBrowser.prototype = { aProp+':'+indent+'px !important;' ); - if (power == 1) aSelf.stopTabIndentAnimation(aTab); - }, 10, this); + if (power == 1) { + delete aTab.__treestyletab__updateTabIndentTask; + return true; + } + else { + return false; + } + }; + TreeStyleTabService.addAnimationTask(aTab.__treestyletab__updateTabIndentTask); }, stopTabIndentAnimation : function(aTab) { - if (!aTab.__treestyletab__updateTabIndentTimer) return; - window.clearInterval(aTab.__treestyletab__updateTabIndentTimer); - aTab.__treestyletab__updateTabIndentTimer = null; + TreeStyleTabService.removeAnimationTask(aTab.__treestyletab__updateTabIndentTask); }, inheritTabIndent : function(aNewTab, aExistingTab) @@ -3089,7 +3096,8 @@ TreeStyleTabBrowser.prototype = { ); if (!aCollapsed) aTab.removeAttribute(this.kCOLLAPSED_DONE); - aTab.__treestyletab__updateTabCollapsedTimer = window.setInterval(function(aSelf) { + var self = this; + aTab.__treestyletab__updateTabCollapsedTask = function() { var power = Math.min(1, (Date.now() - startTime) / delay); var powerForStyle = Math.sin(90 * power * Math.PI / 180); var margin = (power == 1) ? @@ -3107,25 +3115,29 @@ TreeStyleTabBrowser.prototype = { ); if (power == 1) { - aSelf.stopTabCollapseAnimation(aTab); - aTab.removeAttribute(aSelf.kCOLLAPSING); + aTab.removeAttribute(self.kCOLLAPSING); aTab.setAttribute( 'style', aTab.getAttribute('style') .replace(regexp, '') - .replace(aSelf.kOPACITY_RULE_REGEXP, '') + .replace(self.kOPACITY_RULE_REGEXP, '') ); - if (aCollapsed) - aTab.setAttribute(aSelf.kCOLLAPSED_DONE, true); + if (aCollapsed) { + aTab.setAttribute(self.kCOLLAPSED_DONE, true); + } + delete aTab.__treestyletab__updateTabCollapsedTask; + return true; } - }, 10, this); + else { + return false; + } + }; + TreeStyleTabService.addAnimationTask(aTab.__treestyletab__updateTabCollapsedTask); }, kOPACITY_RULE_REGEXP : /opacity\s*:[^;]+;?/, stopTabCollapseAnimation : function(aTab) { - if (!aTab.__treestyletab__updateTabCollapsedTimer) return; - window.clearInterval(aTab.__treestyletab__updateTabCollapsedTimer); - aTab.__treestyletab__updateTabCollapsedTimer = null; + TreeStyleTabService.removeAnimationTask(aTab.__treestyletab__updateTabCollapsedTask); }, collapseExpandTreesIntelligentlyFor : function(aTab, aJustNow)