Skip to content

Commit

Permalink
Fix wrong dragging animations of pinned tabs in the vertical tab bar
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Nov 28, 2012
1 parent 310651d commit 18d4fec
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
34 changes: 19 additions & 15 deletions content/treestyletab/res/tabsDragUtils.js
Expand Up @@ -15,7 +15,7 @@
http://github.com/piroor/fxaddonlibs/blob/master/tabsDragUtils.js
*/
(function() {
const currentRevision = 22;
const currentRevision = 23;

if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};

Expand Down Expand Up @@ -173,7 +173,7 @@
).replace(
/(let tabWidth = [^;]+;)/,
'$1\n' +
'let tabCenterOffset = aCanDropOnSelf ? (tabWidth / 2) : 0 ;'
'let tabCenterOffset = aOptions.canDropOnSelf ? (tabWidth / 3) : 0 ;'
).replace(
'let tabCenter = ',
'draggedTabs.slice(1).forEach(function(tab) {\n' +
Expand Down Expand Up @@ -206,17 +206,19 @@
'/* $& */ tabsWidth : -tabsWidth'
).replace( // add a new argument
')',
', aCanDropOnSelf)'
', aOptions)'
).replace( // insert initialization processes
'{',
'{\n' +
' var isVertical = window["piro.sakura.ne.jp"].tabsDragUtils.isVertical(this);\n' +
' if (typeof aOptions == "boolean") aOptions = { canDropOnSelf: aOptions };\n' +
' aOptions = aOptions || {};\n' +
' var isVertical = "isVertical" in aOptions ? aOptions.isVertical : window["piro.sakura.ne.jp"].tabsDragUtils.isVertical(this) ;\n' +
' var position = isVertical ? "screenY" : "screenX" ;\n' +
' var size = isVertical ? "height" : "width" ;\n' +
' var scroll = isVertical ? "scrollY" : "scrollX" ;\n' +
' var translator = isVertical ? "translateY" : "translateX" ;\n' +
' aCanDropOnSelf = aCanDropOnSelf || ("TreeStyleTabService" in window);\n' +
' var units = aCanDropOnSelf ? 3 : 2 ;'
' aOptions.canDropOnSelf = aOptions.canDropOnSelf || ("TreeStyleTabService" in window);\n' +
' var units = aOptions.canDropOnSelf ? 3 : 2 ;'
)
);
aObserver.__TabsDragUtils_updated__animateTabMove = aObserver._animateTabMove;
Expand All @@ -228,13 +230,15 @@
* date : 2012-10-09
* source : http://mxr.mozilla.org/mozilla-central/source/browser/base/content/tabbrowser.xml
*/
// function _animateTabMove(event, aCanDropOnSelf) {
// var isVertical = window['piro.sakura.ne.jp'].tabsDragUtils.isVertical(this);
// var position = isVertical ? 'screenY' : 'screenX' ;
// var size = isVertical ? 'height' : 'width' ;
// function _animateTabMove(event, aOptions) {
// if (typeof aOptions == "boolean") aOptions = { canDropOnSelf: aOptions };
// aOptions = aOptions || {};
// var isVertical = "isVertical" in aOptions ? aOptions.isVertical : window["piro.sakura.ne.jp"].tabsDragUtils.isVertical(this) ;
// var position = isVertical ? "screenY" : "screenX" ;
// var size = isVertical ? "height" : "width" ;
// var translator = isVertical ? "translateY" : "translateX" ;
// aCanDropOnSelf = aCanDropOnSelf || ("TreeStyleTabService" in window);
// var units = aCanDropOnSelf ? 3 : 2 ;
// aOptions.canDropOnSelf = aOptions.canDropOnSelf || ("TreeStyleTabService" in window);
// var units = aOptions.canDropOnSelf ? 3 : 2 ;
//
// let draggedTab = event.dataTransfer.mozGetDataAt(TAB_DROP_TYPE, 0);
// var draggedTabs = window['piro.sakura.ne.jp'].tabsDragUtils.getDraggedTabs(event);
Expand Down Expand Up @@ -273,7 +277,7 @@
// tabs.reverse();
//
// let tabWidth = draggedTab.getBoundingClientRect()[size]/*.width*/;
// let tabCenterOffset = aCanDropOnSelf ? (tabWidth / 2) : 0 ;
// let tabCenterOffset = aOptions.canDropOnSelf ? (tabWidth / 3) : 0 ;
//
// // Move the dragged tab based on the mouse position.
//
Expand Down Expand Up @@ -541,7 +545,7 @@
return tabbar && '_animateTabMove' in tabbar;
},

processTabsDragging: function TDU_processTabsDragging(aEvent, aCanDropOnSelf)
processTabsDragging: function TDU_processTabsDragging(aEvent, aOptions)
{
// Firefox 17 and later
if (this.canAnimateDraggedTabs(aEvent)) {
Expand All @@ -551,7 +555,7 @@

if (!tabbar.hasAttribute('movingtab'))
tabbar.setAttribute('movingtab', 'true');
tabbar._animateTabMove(aEvent, aCanDropOnSelf);
tabbar._animateTabMove(aEvent, aOptions);
return true;
}
return false;
Expand Down
8 changes: 7 additions & 1 deletion modules/tabbarDNDObserver.js
Expand Up @@ -888,7 +888,13 @@ try{
let draggedTab = aEvent.dataTransfer && aEvent.dataTransfer.mozGetDataAt(TAB_DROP_TYPE, 0);
let dragOverTab = sv.getTabFromEvent(aEvent) || sv.getTabFromTabbarEvent(aEvent) || aEvent.target;
b.ownerDocument.defaultView['piro.sakura.ne.jp'].tabsDragUtils
.processTabsDragging(aEvent, !dragOverTab || !dragOverTab.pinned);
.processTabsDragging(aEvent, {
canDropOnSelf : !dragOverTab || !dragOverTab.pinned,
isVertical : (
b.ownerDocument.defaultView['piro.sakura.ne.jp'].tabsDragUtils.isVertical(b.tabContainer) &&
!draggedTab.pinned
)
});

/**
* We must calculate drop action after tabsDragUtils.processTabsDragging(),
Expand Down

0 comments on commit 18d4fec

Please sign in to comment.