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

The alignment of h2 headings becomes disordered beyond a specific viewport width

Can someone help me with an issue I'm facing regarding the placement of my "rightside" navigation? The problem arises when the viewport width drops below 767px, causing the h2 elements in the rightnav to align themselves directly next to the #leftnav. ...

What is the best way to choose a specific div within a container that contains additional HTML elements?

I am facing an issue with selecting the second div tag within a section that contains 2 divs and an img tag. I attempted to use section div:nth-child(2), but it is targeting the second element inside the first div. However, my goal is to select the secon ...

Managing JWT tokens for secured pages using Sails.js

In an effort to enhance security in my system, I decided to implement JWT token authentication. For the front-end, I opted for statellizer. Once a user logs into the system, a token is generated like this: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI ...

Slanted lines HTML CSS

I am encountering an issue with my HTML and CSS coding. The design requires a zig-zag "border" at the top and bottom of the page, creating a white paper space in between. The paper needs to be positioned underneath the zig-zag borders. Currently, this is ...

Using CSS to position an element relative/absolute within text inline

Need help aligning caret icons next to dynamically populated text in a navbar menu with dropdown tabs at any viewport size. Referring to positioning similar to the green carets shown here: https://i.stack.imgur.com/4XM7x.png Check out the code snippet bel ...

Show equally sized elements using a grid system

I need assistance with displaying fields in a row using CSS grid. I want to display 3 fields in a row with equal width, and if there are only 2 fields, they should also have equal widths. Additionally, if there is only one field, it should take up the full ...

Manipulating the DOM by nesting an icon within a button element in HTML

Currently working on my todo list project and I have a question about using innerHTML. I'm curious if I can include an icon inside of a button tag like this: btn.innerHTML = '<i class="fas fa-times fa-lg"></i>'; So, wo ...

Error in AngularJS - filterProvider not recognized

When the two script statements below are combined, they cause an error: "Error: [$injector:unpr] Unknown provider: searchNameFilterProvider <- searchNameFilter." Can someone explain why this happens? 1st segment Find Person: <input type="text" ng-m ...

Are route segments mandatory in AngularJS?

My routing configuration currently appears like this: .when "/:locale", templateUrl: "/views/index.html" ... .otherwise redirectTo: "/en" The problem is that the initial route also matches /. Is there a method to include mandatory route segments, so th ...

Insert a CSS Class into an HTML div element with JQuery

I'm faced with a bit of a challenge. Here's the scenario: <div class="portItem"></div> <div class="portItem"></div> <div class="portItem"></div> <div class="p ...

How can I code a div to automatically scroll to the top of the page?

I'm attempting to implement something similar in WordPress - I want a div containing an advertisement to initially start 300px down the page, then scroll up with the page until it reaches the top, and finally stay there if the user continues to scroll ...

Stylish Sudoku Grid Design with CSS-Grid Borders

I have designed a sudoku puzzle and I am seeking assistance with CSS to style it. My goal for styling using CSS is illustrated here... https://i.stack.imgur.com/nrA47.png What I currently have appears like this... https://i.stack.imgur.com/zpNp6.png T ...

Is it possible for a website administrator to view the modifications I have made to the CSS and HTML code?

Is it possible for a website to detect any temporary changes made to their CSS or Html through developer tools, even though these changes are not permanent? ...

Automatically rehydrate an instance using Angular and JavaScript

REVISION Special thanks to Shaun Scovill for providing an elegant solution using lodash // Creating an instance and injecting server object - within the ChartService implementation below var chart = new Chart(serverChartObject); // Replacing ...

AngularJs tip: Harness the power of parallel and sequential function calls that have interdependencies

service (function () { 'use strict'; angular .module('app.user') .factory('myService', Service); Service.$inject = ['$http', 'API_ENDPOINT', '$q']; /* @ngInject ...

Tips for resolving conflicts between CSS files

My index.html file contains multiple css and js files, including MaterializeCSS and a style.css file. However, when both are included simultaneously, using elements from Materialize such as tabs results in them not appearing correctly. Despite initializing ...

Adjust the color of the label when the checkbox is marked, and make it red when the checkbox is left

Looking to create a customized checkbox due to challenges in styling the default HTML checkbox, I have attempted the following code. The checkbox functions properly when clicking on the label, but I am unable to change the border color of the label based o ...

JavaScript Equivalent of jQuery's removeClass and addClass Functions

I am faced with the challenge of rewriting the following code without using jQuery: document.querySelector('.loading-overlay').classList.remove('hidden'); Can anyone provide guidance on how this can be achieved? ...

Is there a way to convert the text within a div from Spanish to English using angular.js?

I am working with a div element that receives dynamic text content from a web service in Spanish. I need to translate this content into English. I have looked into translation libraries, but they seem more suited for individual words rather than entire dyn ...

Is there a way to arrange my bootstrap navigation tabs vertically on my mobile device?

I have a group of five bootstrap navigation tabs that are evenly spaced and visually appealing on desktop screens. However, when viewed on a mobile device, the text within the tabs becomes cramped together. How can I make the tabs stack vertically on mobil ...