diff --git a/platform/commonUI/general/src/directives/MCTSplitPane.js b/platform/commonUI/general/src/directives/MCTSplitPane.js index f52876335c..f84c67a0a3 100644 --- a/platform/commonUI/general/src/directives/MCTSplitPane.js +++ b/platform/commonUI/general/src/directives/MCTSplitPane.js @@ -117,6 +117,10 @@ define( // Apply styles to child elements function updateChildren(children) { + if (alias) { + position = userWidthPreference || position; + } + // Pick out correct elements to update, flowing from // selected anchor edge. var first = children.eq(anchor.reversed ? 2 : 0), @@ -126,7 +130,7 @@ define( splitterSize = getSize(splitter[0]); first.css(anchor.edge, "0px"); - first.css(anchor.dimension, (userWidthPreference || position) + 'px'); + first.css(anchor.dimension, position + 'px'); // Get actual size (to obey min-width etc.) firstSize = getSize(first[0]); @@ -135,8 +139,8 @@ define( splitter.css(anchor.opposite, "auto"); last.css(anchor.edge, firstSize + splitterSize + 'px'); - last.css(anchor.opposite, "0px"); - position = firstSize + splitterSize; + last.css(anchor.opposite, '0px'); + position = firstSize; } // Update positioning of contained elements @@ -173,17 +177,17 @@ define( positionParsed.assign($scope, position); } } + return position; } function setUserWidthPreference(value) { - userWidthPreference = value - splitterSize; + userWidthPreference = value; } function persistToLocalStorage(value) { if (alias) { - userWidthPreference = value - splitterSize; - $window.localStorage.setItem(alias, userWidthPreference); + $window.localStorage.setItem(alias, value); } } @@ -225,13 +229,13 @@ define( anchor: function () { return anchor; }, - position: function (value) { - if (arguments.length > 0) { - setUserWidthPreference(value); - return getSetPosition(value); - } else { + position: function (newPosition) { + if (arguments.length === 0) { return getSetPosition(); } + + setUserWidthPreference(newPosition); + return getSetPosition(newPosition); }, startResizing: function () { toggleClass('resizing'); diff --git a/platform/commonUI/general/src/directives/MCTSplitter.js b/platform/commonUI/general/src/directives/MCTSplitter.js index 69db2f0a02..f0e4c69840 100644 --- a/platform/commonUI/general/src/directives/MCTSplitter.js +++ b/platform/commonUI/general/src/directives/MCTSplitter.js @@ -57,7 +57,10 @@ define( // Update the position of this splitter newPosition = initialPosition + pixelDelta; - mctSplitPane.position(newPosition); + + if (initialPosition !== newPosition) { + mctSplitPane.position(newPosition); + } }, // Grab the event when the user is done moving // the splitter and pass it on diff --git a/platform/commonUI/general/test/directives/MCTSplitPaneSpec.js b/platform/commonUI/general/test/directives/MCTSplitPaneSpec.js index abd0935021..51ebc48244 100644 --- a/platform/commonUI/general/test/directives/MCTSplitPaneSpec.js +++ b/platform/commonUI/general/test/directives/MCTSplitPaneSpec.js @@ -140,7 +140,7 @@ define( it("exposes its splitter's initial position", function () { expect(controller.position()).toEqual( - mockFirstPane[0].offsetWidth + mockSplitter[0].offsetWidth + mockFirstPane[0].offsetWidth ); }); @@ -168,7 +168,7 @@ define( controller.position(testValue); expect(mockFirstPane.css).toHaveBeenCalledWith( 'width', - (testValue - mockSplitter[0].offsetWidth) + 'px' + (testValue) + 'px' ); }); @@ -200,11 +200,11 @@ define( mockFirstPane[0].offsetWidth += 100; // Should not reflect the change yet expect(controller.position()).not.toEqual( - mockFirstPane[0].offsetWidth + mockSplitter[0].offsetWidth + mockFirstPane[0].offsetWidth ); mockInterval.mostRecentCall.args[0](); expect(controller.position()).toEqual( - mockFirstPane[0].offsetWidth + mockSplitter[0].offsetWidth + mockFirstPane[0].offsetWidth ); }); @@ -216,7 +216,7 @@ define( it("saves user preference to localStorage when user is done resizing", function () { controller.endResizing(100); - expect(Number(mockWindow.localStorage.getItem('mctSplitPane-rightSide'))).toEqual(100 - mockSplitter[0].offsetWidth); + expect(Number(mockWindow.localStorage.getItem('mctSplitPane-rightSide'))).toEqual(100); }); });