Merge pull request #323 from Terny22/bug/289

Fix bug - Issue #289
This commit is contained in:
Igor Kulikov 2017-10-03 10:02:32 +03:00 committed by GitHub
commit e6787c0b4d

View File

@ -234,14 +234,16 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $
removeResizeListener(gridsterParent[0], onGirdsterParentResize); // eslint-disable-line no-undef removeResizeListener(gridsterParent[0], onGirdsterParentResize); // eslint-disable-line no-undef
}); });
watchWidgets();
function onGirdsterParentResize() { function onGirdsterParentResize() {
if (gridsterParent.height() && autofillHeight()) { if (gridsterParent.height() && autofillHeight()) {
updateMobileOpts(); updateMobileOpts();
} }
} }
$scope.$watchCollection('vm.widgets', function () { function watchWidgets() {
sortWidgets(); $scope.widgetsCollectionWatch = $scope.$watchCollection('vm.widgets', function () {
var ids = []; var ids = [];
for (var i=0;i<vm.widgets.length;i++) { for (var i=0;i<vm.widgets.length;i++) {
var widget = vm.widgets[i]; var widget = vm.widgets[i];
@ -278,10 +280,22 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $
delete vm.widgetLayoutInfo[widgetId]; delete vm.widgetLayoutInfo[widgetId];
} }
} }
$mdUtil.nextTick(function () {
sortWidgets();
if (autofillHeight()) { if (autofillHeight()) {
updateMobileOpts(); updateMobileOpts();
} }
}); });
});
}
function stopWatchWidgets() {
if ($scope.widgetsCollectionWatch) {
$scope.widgetsCollectionWatch();
$scope.widgetsCollectionWatch = null;
}
}
//TODO: widgets visibility //TODO: widgets visibility
/*gridsterParent.scroll(function () { /*gridsterParent.scroll(function () {
@ -500,6 +514,7 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $
loadDashboard(); loadDashboard();
function sortWidgets() { function sortWidgets() {
stopWatchWidgets();
vm.widgets.sort(function (widget1, widget2) { vm.widgets.sort(function (widget1, widget2) {
var row1 = widgetOrder(widget1); var row1 = widgetOrder(widget1);
var row2 = widgetOrder(widget2); var row2 = widgetOrder(widget2);
@ -509,6 +524,7 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $
} }
return res; return res;
}); });
watchWidgets();
} }
function reload() { function reload() {