https://github.com/component/class-transition
Applies a transitive class that gets removed after a CSS transition ends.
https://github.com/component/class-transition
Last synced: 9 months ago
JSON representation
Applies a transitive class that gets removed after a CSS transition ends.
- Host: GitHub
- URL: https://github.com/component/class-transition
- Owner: component
- Created: 2013-02-23T21:18:39.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2016-07-27T00:27:22.000Z (over 9 years ago)
- Last Synced: 2025-04-03T04:28:12.933Z (12 months ago)
- Language: HTML
- Size: 146 KB
- Stars: 13
- Watchers: 6
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# class-transition
Applies a transitive `className` that gets removed upon a CSS
transition completing or a timeout executing as a fallback.
## Example
```js
var transition = require('class-transition');
var el = document.getElementById('subject');
transition(el, 'highlight', '500ms', function() {
console.log('transition finished');
});
```
## API
### transition(el, class, [time], [fn])
Applies the given `class` to `el` for a given `time`.
If no `time` is given, the class will be removed when
the transition completes.
`time` is passed to the
[ms](http://github.com/guille/ms) component, so it can be `500` or `'500ms'` or `'0.5s'`.
You may also pass an optional `fn` to be notified
when the transition finishes.
## License
MIT