Skip to content
This repository has been archived by the owner on Jun 19, 2018. It is now read-only.

Commit

Permalink
fix(DragAndResize): Prevent UI flicker when dragging and resizing eve…
Browse files Browse the repository at this point in the history
…nts. Closes #209
  • Loading branch information
Matt Lewis committed Nov 23, 2015
1 parent aa7bcba commit 38c2d29
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
12 changes: 7 additions & 5 deletions src/directives/mwlDraggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var angular = require('angular');

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

if (!interact) {
return;
Expand Down Expand Up @@ -108,10 +108,12 @@ angular
$scope.$apply();
}

translateElement(elm, '')
.removeAttr('data-x')
.removeAttr('data-y')
.removeClass('dragging-active');
$timeout(function() {
translateElement(elm, '')
.removeAttr('data-x')
.removeAttr('data-y')
.removeClass('dragging-active');
});
}

}
Expand Down
20 changes: 11 additions & 9 deletions src/directives/mwlResizable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var angular = require('angular');

angular
.module('mwl.calendar')
.controller('MwlResizableCtrl', function($element, $scope, $parse, $attrs, interact) {
.controller('MwlResizableCtrl', function($element, $scope, $parse, $attrs, $timeout, interact) {

if (!interact) {
return;
Expand Down Expand Up @@ -102,14 +102,16 @@ angular
var elm = angular.element(event.target);
var unitsResized = getUnitsResized(resizeEdge, elm, snapGridDimensions);

elm
.data('x', null)
.data('y', null)
.css({
transform: '',
width: originalDimensionsStyle.width,
height: originalDimensionsStyle.height
});
$timeout(function() {
elm
.data('x', null)
.data('y', null)
.css({
transform: '',
width: originalDimensionsStyle.width,
height: originalDimensionsStyle.height
});
});

if ($attrs.onResizeEnd) {
$parse($attrs.onResizeEnd)($scope, unitsResized);
Expand Down

0 comments on commit 38c2d29

Please sign in to comment.