Description
What problem does this feature solve?
In some CSS libraries, i.e. Bootstrap, many components have opacity set to 0
by default, and only have opacity set to 1
when a class is applied. i.e. Bootstrap's fade + show
classes:
.fade:not(.show) { opacity: 0; }
The current <transition>
behaviour does not support retaining the enter-to-class
(as it is immediately removed once the transition completes).
Currently one has to use javascript hooks and VM data to add/remove the show
class, which makes it impossible to make re-usable transition components, as simply adding a class via javascript to the el
reference (via el.classList.add/remove('show')
) doesn't guarantee persistence if the content in the default slot manipulates it's own classes, meaning the transition component must be integrated into the custom component, not as a re-usable utility wrapper component).
What does the proposed API look like?
It would be nice to either be able to retain the enter-to-class
class after the transition completes, or create a new prop that provides this behaviour for a particular class name i.e. enter-to-retain-class
. The class would be removed on leave.
The other option would be to create a new prop active-class="classname"
which is added one frame after insertion, and removed when the leave transition is to start (basically rolling the enter-to-class
and leave-class
into one prop, but retain the class until leave is initiated)