We are currently in the process of developing a sophisticated single-page application that allows users to create animations on various widgets. For example, a widget button can be animated from left to right with changes in opacity over a set duration. Additionally, one widget can trigger animations on another, creating layered transition effects.
Users have the ability to define and trigger these animations through JavaScript in a complex manner. The animations can be customized in different combinations, utilizing an object-oriented programming approach for animation data management. Users can also reverse, pause, and play the animations as needed.
In terms of animation technology, we are considering two options:
01 - Utilizing CSS Transitions by generating dynamic CSS classes and injecting them into the header of the page. This approach involves manipulating the DOM to handle class switching for animations.
02 - Using a JavaScript library such as Velocity.js or Greensock to animate the DOM elements directly using inline styles.
03 - Although we experimented with Web Animation API (and CSS Animation), we encountered some limitations that hindered its adoption.
We would greatly appreciate your feedback regarding the following approaches:
Approach 01:
- Is it feasible to manage programmatically with JavaScript?
- Can properties within style tags be dynamically edited without causing flickering or relying on complex regex?
- Are there any issues associated with dynamically adding tags to the header, such as potential flickering?
- Have you experienced performance drawbacks when running multiple parallel animations with CSS Transition?
- Do you know of any projects that successfully utilize this approach?
- How is the control of animation functions like reversing, stopping, and pausing handled?
Approach 02:
- Do you believe this approach is generally more manageable with JavaScript?
- Are there any drawbacks that would lead one to choose Approach 01 instead?
- How is the control of animation functions managed in this approach?
We welcome any feedback you may have on this matter.
Here's a helpful article I came across: https://davidwalsh.name/css-js-animation