-
Notifications
You must be signed in to change notification settings - Fork 296
Open
Description
I need to assign a min-width value to my widgets, but this is causing some troubles.
I'am using the style option:
size: {
width: '50%'
}
style: {
minWidth: '270px'
}
It seems to be working, but if you are going to resize your widget to a smaller size, the width attribute will decrease over and over again. Use the inspector to see this phenomenon.
I've fixed this issue by overwriting the DashboardWidgetCtrl and editing the grabResize function. Here is my code:
var mouseup = function(e) {
// remove listener and marquee
jQuery($window).off('mousemove', mousemove);
$marquee.remove();
// calculate change in units
var curX = e.clientX;
var pixelChange = curX - initX;
var unitChange = Math.round(pixelChange * transformMultiplier * 100) / 100;
// add to initial unit width
var newWidth = unitWidth * 1 + unitChange;
// new part starts
if(typeof widget.containerStyle.minWidth !== 'undefined') {
if ((pixelWidth + pixelChange) < parseFloat(widget.containerStyle.minWidth)) {
newWidth = parseFloat(widget.containerStyle.minWidth);
widthUnits = widget.containerStyle.minWidth.replace(/^[-\.\d]+/, '') || '%';
}
}
if(widthUnits === 'px') {
var dashboardSize = widgetElm.parent().parent().width();
newWidth = Math.min(dashboardSize, newWidth);
}
// new part ends
widget.setWidth(newWidth, widthUnits);
$scope.$emit('widgetChanged', widget);
$scope.$apply();
$scope.$broadcast('widgetResized', {
width: newWidth
});
};Is there a better way to fix this?
Maybe a minsize option would be great.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
