From d3135777f8c7f7288254db7a2bbf527aaa061664 Mon Sep 17 00:00:00 2001 From: Morgan Doocy Date: Sun, 8 Mar 2015 13:43:53 -0700 Subject: [PATCH 1/2] If attribute value is 'min-height', set that CSS property instead. --- README.md | 10 ++++++++++ dist/auto-height.js | 5 +++-- src/auto-height.coffee | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 271c9a7..4da82f6 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,16 @@ Use it in your html: ``` +To use the CSS `min-height` property instead of `height` (in order to allow +the container to expand further vertically), include a value of `min-height`: + +``` +
+ This container will be at least as tall as the remaining on-screen space, + but will grow to fit any contents taller than that. + +``` + ## Community ### Got a question? diff --git a/dist/auto-height.js b/dist/auto-height.js index 95b0ea7..6f92f4a 100644 --- a/dist/auto-height.js +++ b/dist/auto-height.js @@ -27,10 +27,11 @@ return _results; }; angular.element($window).bind('resize', function() { - var additionalHeight, parentHeight; + var additionalHeight, parentHeight, property; additionalHeight = $attrs.additionalHeight || 0; parentHeight = $window.innerHeight - $element.parent()[0].getBoundingClientRect().top; - return $element.css('height', parentHeight - combineHeights(siblings($element)) - additionalHeight); + property = $attrs.autoHeight === 'min-height' ? 'min-height' : 'height' + return $element.css(property, parentHeight - combineHeights(siblings($element)) - additionalHeight); }); return $timeout(function() { return angular.element($window).triggerHandler('resize'); diff --git a/src/auto-height.coffee b/src/auto-height.coffee index 39ccded..1fd4dcc 100644 --- a/src/auto-height.coffee +++ b/src/auto-height.coffee @@ -12,7 +12,8 @@ angular.module('twygmbh.auto-height', []). angular.element($window).bind 'resize', -> additionalHeight = $attrs.additionalHeight || 0 parentHeight = $window.innerHeight - $element.parent()[0].getBoundingClientRect().top - $element.css('height', (parentHeight - combineHeights(siblings($element)) - additionalHeight)) + property = $attrs.autoHeight === 'min-height' ? 'min-height' : 'height' + $element.css(property, (parentHeight - combineHeights(siblings($element)) - additionalHeight)) $timeout -> angular.element($window).triggerHandler('resize') From c91e4e4e23d66feb143ad24b0d5f6560c6c226bd Mon Sep 17 00:00:00 2001 From: Morgan Doocy Date: Tue, 31 Mar 2015 14:12:48 -0700 Subject: [PATCH 2/2] Fix CoffeeScript ternary syntax. --- src/auto-height.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/auto-height.coffee b/src/auto-height.coffee index 1fd4dcc..7523c7e 100644 --- a/src/auto-height.coffee +++ b/src/auto-height.coffee @@ -12,10 +12,10 @@ angular.module('twygmbh.auto-height', []). angular.element($window).bind 'resize', -> additionalHeight = $attrs.additionalHeight || 0 parentHeight = $window.innerHeight - $element.parent()[0].getBoundingClientRect().top - property = $attrs.autoHeight === 'min-height' ? 'min-height' : 'height' + property = if $attrs.autoHeight == 'min-height' then 'min-height' else 'height' $element.css(property, (parentHeight - combineHeights(siblings($element)) - additionalHeight)) $timeout -> angular.element($window).triggerHandler('resize') , 1000 - ] \ No newline at end of file + ]