From 4db723ea816028c12c97d28bcdb7890f4e3df46b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 24 Oct 2016 14:40:35 +0200 Subject: [PATCH] ux(panel resize): snap to even 12ths spans --- public/app/features/panel/panel_directive.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/public/app/features/panel/panel_directive.ts b/public/app/features/panel/panel_directive.ts index be8e2df42e4..9b0bb908ca2 100644 --- a/public/app/features/panel/panel_directive.ts +++ b/public/app/features/panel/panel_directive.ts @@ -159,19 +159,28 @@ module.directive('panelResizer', function($rootScope) { } scope.$apply(function() { - ctrl.render(); + // ctrl.render(); }); } function dragEndHandler() { + ctrl.panel.span = Math.round(ctrl.panel.span); + if (lastPanel) { + lastPanel.span = Math.round(lastPanel.span); + } + // if close to 12 var rowSpan = ctrl.dashboard.rowSpan(ctrl.row); if (rowSpan < 12 && rowSpan > 11) { lastPanel.span += 12 - rowSpan; } - scope.$apply(function() { - $rootScope.$broadcast('render'); + // first digest to propagate panel width change + // then render + $rootScope.$apply(function() { + setTimeout(function() { + $rootScope.$broadcast('render'); + }); }); $('body').off('mousemove', moveHandler);