アニメーション関係の計算を修正
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4091 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
fd3d6c626e
commit
cc3f5a9bbc
@ -22,7 +22,7 @@
|
|||||||
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/animationManager.js
|
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/animationManager.js
|
||||||
*/
|
*/
|
||||||
(function() {
|
(function() {
|
||||||
const currentRevision = 2;
|
const currentRevision = 3;
|
||||||
|
|
||||||
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
|
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
|
||||||
|
|
||||||
@ -96,10 +96,11 @@
|
|||||||
onAnimation : function(aSelf)
|
onAnimation : function(aSelf)
|
||||||
{
|
{
|
||||||
// task should return true if it finishes.
|
// task should return true if it finishes.
|
||||||
|
var now = Date.now();
|
||||||
aSelf.tasks = aSelf.tasks.filter(function(aTask) {
|
aSelf.tasks = aSelf.tasks.filter(function(aTask) {
|
||||||
try {
|
try {
|
||||||
return !aTask.task(
|
return !aTask.task(
|
||||||
Date.now() - aTask.start,
|
now - aTask.start,
|
||||||
aTask.beginning,
|
aTask.beginning,
|
||||||
aTask.final,
|
aTask.final,
|
||||||
aTask.delay
|
aTask.delay
|
||||||
|
@ -2819,27 +2819,25 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
var startIndent = this.getPropertyPixelValue(aTab, aProp);
|
var startIndent = this.getPropertyPixelValue(aTab, aProp);
|
||||||
var delta = aIndent - startIndent;
|
var delta = aIndent - startIndent;
|
||||||
|
var radian = 90 * Math.PI / 180;
|
||||||
var self = this;
|
var self = this;
|
||||||
aTab.__treestyletab__updateTabIndentTask = function(aTime, aBeginning, aFinal, aDelay) {
|
aTab.__treestyletab__updateTabIndentTask = function(aTime, aBeginning, aFinal, aDelay) {
|
||||||
var power = Math.min(1, aTime / aDelay);
|
var indent, finished;
|
||||||
var powerForStyle = Math.sin(90 * power * Math.PI / 180);
|
if (aTime >= aDelay) {
|
||||||
var indent = (power == 1) ?
|
|
||||||
aIndent :
|
|
||||||
startIndent + (delta * powerForStyle);
|
|
||||||
aTab.setAttribute(
|
|
||||||
'style',
|
|
||||||
aTab.getAttribute('style')
|
|
||||||
.replace(regexp, '')+';'+
|
|
||||||
aProp+':'+indent+'px !important;'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (power == 1) {
|
|
||||||
delete aTab.__treestyletab__updateTabIndentTask;
|
delete aTab.__treestyletab__updateTabIndentTask;
|
||||||
return true;
|
indent = aIndent;
|
||||||
|
finished = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
indent = startIndent + (delta * Math.sin(aTime / aDelay * radian));
|
||||||
|
finished = false;
|
||||||
}
|
}
|
||||||
|
aTab.setAttribute(
|
||||||
|
'style',
|
||||||
|
aTab.getAttribute('style').replace(regexp, '')+';'+
|
||||||
|
aProp+':'+indent+'px !important;'
|
||||||
|
);
|
||||||
|
return finished;
|
||||||
};
|
};
|
||||||
window['piro.sakura.ne.jp'].animationManager.addTask(
|
window['piro.sakura.ne.jp'].animationManager.addTask(
|
||||||
aTab.__treestyletab__updateTabIndentTask,
|
aTab.__treestyletab__updateTabIndentTask,
|
||||||
@ -3078,11 +3076,20 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var height = this.getFirstTab(this.mTabBrowser).boxObject.height;
|
var height = this.getFirstTab(this.mTabBrowser).boxObject.height;
|
||||||
var startMargin = aCollapsed ? 0 : height ;
|
var startMargin, endMargin, startOpacity, endOpacity;
|
||||||
var endMargin = aCollapsed ? height : 0 ;
|
if (aCollapsed) {
|
||||||
|
startMargin = 0;
|
||||||
|
endMargin = height;
|
||||||
|
startOpacity = 1;
|
||||||
|
endOpacity = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
startMargin = height;
|
||||||
|
endMargin = 0;
|
||||||
|
startOpacity = 0;
|
||||||
|
endOpacity = 1;
|
||||||
|
}
|
||||||
var deltaMargin = endMargin - startMargin;
|
var deltaMargin = endMargin - startMargin;
|
||||||
var startOpacity = aCollapsed ? 1 : 0 ;
|
|
||||||
var endOpacity = aCollapsed ? 0 : 1 ;
|
|
||||||
var deltaOpacity = endOpacity - startOpacity;
|
var deltaOpacity = endOpacity - startOpacity;
|
||||||
var collapseProp = this.collapseProp;
|
var collapseProp = this.collapseProp;
|
||||||
|
|
||||||
@ -3096,25 +3103,12 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
);
|
);
|
||||||
if (!aCollapsed) aTab.removeAttribute(this.kCOLLAPSED_DONE);
|
if (!aCollapsed) aTab.removeAttribute(this.kCOLLAPSED_DONE);
|
||||||
|
|
||||||
var self = this;
|
var radian = 90 * Math.PI / 180;
|
||||||
|
var self = this;
|
||||||
aTab.__treestyletab__updateTabCollapsedTask = function(aTime, aBeginning, aFinal, aDelay) {
|
aTab.__treestyletab__updateTabCollapsedTask = function(aTime, aBeginning, aFinal, aDelay) {
|
||||||
var power = Math.min(1, aTime / aDelay);
|
if (aTime >= aDelay) {
|
||||||
var powerForStyle = Math.sin(90 * power * Math.PI / 180);
|
delete aTab.__treestyletab__updateTabCollapsedTask;
|
||||||
var margin = (power == 1) ?
|
if (aCollapsed) aTab.setAttribute(self.kCOLLAPSED_DONE, true);
|
||||||
endMargin :
|
|
||||||
startMargin + (deltaMargin * powerForStyle);
|
|
||||||
var opacity = (power == 1) ?
|
|
||||||
endOpacity :
|
|
||||||
startOpacity + (deltaOpacity * powerForStyle);
|
|
||||||
aTab.setAttribute(
|
|
||||||
'style',
|
|
||||||
aTab.getAttribute('style')
|
|
||||||
.replace(regexp, '')+';'+
|
|
||||||
collapseProp+': -'+margin+'px !important;'+
|
|
||||||
'opacity: '+opacity+' !important;'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (power == 1) {
|
|
||||||
aTab.removeAttribute(self.kCOLLAPSING);
|
aTab.removeAttribute(self.kCOLLAPSING);
|
||||||
aTab.setAttribute(
|
aTab.setAttribute(
|
||||||
'style',
|
'style',
|
||||||
@ -3122,13 +3116,19 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
.replace(regexp, '')
|
.replace(regexp, '')
|
||||||
.replace(self.kOPACITY_RULE_REGEXP, '')
|
.replace(self.kOPACITY_RULE_REGEXP, '')
|
||||||
);
|
);
|
||||||
if (aCollapsed) {
|
|
||||||
aTab.setAttribute(self.kCOLLAPSED_DONE, true);
|
|
||||||
}
|
|
||||||
delete aTab.__treestyletab__updateTabCollapsedTask;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
var power = Math.sin(aTime / aDelay * radian);
|
||||||
|
var margin = startMargin + (deltaMargin * power);
|
||||||
|
var opacity = startOpacity + (deltaOpacity * power);
|
||||||
|
aTab.setAttribute(
|
||||||
|
'style',
|
||||||
|
aTab.getAttribute('style')
|
||||||
|
.replace(regexp, '')+';'+
|
||||||
|
collapseProp+': -'+margin+'px !important;'+
|
||||||
|
'opacity: '+opacity+' !important;'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -3240,18 +3240,18 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
var deltaX = aEndX - startX;
|
var deltaX = aEndX - startX;
|
||||||
var deltaY = aEndY - startY;
|
var deltaY = aEndY - startY;
|
||||||
|
|
||||||
|
var radian = 90 * Math.PI / 180;
|
||||||
var self = this;
|
var self = this;
|
||||||
this.smoothScrollTask = function(aTime, aBeginning, aFinal, aDelay) {
|
this.smoothScrollTask = function(aTime, aBeginning, aFinal, aDelay) {
|
||||||
var scrollBoxObject = self.scrollBoxObject;
|
var scrollBoxObject = self.scrollBoxObject;
|
||||||
var power = Math.min(1, aTime / aDelay);
|
if (aTime >= aDelay) {
|
||||||
if (power == 1) {
|
|
||||||
scrollBoxObject.scrollTo(aEndX, aEndY);
|
scrollBoxObject.scrollTo(aEndX, aEndY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var powerForPositioning = Math.sin(90 * power * Math.PI / 180);
|
var power = Math.sin(aTime / aDelay * radian);
|
||||||
var newX = startX + parseInt(deltaX * powerForPositioning);
|
var newX = startX + parseInt(deltaX * power);
|
||||||
var newY = startY + parseInt(deltaY * powerForPositioning);
|
var newY = startY + parseInt(deltaY * power);
|
||||||
|
|
||||||
var x = {}, y = {};
|
var x = {}, y = {};
|
||||||
scrollBoxObject.getPosition(x, y);
|
scrollBoxObject.getPosition(x, y);
|
||||||
|
Loading…
Reference in New Issue
Block a user