How to make it so that when we press a button a second time, the block will smoothly go back? jquery can not be used, the project is done on an angular.
var app = angular.module('myApp', []); app.controller('personCtrl', function($scope) { $scope.myVar = false; $scope.toggle = function() { $scope.myVar = !$scope.myVar; }; }); /* Styles go here */ .fixed { position: fixed; background: blue; color: white; width: 50%; padding: 40px 0; animation: my 200ms both linear; } @keyframes my { from { width: 0; } to { width: 50%; } } <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="style.css"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <script src="script.js"></script> </head> <body> <div ng-app="myApp" ng-controller="personCtrl"> <button ng-click="toggle()">Show block</button> <p class="fixed" ng-show="myVar"> this is filter </p> </div> <div> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Asperiores, omnis earum accusamus dicta. Ipsa, consectetur, beatae illo impedit veniam esse ea fugiat corrupti consequuntur quasi minima nobis quidem dolorem ad. </div> </body> </html>