diff --git a/browser/components/customizableui/src/CustomizeMode.jsm b/browser/components/customizableui/src/CustomizeMode.jsm index 290cbeb15ee..8f6407fb5b2 100644 --- a/browser/components/customizableui/src/CustomizeMode.jsm +++ b/browser/components/customizableui/src/CustomizeMode.jsm @@ -38,6 +38,8 @@ let gModuleName = "[CustomizeMode]"; let gDisableAnimation = null; +let gDraggingInToolbars; + function CustomizeMode(aWindow) { if (gDisableAnimation === null) { gDisableAnimation = Services.prefs.getPrefType(kPrefCustomizationAnimation) == Ci.nsIPrefBranch.PREF_BOOL && @@ -1052,6 +1054,8 @@ CustomizeMode.prototype = { this._dragOffset = {x: aEvent.clientX - itemCenter.x, y: aEvent.clientY - itemCenter.y}; + gDraggingInToolbars = new Set(); + // Hack needed so that the dragimage will still show the // item as it appeared before it was hidden. this._initializeDragAfterMove = function() { @@ -1062,8 +1066,10 @@ CustomizeMode.prototype = { item.hidden = true; this._showPanelCustomizationPlaceholders(); DragPositionManager.start(this.window); - if (!isInToolbar && item.nextSibling) { - this._setDragActive(item.nextSibling, "before", draggedItem.id, false); + if (item.nextSibling) { + this._setDragActive(item.nextSibling, "before", draggedItem.id, isInToolbar); + } else if (isInToolbar && item.previousSibling) { + this._setDragActive(item.previousSibling, "after", draggedItem.id, isInToolbar); } } this._initializeDragAfterMove = null; @@ -1412,7 +1418,7 @@ CustomizeMode.prototype = { return; } - if (aItem.hasAttribute("dragover") != aValue) { + if (aItem.getAttribute("dragover") != aValue) { aItem.setAttribute("dragover", aValue); let window = aItem.ownerDocument.defaultView; @@ -1420,6 +1426,14 @@ CustomizeMode.prototype = { if (!aInToolbar) { this._setGridDragActive(aItem, draggedItem, aValue); } else { + let targetArea = this._getCustomizableParent(aItem); + let makeSpaceImmediately = false; + if (!gDraggingInToolbars.has(targetArea.id)) { + gDraggingInToolbars.add(targetArea.id); + let draggedWrapper = this.document.getElementById("wrapper-" + aDraggedItemId); + let originArea = this._getCustomizableParent(draggedWrapper); + makeSpaceImmediately = originArea == targetArea; + } // Calculate width of the item when it'd be dropped in this position let width = this._getDragItemSize(aItem, draggedItem).width; let direction = window.getComputedStyle(aItem).direction; @@ -1433,8 +1447,16 @@ CustomizeMode.prototype = { prop = "borderRightWidth"; otherProp = "border-left-width"; } + if (makeSpaceImmediately) { + aItem.setAttribute("notransition", "true"); + } aItem.style[prop] = width + 'px'; aItem.style.removeProperty(otherProp); + if (makeSpaceImmediately) { + // Force a layout flush: + aItem.getBoundingClientRect(); + aItem.removeAttribute("notransition"); + } } } }, @@ -1445,12 +1467,21 @@ CustomizeMode.prototype = { } let isToolbar = CustomizableUI.getAreaType(currentArea.id) == "toolbar"; if (isToolbar) { + if (aNoTransition) { + aItem.setAttribute("notransition", "true"); + } aItem.removeAttribute("dragover"); // Remove both property values in the case that the end padding // had been set. aItem.style.removeProperty("border-left-width"); aItem.style.removeProperty("border-right-width"); + if (aNoTransition) { + // Force a layout flush: + aItem.getBoundingClientRect(); + aItem.removeAttribute("notransition"); + } } else { + aItem.removeAttribute("dragover"); if (aNextItem) { let nextArea = this._getCustomizableParent(aNextItem); if (nextArea == currentArea) { diff --git a/browser/themes/shared/customizableui/customizeMode.inc.css b/browser/themes/shared/customizableui/customizeMode.inc.css index a5151a58aba..0cb4e2ae7c8 100644 --- a/browser/themes/shared/customizableui/customizeMode.inc.css +++ b/browser/themes/shared/customizableui/customizeMode.inc.css @@ -117,7 +117,7 @@ background-attachment: scroll, scroll, fixed, fixed, scroll; } -toolbarpaletteitem { +toolbarpaletteitem[place="toolbar"] { transition: border-width 250ms ease-in-out; } @@ -132,6 +132,7 @@ toolbarpaletteitem[place="panel"] { } toolbarpaletteitem[notransition].panel-customization-placeholder, +toolbarpaletteitem[notransition][place="toolbar"], toolbarpaletteitem[notransition][place="palette"], toolbarpaletteitem[notransition][place="panel"] { transition: none;