Skip to content

Instantly share code, notes, and snippets.

@gerzhan
Forked from DarrylD/directive.js
Created January 12, 2016 09:13
Show Gist options
  • Save gerzhan/6f3cbde6e081f304293f to your computer and use it in GitHub Desktop.
Save gerzhan/6f3cbde6e081f304293f to your computer and use it in GitHub Desktop.
ionic slide box dynamic height - fixes the issue where the slide boxes aren't taking up the full height of the device
app.directive('dynamicHeight', function() {
return {
require: ['^ionSlideBox'],
link: function(scope, elem, attrs, slider) {
scope.$watch(function() {
return slider[0].__slider.selected();
}, function(val) {
//getting the heigh of the container that has the height of the viewport
var newHeight = window.getComputedStyle(elem.parent()[0], null).getPropertyValue("height");
if (newHeight) {
elem.find('ion-scroll')[0].style.height = newHeight;
}
});
}
};
})
<ion-slide-box>
<ion-slide class="slide" dynamic-height>
<ion-scroll>
<div class="slide-box box">
<!-- your stuff -->
</div>
</ion-scroll>
</ion-slide>
</ion-slide-box>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment