Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ Use it in your html:
</div>
```

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`:

```
<div class="article" auto-height="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.
</article>
```

## Community

### Got a question?
Expand Down
2 changes: 1 addition & 1 deletion dist/auto-height.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/auto-height.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
]