-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with min-width #140
Comments
Hmm bug in my own code detected, need to fix that on monday. Resizing the browser casuing issues. Maybe we need to watch |
@Exotelis let me know if it turns out to be a bug in your code. I'd be happy to help out otherwise. |
Ok, thats my new mouseup function 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
if(typeof widget.containerStyle.minWidth !== 'undefined') {
var dashboardSize = widgetElm.parent().parent().width();
var minWidth = parseFloat(widget.containerStyle.minWidth);
var units = widget.containerStyle.minWidth.replace(/^[-\.\d]+/, '') || '%';
var minWidthPx;
var minWidthPercent;
switch(units) {
case '%':
minWidthPx = minWidth / 100 * dashboardSize;
minWidthPercent = minWidth;
break;
case 'px':
minWidthPx = minWidth;
minWidthPercent = minWidth / dashboardSize * 100;
break;
}
if((pixelWidth + pixelChange) < minWidthPx) {
if(widthUnits === '%') {
newWidth = minWidthPercent;
} else {
newWidth = minWidthPx;
}
}
}
// new
widget.setWidth(newWidth, widthUnits);
$scope.$emit('widgetChanged', widget);
$scope.$apply();
$scope.$broadcast('widgetResized', {
width: newWidth
});
}; With one Exception, 'width' cannot be less than 'min-width'. The Exception is to resize your browser. Adding the following watcher will fix this issue. if(typeof $scope.widget.containerStyle.minWidth !== 'undefined') {
$scope.$watch(function () {
return {
'w': window.innerWidth
};
}, function () {
var widget = $scope.widget;
var widgetElm = $element.find('.widget');
var units = widget.containerStyle.minWidth.replace(/^[-\.\d]+/, '') || '%';
if (units !== '%') {
var dashboardSize = widgetElm.parent().parent().width();
var minWidthPx = parseFloat(widget.containerStyle.minWidth);
var widthUnits = widget.widthUnits;
var minWidthPercent = parseFloat(widget.containerStyle.minWidth) / dashboardSize * 100;
if (widgetElm.width() < minWidthPx) {
if (widthUnits === '%') {
var newWidth = minWidthPercent;
} else {
var newWidth = minWidthPx;
}
widget.setWidth(newWidth, widthUnits);
}
}
}, true);
} Is there a better way to keep my dashboard responsive? |
@Exotelis Just confirmed the issue with resizing:
Will update the code to resolve both issue. I'm sorry for the late response. |
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:
Is there a better way to fix this?
Maybe a minsize option would be great.
The text was updated successfully, but these errors were encountered: