Reputation:
I have an element for which I need to toggle the opacity. Sometimes I want to transition the opacity, and sometimes I do not. Is there an easy way to reset the property without the transition using JavaScript some of the time without turning the transition off?
Upvotes: 4
Views: 1631
Reputation: 96241
Is there an easy way to reset the property without the transition using JavaScript some of the time without turning the transition off?
Not that I know of. A transition occurs when the property it is set on changes – how that change occurs, does not matter.
But there is an easy way of turning it off – apply the transition via a class, and then remove that class dynamically when you want to change the property value without transition.
Upvotes: 6