Designing a dynamic 1-3 column arrangement with Angular for animated content

Let's discuss the current setup:

I am in the process of creating a webpage for an application that includes a navigation bar, a footer, and a 3-column body layout.

Initially, only one column is visible. This primary column will contain interactive divs known as cards. When a card is clicked, the second column should smoothly slide open, revealing additional information about the selected card.

This same pattern extends to the second column: it will display its own set of cards, which when clicked, will reveal the third column with further details related to the second card.

The second and third columns can be closed, whereas the first column remains open at all times.

I am utilizing Angular to dynamically load content into the columns, and so far, I have successfully set up the 1-3 column structure. However, implementing smooth animations has proven challenging. I am struggling to figure out how to animate the appearance and disappearance of each column seamlessly.

For reference, here is a link to what I have developed so far: Codepen example

<div class="container" ng-controller="Controller as ctrl">
  <div class="column" ng-repeat="column in ctrl.columns" ng-class="[column.mode, column.color]" ng-show="column.open">
    <button ng-click="ctrl.close(this)" ng-show="column.id != 0">Close</button>
    <p ng-click="ctrl.open(this)">Name: {{column.name}}</p>
    <p>Open: {{column.open}}</p>
    <p>Mode: {{column.mode}}</p>
    <p>Color: {{column.color}}</p>
  </div>
</div>

CSS:

.container {
  height: calc(100% - 50px);
  display: flex;
}

.column {
  padding: 10px 0 0 10px;
  overflow-y: auto;
}

.column-narrow {
  flex: 33;
}

.column-wide {
  flex: 66;
}

.column-full {
  flex: 100;
}

Clicking on the name paragraph triggers the expansion of the second and third columns. The colors are placeholder and used for visual differentiation between containers.

If anyone has a CSS(3) solution or suggestions for optimizing my code and enhancing the user experience, please feel free to share. I am currently learning Angular and open to improvements.

Answer №1

Getting basic animations up and running doesn't require a lot of code.

The built-in ng-show and ng-hide directives in AngularJS already come equipped with animation support. This means that AngularJS will automatically include animation hooks as additional classes like ng-hide-add, ng-hide-add-active, ng-hide-remove, ng-hide-remove-active.

All you need to do is add these classes to your CSS column style.

Simply including the following CSS lines was all it took to enable animations in your Codepen:


.column.ng-hide-add.ng-hide-add-active,
.column.ng-hide-remove.ng-hide-remove-active {
  -webkit-transition: all linear 0.5s;
  transition: all linear 0.5s;
}

Feel free to check out the updated codepen here: http://codepen.io/anon/pen/XbVLxO

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Storing data in the browser's local storage using jQuery without requiring any CSS

I have a form that receives data and I am trying to save the first two pages of received data into localStorage: <form id="myForm" method="post"> Font Size (px): <input id="fontsize" type="text" name="fontsize" /> </form> <s ...

Exploring the possibilities of device orientation in combination with 3D transforms

Imagine a project that aims to create a cube with sides representing different geolocations. The cube's sides for east, west, up, ground, north, and south are meant to always point in their respective directions. To gather the necessary data, the proj ...

default choice in dropdown menus

I need to populate my option fields with data retrieved from a database. I encountered an error in the console: Error: [$compile:ctreq] Controller 'select', required by directive 'ngOptions', can't be found! I am confident that t ...

Enhance your React project by incorporating Material-UI card media elements with the ability to add

I am trying to figure out how to create an opaque colored overlay on top of an image using Material-UI. While it is possible with plain HTML, CSS, and JavaScript, I am facing some challenges with Material-UI. <Card> <CardMedia> <im ...

Is there a way to rigorously validate my HTML, CSS, and JavaScript files against specific standards?

Can modern browsers suppress errors in HTML, CSS, and JS sources? Is there a method to uncover all mistakes, no matter how small they may be? ...

Is there a way to reverse the hover effect on div elements?

Let's start by examining the code I've written: HTML: <div class="button_container"> <div class="inner_button"> <a href="#" class="button_text">Button</a> </div> <div class="button_side"> ...

How can jQuery be used to display the size and type of linked files in title attributes?

For instance: Prior to <a target="_blank" href="http://www.adobe.com/devnet/acrobat/pdfs/reader_overview.pdf"> Adobe Reader JavaScript specification </a> As the file is in PDF format, the title should read title="PDF, 93KB, opens in a new ...

Is there a way to set the starting position of the overflow scroll to the middle?

Is there a way to have the overflow-x scrollbar scroll position start in the middle rather than on the left side? Currently, it always begins at the left side. Here is what it looks like now: https://i.stack.imgur.com/NN5Ty.png If anyone knows of a soluti ...

Comparing adjust-leading-to with leader in Compass - what sets them apart?

Currently exploring Compass and feeling a bit puzzled about the functionality of two mixins: adjust-leading-to and leader. Would appreciate it if someone could clarify the distinction between them. ...

Are you ready to create a Modal Factory?

For a while now, I have been utilizing modals in various front-end frameworks to communicate with users in my applications. Typically, the process involves defining the modal's html and then rendering it through a click event. As my apps continue to ...

Utilizing a dedicated settings configuration in a JSON file

I'm interested in finding out how to implement a separate file in Angularjs for storing settings data. For example, I have a service that contains a list of languages like this: .service('Language', function () { this.getLanguageSettings ...

Node.js poses a challenge when it comes to decoding incoming request data

I am attempting to create a sample login page using the combination of node, express, and angularjs. Displayed below is my login view: <div class="login-page"> <div class="login-page-content"> <div style="margin-top:30px;padding:10px;w ...

Share a list of items using Restangular in AngularJS

My approach to utilizing Restangular for making API calls involves targeting a single object, demonstrated in the code snippet below: $scope.box = { name : "box_a" , id : 1 }; Restangular.all('boxes/') .post($scope.box) .then(function() ...

Tips for minimizing code repetition when implementing controllers with overlapping functionalities?

If I have the following controllers: controller("MyCtrl1", ["$scope", "$sce", "myService", "$location", function ($scope, $sce, myService, $location) { $scope.Resources = window.MyGlobalResorcesObject; $scope.trustedHtml = function (in ...

Encountering Error 1 in Cordova File Transfer with Laravel Framework

I'm currently developing an Ionic angular 1 application where I need to upload an image to my laravel api server. However, I keep encountering error code 1 (File not found?) along with a laravel PHP error message as the response body. I've tried ...

What methods can I employ to utilize CSS on a table row that contains a specific class in an HTML

Is there a way to make the CSS affect <tr class="header"> with the class of header? CSS table.table-bordered tr:hover{ background-color: #C0C0A9; } table.table-bordered tr { background-color: #C0C0D9; } Any suggestions on what I ...

Technique for seamlessly moving between subpages and main page while scrolling to a specific id

I'm struggling with coding and thought I'd reach out for help here. Can anyone provide a solution to my problem? Issue - I have a navigation link on my main page that scrolls to an ID using jQuery. It works fine on the main page, but not on any ...

Is it better to overwrite past values in CSS or to duplicate rules?

Which one of these CSS code practices is considered better? A - concise and rewritten: @media only screen and (min-width: 480px) and (max-width: 960px) { h1, h2, .header, .widget, .copyright { position: static; width: 100%; height: auto; ...

The menu item is having trouble aligning to the right side

Hello, I am currently working on developing a website menu for a project and I am facing an issue with aligning the "Login" Menu item to the right side. Any assistance in resolving this alignment issue would be greatly appreciated. I am also willing to pro ...

When floating a heading 4 (h4) and two divs to the left, and a single div to the right,

When floating a h4 and 2 divs to the left, and another div to the right, how can I place a block inside the remaining space that perfectly fills it? The background color of this space should not spread outside. [h4][div][div][remaining space][div] Thank ...