Skip to content

Commit

Permalink
Try fixing widget overlapping bug
Browse files Browse the repository at this point in the history
  • Loading branch information
CarterLi committed Jun 21, 2018
1 parent ba72c66 commit bee362d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 1 addition & 3 deletions demo/dashboard/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h1 style="display: inline-block; width: 200px;">Dashboard</h1>
<select class="form-control" style="width: 150px; margin-bottom: 20px; display:inline-block;" ng-change="changeDashboard()" ng-model="selectedDashboardId" ng-options="d.id as d.name for d in dashboards | object2Array | orderBy:'id'">
</select>
</div>
<div gridster="gridsterOptions" ng-show="visible">
<div gridster="gridsterOptions" ng-show="dashboard.widgets.length">
<ul>
<li gridster-item="widget" ng-repeat="widget in dashboard.widgets">
<div class="box" ng-controller="CustomWidgetCtrl">
Expand All @@ -22,5 +22,3 @@ <h3>{{ widget.name }}</h3>
</li>
</ul>
</div>
<hr>
<button ng-click="visible=!visible">toggle</button>
5 changes: 4 additions & 1 deletion src/angular-gridster.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@
var resize = function() {
var width = $elem[0].offsetWidth || parseInt($elem.css('width'), 10);

if (!width || width === prevWidth || gridster.movingItem) {
if (width === prevWidth || gridster.movingItem) {
return;
}
prevWidth = width;
Expand All @@ -831,6 +831,7 @@
}

$rootScope.$broadcast('gridster-resized', [width, $elem[0].offsetHeight], gridster);
scope.$apply();
};

// track element width changes any way we can
Expand All @@ -845,6 +846,8 @@

// allow a little time to place items before floating up
$timeout(function() {
resize();

scope.$watch('gridster.floating', function() {
gridster.floatItemsUp();
});
Expand Down

0 comments on commit bee362d

Please sign in to comment.