The Transition service allows to display or hide content smoothly through an animation. At its heart, a transition is a Directive managing the visibility of inner content by attaching / detaching classes.
Creating and attaching a transition is straighforward! Simply create a transition service using the factory createTransition and attach the provided directive to a dom element.
Let's see this in action by implementing a Collapse component:
AgnosUI provides several transition functions to use (collapse vertical or horizontal, fade in/out) but you may create your own using the createSimpleClassTransition utility and a bit of css. Here is another example with a flip animation:
When creating your own, remember to respect the user preferences and the media query prefers-reduced-motion.
You can configure a transition using the following properties:
TransitionFn : the transition function that will be runboolean : whether the element should be visible when the transition is completedboolean : whether the transition should be animatedboolean : if the element is initially visible, whether the element should be animated when first displayed() => void : function to be called when the transition is completed and the element is visible() => void : function to be called when the transition is completed and the element is not visible(visible: boolean) => void : function to be called when the visible property changesThe state of the transition will include the stores:
boolean : whether the element is visible or will be visible when the transition is completedboolean : whether the element to be animated is present in the DOMHTMLElement | null : reference to the DOM elementboolean : whether a transition is currently runningboolean : whether the element is visible and not transitioningboolean : whether the element is not visible and not transitioningYou may play around the properties and see the stores updated with the following example:
Sample not found, make sure to fill the samples.ts file.