transition.js revision 2e49faa8717cc2acbd7ab2aac237061848568a6c
/**
* Provides the transition method for Node.
* Transition has no API of its own, but adds the transition method to Node.
*
* @module transition
* @requires node-style
*/
var CAMEL_VENDOR_PREFIX = '',
VENDOR_PREFIX = '',
DOCUMENT_ELEMENT = 'documentElement',
TRANSITION = 'transition',
TRANSITION_CAMEL = 'Transition',
EMPTY_OBJ = {},
VENDORS = [
'Webkit',
'Moz'
],
Webkit: 'webkitTransitionEnd'
},
/**
* A class for constructing transition instances.
* Adds the "transition" method to Node.
* @class Transition
* @constructor
*/
Transition = function() {
};
return m1.toUpperCase();
});
return property;
};
var str = '';
if (m1) {
}
if (m3) {
}
return str;
});
return property;
};
Transition.useNative = false;
Transition.useNative = true;
}
});
TRANSITION_END = 'transitionend';
Transition.fx = {};
Transition.toggles = {};
Transition._hasEnd = {};
Transition._nodeAttrs = {};
Transition.prototype = {
var anim = this;
}
return anim;
},
var anim = this,
dur,
attr,
val;
if (!attrs) {
}
// might just be a value
}
if (typeof val === 'function') {
}
// take control if another transition owns this property
}
}
// make 0 async and fire events
};
// native end event doesnt fire when setting to same value
// supplementing with timer
// val may be a string or number (height: 0, etc), but computedStyle is always string
setTimeout(function() {
});
}, dur * 1000);
}
},
removeProperty: function(prop) {
var anim = this,
}
},
var attr,
}
// when size is auto or % webkit starts from zero instead of computed
// TODO: selective set
}
}
}
},
/**
* Starts or an animation.
* @method run
* @chainable
* @private
*/
var anim = this,
data = {
type: 'transition:start',
};
//anim._node.fire('transition:start', data);
}
}
return anim;
},
_start: function() {
this._runNative();
},
return dur + 's';
},
_runNative: function(time) {
var anim = this,
cssText = '',
attr,
name;
// preserve existing transitions
if (cssTransition !== 'all') {
}
// run transitions mapped to this instance
} else {
this.removeProperty(name);
}
}
}
// only one native end event per node
//anim._detach = Y.on(TRANSITION_END, anim._onNativeEnd, node);
//node[ON_TRANSITION_END] = anim._onNativeEnd;
}
//setTimeout(function() { // allow updates to apply (size fix, onstart, etc)
//}, 1);
},
var anim = this,
data = {
type: 'transition:end',
},
if (node) {
setTimeout(function() { // IE: allow previous update to finish
// nested to ensure proper fire order
if (callback) {
}
}, 1);
} else if (callback) {
setTimeout(function() { // IE: allow previous update to finish
}, 1);
}
//node.fire('transition:end', data);
}
},
_endNative: function(name) {
value = node.ownerDocument.defaultView.getComputedStyle(node, '')[Transition._toCamel(TRANSITION_PROPERTY)];
if (typeof value === 'string') {
}
},
_onNativeEnd: function(e) {
var node = this,
event = e,//e._event,
data,
if (anim) {
data = {
type: 'propertyEnd',
};
}
//node.fire('transition:propertyEnd', data);
}
}
},
destroy: function() {
var anim = this;
/*
if (anim._detach) {
anim._detach.detach();
}
*/
//anim._node[ON_TRANSITION_END] = null;
}
};
Y.Transition = Transition;
/**
* Animate one or more css properties to a given value. Requires the "transition" module.
* <pre>example usage:
* Y.one('#demo').transition({
* duration: 1, // in seconds, default is 0.5
* easing: 'ease-out', // default is 'ease'
* delay: '1', // delay start for 1 second, default is 0
*
* height: '10px',
* width: '10px',
*
* opacity: { // per property
* value: 0,
* duration: 2,
* delay: 2,
* easing: 'ease-in'
* }
* });
* </pre>
* @for Node
* @method transition
* @param {Object} config An object containing one or more style properties, a duration and an easing.
* @param {Function} callback A function to run after the transition has completed.
* @chainable
*/
var
prop;
if (typeof config === 'function') {
config = null;
}
}
}
}
} else {
}
} else { // name is a config, config is a callback or undefined
}
} else {
}
return this;
};
this._show(); // show prior to transition
if (name && Y.Transition) {
if (typeof name !== 'string' && !name.push) { // named effect or array of effects supercedes default
if (typeof config === 'function') {
}
}
}
return this;
};
return function() {
if (fn) {
}
if (callback) {
}
};
};
if (name && Y.Transition) {
if (typeof config === 'function') {
config = null;
}
if (typeof name !== 'string' && !name.push) { // named effect or array of effects supercedes default
if (typeof config === 'function') {
}
}
} else {
this._hide();
}
return this;
};
/**
* Animate one or more css properties to a given value. Requires the "transition" module.
* <pre>example usage:
* Y.all('.demo').transition({
* duration: 1, // in seconds, default is 0.5
* easing: 'ease-out', // default is 'ease'
* delay: '1', // delay start for 1 second, default is 0
*
* height: '10px',
* width: '10px',
*
* opacity: { // per property
* value: 0,
* duration: 2,
* delay: 2,
* easing: 'ease-in'
* }
* });
* </pre>
* @for NodeList
* @method transition
* @param {Object} config An object containing one or more style properties, a duration and an easing.
* @param {Function} callback A function to run after the transition has completed. The callback fires
* once per item in the NodeList.
* @chainable
*/
i = 0,
node;
}
return this;
};
name = null;
}
}
if (on) {
this._show();
} else {
}
return this;
};
i = 0,
node;
}
return this;
};
fadeOut: {
opacity: 0,
duration: 0.5,
easing: 'ease-out'
},
fadeIn: {
opacity: 1,
duration: 0.5,
easing: 'ease-in'
},
sizeOut: {
height: 0,
width: 0,
duration: 0.75,
easing: 'ease-out'
},
sizeIn: {
},
},
duration: 0.5,
easing: 'ease-in',
on: {
start: function() {
this._transitionOverflow = overflow;
}
},
end: function() {
if (this._transitionOverflow) { // revert overridden value
delete this._transitionOverflow;
}
}
}
}
});
});
/*
* The Transition Utility provides an API for creating advanced transitions.
* @module transition
*/
/*
* Provides the base Transition class, for animating numeric properties.
*
* @module transition
* @submodule transition-timer
*/
var Transition = Y.Transition;
_start: function() {
if (Transition.useNative) {
this._runNative();
} else {
this._runTimer();
}
},
_runTimer: function() {
var anim = this;
anim._initAttrs();
anim._startTime = new Date();
},
_endTimer: function() {
var anim = this;
anim._startTime = null;
},
_runFrame: function() {
var t = new Date() - this._startTime;
this._runAttrs(t);
},
var anim = this,
done = false,
allDone = false,
data,
name,
d,
t,
i;
t = time;
data = {
type: 'propertyEnd',
};
done = (t >= d);
if (t > d) {
t = d;
}
if (done) {
}
//node.fire('transition:propertyEnd', data);
allDone = true;
}
}
}
}
}
},
_initAttrs: function() {
var anim = this,
val,
name,
mTo,
// only allow supported properties
}
if (typeof easing === 'string') {
}
}
} else {
}
}
}
},
destroy: function() {
this.detachAll();
this._node = null;
}
}, true);
Y.mix(Y.Transition, {
_runtimeAttrs: {},
/*
* Regex of properties that should use the default unit.
*
* @property RE_DEFAULT_UNIT
* @static
*/
/*
* The default unit to use with properties that pass the RE_DEFAULT_UNIT test.
*
* @property DEFAULT_UNIT
* @static
*/
DEFAULT_UNIT: 'px',
/*
* Time in milliseconds passed to setInterval for frame processing
*
* @property intervalTime
* @default 20
* @static
*/
intervalTime: 20,
/*
* Bucket for custom getters and setters
*
* @property behaviors
* @static
*/
behaviors: {
left: {
}
}
},
/*
* The default setter to use when setting object properties.
*
* @property DEFAULT_SETTER
* @static
*/
if (node) {
}
} else {
}
},
/*
* The default getter to use when getting object properties.
*
* @property DEFAULT_GETTER
* @static
*/
val = '';
}
return val;
},
_startTimer: function() {
if (!Transition._timer) {
}
},
_stopTimer: function() {
Transition._timer = null;
},
/*
* Called per Interval to handle each animation frame.
* @method _runFrame
* @private
* @static
*/
_runFrame: function() {
var done = true,
anim;
done = false;
}
}
if (done) {
}
},
cubicBezier: function(p, t) {
var x0 = 0,
y0 = 0,
x1 = p[0],
y1 = p[1],
x2 = p[2],
y2 = p[3],
x3 = 1,
y3 = 0,
D = x0,
H = y0,
x = (((A*t) + B)*t + C)*t + D,
y = (((E*t) + F)*t + G)*t + H;
return [x, y];
},
easings: {
'ease-in': [0.42, 0, 1, 1],
'ease-out': [0, 0, 0.58, 1],
'ease-in-out': [0.42, 0, 0.58, 1]
},
_running: {},
_timer: null,
}, true);
Transition.behaviors.top = Transition.behaviors.bottom = Transition.behaviors.right = Transition.behaviors.left;
Y.Transition = Transition;