0

So I have two sets of 4 buttons. Only 1 set of buttons is made visible by ng-show expression at a time. I am having difficulty working with angular animation css to create a slide in on ng-show-add and a slide out on ng-show-remove. Heres my code:

<script>
    angular.module('myApp', ['ngAnimate']).
    controller('theController', ['$scope', function($scope) {
        $scope.imageAnalysis = false;

        $scope.toggleImageBtns = function() {
            $scope.imageAnalysis = !$scope.imageAnalysis;
        };
    }]);
<script>
<body>
    <div class="container" ng-controller="theController">
        <div class="row feature-btns" ng-show="imageAnalysis === false">
            <div class="col-xs-3">
                <div class="btn btn-default"> feature btn 1 </div>
            </div>
            <div class="col-xs-3">
                <div class="btn btn-default"> feature btn 2 </div>
            </div>
            <div class="col-xs-3">
                <div class="btn btn-default"> feature btn 3 </div>
            </div>
            <div class="col-xs-3">
                <div class="btn btn-default" ng-click="toggleImageBtns()"> click me to see image buttons </div>
            </div>
        </div>
        <!-- /.row -->
        <div class="row image-btns" ng-show="imageAnalysis === true">
            <div class="col-xs-3">
                <div class="btn btn-default"> image btn 1 </div>
            </div>
            <div class="col-xs-3">
                <div class="btn btn-default"> image btn 2 </div>
            </div>
            <div class="col-xs-3">
                <div class="btn btn-default"> image btn 3 </div>
            </div>
            <div class="col-xs-3">
                <div class="btn btn-default" ng-click="toggleImageBtns()"> go back to feature buttons </div>
            </div>
        </div>
    </div>    
</body
Daniel Kobe
  • 9,376
  • 15
  • 62
  • 109

1 Answers1

0

Here is a snippet of CSS that will slide in your buttons from the right. It should give you an idea of the classes you need to use and can manipulate.

.feature-btns {
    position: absolute;
    top: 50px;
    left: 0;
    transition: 250ms ease-in-out all;
}
/* fade out content as it is hidden */
.feature-btns.ng-hide-add {
    opacity: 1.0;
}

.feature-btns.ng-hide-add-active {
    opacity: 0;
}
/* slide in from right*/
.feature-btns.ng-hide-remove {
    left: 100%;
    //left: 1100px;
    position: absolute;
    top: 50px;
}

.feature-btns.ng-hide-remove-active {
    left: 0;
}


.image-btns {
    position: absolute;
    top: 50px;
    left: 0;
    transition: 250ms ease-in-out all;
}
/* fade out content as it is hidden */
.image-btns.ng-hide-add {
    opacity: 1.0;
}

.image-btns.ng-hide-add-active {
    opacity: 0;
}
/* slide in from right*/
.image-btns.ng-hide-remove {
    left: 100%;
    //left: 1100px;
    position: absolute;
    top: 50px;
}

.image-btns.ng-hide-remove-active {
    left: 0;
}
tsiorn
  • 2,236
  • 1
  • 22
  • 26
  • Works great, barely had to edit the code. One question, whats the difference between ng-hide-remove and ng-hide-remove-active class? – Daniel Kobe Jun 30 '15 at 18:53
  • When ngShow is changed, the ngAnimate module will append ng-hide-remove class to trigger the hide animation (start of the animation). Next ngAnimate will add ng-hide-remove-active class (which we have set to contain the final state of the transition) which will last until the animation finishes. – tsiorn Jun 30 '15 at 19:10