画面外に開かれたタブに正しくスクロールするようにした

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4096 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-04-08 15:16:34 +00:00
parent 6222e65b0b
commit 3da96a7572
2 changed files with 34 additions and 12 deletions

View File

@ -913,6 +913,23 @@ var TreeStyleTabService = {
} }
} }
}, },
getXOffsetOfTab : function(aTab)
{
return this.evaluateXPath(
'sum((self::* | preceding-sibling::xul:tab)/attribute::'+this.kX_OFFSET+')',
aTab,
XPathResult.NUMBER_TYPE
).numberValue;
},
getYOffsetOfTab : function(aTab)
{
return this.evaluateXPath(
'sum((self::* | preceding-sibling::xul:tab)/attribute::'+this.kY_OFFSET+')',
aTab,
XPathResult.NUMBER_TYPE
).numberValue;
},
/* Session Store API */ /* Session Store API */

View File

@ -113,10 +113,12 @@ TreeStyleTabBrowser.prototype = {
if (!aTab) return false; if (!aTab) return false;
var tabBox = aTab.boxObject; var tabBox = aTab.boxObject;
var barBox = this.scrollBox.boxObject; var barBox = this.scrollBox.boxObject;
return (tabBox.screenX >= barBox.screenX && var xOffset = this.getXOffsetOfTab(aTab);
tabBox.screenX + tabBox.width <= barBox.screenX + barBox.width && var yOffset = this.getYOffsetOfTab(aTab);
tabBox.screenY >= barBox.screenY && return (tabBox.screenX + xOffset >= barBox.screenX &&
tabBox.screenY + tabBox.height <= barBox.screenY + barBox.height); tabBox.screenX + xOffset + tabBox.width <= barBox.screenX + barBox.width &&
tabBox.screenY + yOffset >= barBox.screenY &&
tabBox.screenY + yOffset + tabBox.height <= barBox.screenY + barBox.height);
}, },
isMultiRow : function() isMultiRow : function()
@ -3097,7 +3099,7 @@ TreeStyleTabBrowser.prototype = {
endOpacity = 0; endOpacity = 0;
} }
else { else {
aTab.setAttribute(offsetAttr, -maxMargin); aTab.setAttribute(offsetAttr, maxMargin);
startMargin = maxMargin; startMargin = maxMargin;
endMargin = 0; endMargin = 0;
startOpacity = 0; startOpacity = 0;
@ -3145,7 +3147,7 @@ TreeStyleTabBrowser.prototype = {
collapseProp+': -'+margin+'px !important;'+ collapseProp+': -'+margin+'px !important;'+
'opacity: '+opacity+' !important;' 'opacity: '+opacity+' !important;'
); );
aTab.setAttribute(offsetAttr, -maxMargin); aTab.setAttribute(offsetAttr, maxMargin);
return false; return false;
} }
}; };
@ -3305,13 +3307,16 @@ TreeStyleTabBrowser.prototype = {
var targetTabBox = aTab.boxObject; var targetTabBox = aTab.boxObject;
var baseTabBox = aTab.parentNode.firstChild.boxObject; var baseTabBox = aTab.parentNode.firstChild.boxObject;
var targetX = (aTab.boxObject.screenX < scrollBoxObject.screenX) ? var xOffset = this.getXOffsetOfTab(aTab);
(targetTabBox.screenX - baseTabBox.screenX) - (targetTabBox.width * 0.5) : var yOffset = this.getYOffsetOfTab(aTab);
(targetTabBox.screenX - baseTabBox.screenX) - scrollBoxObject.width + (targetTabBox.width * 1.5) ;
var targetY = (aTab.boxObject.screenY < scrollBoxObject.screenY) ? var targetX = (aTab.boxObject.screenX + xOffset < scrollBoxObject.screenX) ?
(targetTabBox.screenY - baseTabBox.screenY) - (targetTabBox.height * 0.5) : (targetTabBox.screenX + xOffset - baseTabBox.screenX) - (targetTabBox.width * 0.5) :
(targetTabBox.screenY - baseTabBox.screenY) - scrollBoxObject.height + (targetTabBox.height * 1.5) ; (targetTabBox.screenX + xOffset - baseTabBox.screenX) - scrollBoxObject.width + (targetTabBox.width * 1.5) ;
var targetY = (aTab.boxObject.screenY + yOffset < scrollBoxObject.screenY) ?
(targetTabBox.screenY + yOffset - baseTabBox.screenY) - (targetTabBox.height * 0.5) :
(targetTabBox.screenY + yOffset - baseTabBox.screenY) - scrollBoxObject.height + (targetTabBox.height * 1.5) ;
this.scrollTo(targetX, targetY); this.scrollTo(targetX, targetY);
}, },