Different transitions with AngularJS

前端 未结 1 1391
名媛妹妹
名媛妹妹 2021-01-22 16:20

How can I enable different transitions with AngularJS. Lets Say, I have a sidebar in my web application. I the user clicks a button X, the sidebar should disappear very fast, if

1条回答
  •  执念已碎
    2021-01-22 16:54

    I would do something like this. Set a default transition for the sidebar, and then apply a class with a different transition speed.

    Here is a jsFiddle of what I mean:

    http://jsfiddle.net/rd13/eTTZj/149/

    HTML:

    Angular:

    function myCtrl($scope) {
        $scope.click = function() {
            $scope.boolChangeClass = !$scope.boolChangeClass;
            $scope.$apply();
        }
    }
    

    CSS:

    .sidebar {
        -moz-transition: left .1s;
        -webkit-transition: left .1s;
        -o-transition: left .1s;
        transition: left .1s;
        width: 100px;
        background-color: blue;
        position: absolute;
        top: 0px;
        bottom: 0px;
        left: -100px;
    }
    
    .slide-out {
        -moz-transition: left 1s;
        -webkit-transition: left 1s;
        -o-transition: left 1s;
        transition: left 1s;
        left: 0px;
    
    }
    

    0 讨论(0)
提交回复
热议问题