diff --git a/README.md b/README.md index fda9227..e3fe3f8 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,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 69926e8..9ae3699 100644 --- a/dist/auto-height.js +++ b/dist/auto-height.js @@ -1 +1 @@ -(function(){angular.module("m43nu.auto-height",[]).directive("autoHeight",["$window","$timeout",function(n,e){return{link:function(t,r,i){var u,a;return u=function(n){var e,t,r,i;for(e=0,t=0,r=n.length;r>t;t++)i=n[t],e+=i.offsetHeight;return e},a=function(n){var e,t,r,i,u;for(i=n.parent().children(),u=[],t=0,r=i.length;r>t;t++)e=i[t],e!==n[0]&&u.push(e);return u},angular.element(n).bind("resize",function(){var e,t;return e=i.additionalHeight||0,t=n.innerHeight-r.parent()[0].getBoundingClientRect().top,r.css("height",t-u(a(r))-e+"px")}),e(function(){return angular.element(n).triggerHandler("resize")},1e3)}}}])}).call(this); \ No newline at end of file +(function(){angular.module("m43nu.auto-height",[]).directive("autoHeight",["$window","$timeout",function(n,e){return{link:function(t,i,r){var u,a;return u=function(n){var e,t,i,r;for(e=0,t=0,i=n.length;i>t;t++)r=n[t],e+=r.offsetHeight;return e},a=function(n){var e,t,i,r,u;for(r=n.parent().children(),u=[],t=0,i=r.length;i>t;t++)e=r[t],e!==n[0]&&u.push(e);return u},angular.element(n).bind("resize",function(){var e,t,o;return e=r.additionalHeight||0,t=n.innerHeight-i.parent()[0].getBoundingClientRect().top,o="min-height"===r.autoHeight?"min-height":"height",i.css(o,t-u(a(i))-e+"px")}),e(function(){return angular.element(n).triggerHandler("resize")},1e3)}}}])}).call(this); \ No newline at end of file diff --git a/src/auto-height.coffee b/src/auto-height.coffee index 48d5c92..6b77145 100644 --- a/src/auto-height.coffee +++ b/src/auto-height.coffee @@ -17,9 +17,10 @@ angular.module('m43nu.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) + "px") + property = if $attrs.autoHeight == 'min-height' then 'min-height' else 'height' + $element.css(property, (parentHeight - combineHeights(siblings($element)) - additionalHeight) + "px") $timeout -> angular.element($window).triggerHandler('resize') , 1000 - ] \ No newline at end of file + ]