Skip to content
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

Add minimum width/height options #41

Open
guikubivan opened this issue Jan 6, 2016 · 2 comments
Open

Add minimum width/height options #41

guikubivan opened this issue Jan 6, 2016 · 2 comments

Comments

@guikubivan
Copy link

I tried to implement this with the following. I'm not familiar with flexbox so I ignored that, but something along these lines would be great.

            scope: {
                rDirections: "=",
                rCenteredX: "=",
                rCenteredY: "=",
                rWidth: "=",
                rHeight: "=",
                rFlex: "=",
                rGrabber: "@",
                rMinWidth: "=",
                rMinHeight: "="
            }
....

switch(dragDir) {
                        case 'top':
                            var newHeight = h + (offset * vy);
                            if(scope.rFlex) { element[0].style.flexBasis = newHeight + 'px'; }
                            else {            if(!scope.rMinHeight || ( newHeight > scope.rMinHeight)) { element[0].style.height = newHeight + 'px'; } }
                            break;
                        case 'right':
                            var newWidth = w - (offset * vx);
                            if(scope.rFlex) { element[0].style.flexBasis = newWidth + 'px'; }
                            else {            if(!scope.rMinWidth || ( newWidth > scope.rMinWidth)) { element[0].style.width = newWidth + 'px'; } }
                            break;
                        case 'bottom':
                            var newHeight = h - (offset * vy);
                            if(scope.rFlex) { element[0].style.flexBasis = h - (offset * vy) + 'px'; }
                            else {            if(!scope.rMinHeight || ( newHeight > scope.rMinHeight)) { element[0].style.height = h - (offset * vy) + 'px'; } }
                            break;
                        case 'left':
                            var newWidth = w + (offset * vx);
                            if(scope.rFlex) { element[0].style.flexBasis = newWidth + 'px'; }
                            else {            if(!scope.rMinWidth || ( newWidth > scope.rMinWidth)) { element[0].style.width = newWidth + 'px';} }
                            break;
                    }
@designnotdrum
Copy link

Why add this to the directive when you can specify both min and max widths/heights in CSS for whatever you're trying to resize?

@mrzepinski
Copy link

mrzepinski commented Nov 7, 2016

@designnotdrum When you have nested elements that inherit height from the parent it's important to have strict values.

My PR is here: #66

@guikubivan Thanks for your issue ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants