From 9fa09e25f05058484b9408593d7451911c38d856 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 25 Feb 2015 16:28:53 -0800 Subject: [PATCH] [Common UI] Tweak mct-scroll-* directives Make fixes/tweaks to behavior of mct-scroll-x and mct-scroll-y directives after testing them against timeline markup. WTD-920. --- platform/commonUI/general/bundle.json | 4 ++-- platform/commonUI/general/src/directives/MCTScroll.js | 3 ++- platform/commonUI/general/test/directives/MCTScrollSpec.js | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/platform/commonUI/general/bundle.json b/platform/commonUI/general/bundle.json index 5bf767d2d1..bd94eaabdf 100644 --- a/platform/commonUI/general/bundle.json +++ b/platform/commonUI/general/bundle.json @@ -108,12 +108,12 @@ }, { "key": "mctScrollX", - "implementations": "directives/MCTScroll.js", + "implementation": "directives/MCTScroll.js", "depends": [ "$parse", "MCT_SCROLL_X_PROPERTY", "MCT_SCROLL_X_ATTRIBUTE" ] }, { "key": "mctScrollY", - "implementations": "directives/MCTScroll.js", + "implementation": "directives/MCTScroll.js", "depends": [ "$parse", "MCT_SCROLL_Y_PROPERTY", "MCT_SCROLL_Y_ATTRIBUTE" ] } ], diff --git a/platform/commonUI/general/src/directives/MCTScroll.js b/platform/commonUI/general/src/directives/MCTScroll.js index f5b7a5b159..6436bd3dcc 100644 --- a/platform/commonUI/general/src/directives/MCTScroll.js +++ b/platform/commonUI/general/src/directives/MCTScroll.js @@ -34,7 +34,8 @@ define( // Handle event; assign to scroll state to scope function updateScope() { - parsed.assign(element[0][property]); + parsed.assign(scope, element[0][property]); + scope.$apply(expr); } // Initialize state in scope diff --git a/platform/commonUI/general/test/directives/MCTScrollSpec.js b/platform/commonUI/general/test/directives/MCTScrollSpec.js index 8b14606d53..200c418798 100644 --- a/platform/commonUI/general/test/directives/MCTScrollSpec.js +++ b/platform/commonUI/general/test/directives/MCTScrollSpec.js @@ -26,7 +26,7 @@ define( mockParsed = jasmine.createSpy('parsed'); mockParsed.assign = jasmine.createSpy('assign'); - mockScope = jasmine.createSpyObj('$scope', ['$watch']); + mockScope = jasmine.createSpyObj('$scope', ['$watch', '$apply']); mockElement = [{ testProperty: 42 }]; mockElement.on = jasmine.createSpy('on'); @@ -71,7 +71,7 @@ define( it("publishes initial scroll state", function () { expect(mockParse).toHaveBeenCalledWith(EXPRESSION); - expect(mockParsed.assign).toHaveBeenCalledWith(42); + expect(mockParsed.assign).toHaveBeenCalledWith(mockScope, 42); }); it("updates scroll state when scope changes", function () { @@ -82,7 +82,8 @@ define( it("updates scope when scroll state changes", function () { mockElement[0].testProperty = 12321; mockElement.on.mostRecentCall.args[1]({ target: mockElement[0] }); - expect(mockParsed.assign).toHaveBeenCalledWith(12321); + expect(mockParsed.assign).toHaveBeenCalledWith(mockScope, 12321); + expect(mockScope.$apply).toHaveBeenCalledWith(EXPRESSION); }); });