move newPosition check from mctSplitPane to splitter

This commit is contained in:
Deep Tailor 2017-08-29 11:50:20 -07:00
parent 0e3b629d90
commit e53b34ed60
4 changed files with 10 additions and 9 deletions

View File

@ -229,14 +229,13 @@ define(
anchor: function () {
return anchor;
},
position: function (initialValue, newValue) {
position: function (newPosition) {
if (arguments.length === 0) {
return getSetPosition();
}
if (initialValue !== newValue) {
setUserWidthPreference(newValue);
getSetPosition(newValue);
}
setUserWidthPreference(newPosition);
return getSetPosition(newPosition);
},
startResizing: function () {
toggleClass('resizing');

View File

@ -57,7 +57,10 @@ define(
// Update the position of this splitter
newPosition = initialPosition + pixelDelta;
mctSplitPane.position(initialPosition, newPosition);
if (initialPosition !== newPosition) {
mctSplitPane.position(newPosition);
}
},
// Grab the event when the user is done moving
// the splitter and pass it on

View File

@ -164,9 +164,8 @@ define(
});
it("allows positions to be set", function () {
var intitialValue = mockChildren[0].offsetWidth;
var testValue = mockChildren[0].offsetWidth + 50;
controller.position(intitialValue, testValue);
controller.position(testValue);
expect(mockFirstPane.css).toHaveBeenCalledWith(
'width',
(testValue) + 'px'

View File

@ -94,7 +94,7 @@ define(
it("repositions during drag", function () {
mockScope.splitter.move([10, 0]);
expect(mockSplitPane.position)
.toHaveBeenCalledWith(testPosition, testPosition + 10);
.toHaveBeenCalledWith(testPosition + 10);
});
it("tell's the splitter when it is done resizing", function () {