Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

fix(weekView): update event sizes when the window is resized

Closes #328
  • Loading branch information...
Matt Lewis
Matt Lewis committed May 11, 2016
1 parent c56a406 commit 75c7a76c833de9acd369640f6b0b2b6b4df0a248
Showing with 24 additions and 4 deletions.
  1. +17 −4 src/directives/mwlElementDimensions.js
  2. +7 −0 test/unit/directives/mwlElementDimensions.spec.js
@@ -4,11 +4,24 @@ var angular = require('angular');

angular
.module('mwl.calendar')
.controller('MwlElementDimensionsCtrl', function($element, $scope, $parse, $attrs) {
.controller('MwlElementDimensionsCtrl', function($element, $scope, $parse, $attrs, $window) {

$parse($attrs.mwlElementDimensions).assign($scope, {
width: $element[0].offsetWidth,
height: $element[0].offsetHeight
function setDimensions() {
$parse($attrs.mwlElementDimensions).assign($scope, {
width: $element[0].offsetWidth,
height: $element[0].offsetHeight
});
$scope.$applyAsync();
}

var win = angular.element($window);

win.bind('resize', setDimensions);

setDimensions();

$scope.$on('$destroy', function() {
win.unbind('resize', setDimensions);
});

})
@@ -35,4 +35,11 @@ describe('mwlElementDimensions directive', function() {
expect(scope.elementDimensions).to.eql({width: 100, height: 50});
});

it('should update the element dimensions when the window is resized', function() {
element[0].style.width = '150px';
element[0].style.height = '20px';
$window.dispatchEvent(new $window.Event('resize'));
expect(scope.elementDimensions).to.eql({width: 150, height: 20});
});

});

0 comments on commit 75c7a76

Please sign in to comment.
You can’t perform that action at this time.