Transition
A jQuery plugin for CSS transition events.
Demo
Demos are largely unstyled to give developers a better idea of how the plugin can drop into a new or existing project.
<div class="transition_target"></div>
$(".transition_target").transition({
always: true
}, function() {
// Tranition complete...
}).addClass("active");
.transition_target {
background: black;
transition: background 0.25s;
}
.transition_target.active {
background: blue;
}
Using Transition
Main
transition.js
Dependencies
jQuery
core.js
Basic
Transition provides a predictable interface for moving to CSS based animations:
$(".target").transition(function() {
...
}).addClass("visible");
Resolve
Transitions can manually resolved, which will immediately fire the associated callback:
if (shouldResolve) {
$(".target").transition("resolve");
}
Options
Set instance options by passing a valid object at initialization, or to the public defaults
method. Custom options for a specific instance can also be set by attaching a data-transition-options
attribute to the target elment. This attribute should contain the properly formatted JSON object representing the custom options.
Name | Type | Default | Description |
---|---|---|---|
always |
boolean |
False |
Flag to always react to transition end (.on vs .one) |
property |
string |
null |
Property to react to |
target |
string |
null |
Target child selector |
Methods
Methods are publicly available to all active instances, unless otherwise stated.
defaults
Extends plugin default settings; effects instances created hereafter.
$.transition("defaults", { ... });
Parameters
Name | Type | Default | Description |
---|---|---|---|
options |
object |
{} |
New plugin defaults |
destroy
Removes plugin instance.
$(".target").transition("destroy");
resolve
Resolves current transition end events.
$(".target").transition("resolve");
CSS
Class | Type | Description |
---|---|---|
.fs-transition-element |
element |
Target Element |