🚧 Work in progress
This is an Ember.js element modifiers solution for attaching CSS transitions, heavily inspired by the old component-based approach offered by ember-css-transitions.
ember install ember-css-transitions-modifiers
Use the css-transition
modifier, as shown below:
Define transitions in CSS. The modifier will add -enter
, -enter-active
, -leave
& -leave-active
suffixes at the appropriate times on insertion and removal.
.fade-enter {
opacity: 0.01;
}
.fade-enter.fade-enter-active {
opacity: 1;
transition: opacity .5s ease-in;
}
.fade-leave {
opacity: 1;
}
.fade-leave.fade-leave-active {
opacity: 0.01;
transition: opacity .5s ease-in;
}
Define multiple classes using a space delimited string. Note that CSS transitions set on multiple classes will not work together.
Transitions can be toggled on and off using enter
and leave
named args. Truthy values do not need to be specified, but for the sake of this example:
The transition-delay
CSS property can be defined (in ms) via delay
, enterDelay
and leaveDelay
named args:
The transition-duration
CSS property can be defined (in ms) via duration
, enterDuration
and leaveDuration
named args:
The active
parameter allows transitions to be fired via a named arg, rather than lifecycle hooks. This allows use cases where:
- Transitions need to be run without the element being added & removed from the DOM (e.g. on-scroll implementations).
- The element may need to be rendered via Fastboot (e.g. SEO critical content).
Attach actions to onEnter
and onLeave
events using named arguments:
- Ember.js v3.4 or above
- Ember CLI v2.13 or above
- Node.js v8 or above
See the Contributing guide for details.
This project is licensed under the MIT License.