I have the following structure in my Angular app:
<header></header>
<section>
<div ui-view></div>
</section>
<footer>
Where my ui-view
uses animate.css to bounce in and out of the screen. My problem is that during animation I get two instances of <div ui-view>
on top of each other, pushing the first instance down. All of the examples I can find get around this by using position: absolute
but since I don't know the height of the ui-view
in advance and have a <footer>
below my <div ui-view>
which I need to display, I can't use this.
This is the way I want the animation to work, except the <footer>
needs to appear below the content:
http://jsfiddle.net/9rjrdd1q/
How can I achieve this without position: absolute
? Or at the very least, get my <footer>
to display...
For anyone interested, I just made a workaround using a directive which resizes the parent container to the height of the ui-view
every time the state changes:
myApp.directive("fixPositionAbsolute", ["$document", "$window", function($document, $window) {
return {
restrict: "A",
link: function($scope, element) {
// Flag to determine if the directive has loaded before
var hasLoaded;
// DOM representation of the Angular element
var domElement = element[0];
$scope.$on("$stateChangeSuccess", function() {
console.log(domElement);
// Get the computed height of the ui-view and assign it to the directive element
domElement.style.height = $window.getComputedStyle($document[0].querySelector("[ui-view]")).height;
// After the first height change, add a class to enable animations from now on
if(!hasLoaded) {
domElement.classList.add("auto-height");
hasLoaded = true;
}
});
}
};
}]);
Then added an animation for the content-wrapper
's height so that it moves along with the bounce animation:
#content-wrapper.auto-height {
height: 0;
transition: height 0.6s ease-in-out;
}
Updated Fiddle
Perhaps you could remove position:absolute
and apply this css rule:
[ui-view].ng-leave {
display:none;
-webkit-animation: bounceOutLeft 1s;
}
But the leaving div will get hidden immediately:
Check the DEMO