transition-debug.js revision 576e5aadaa60b824ce0a3875d3551ca3151a1957
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney* The Native Transition Utility provides an API wrapper for CSS transitions.
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney* It is also the base module for the timer-based transition module.
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney* @module node
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney* Provides the base Transition class.
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney* @module node
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney* @submodule transition-native
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney * A class for constructing transition instances.
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney * @class Transition
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney * @for Transition
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney * @constructor
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney * @extends Base
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney TRANSITION_PROPERTY = '-webkit-transition-property',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney TRANSITION_DURATION = '-webkit-transition-duration',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney TRANSITION_TIMING_FUNCTION = '-webkit-transition-timing-function',
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyTransition._reKeywords = /^(?:node|duration|iterations|easing|delay)$/;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeneyif (TRANSITION in Y.config.doc.documentElement.style) {
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney config.duration: anim.constructor.DEFAULT_DURATION;
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._easing = config.easing || anim.constructor.DEFAULT_EASING;
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._count = 0; // track number of animated properties
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney if (config.transform && !config['-webkit-transform']) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney config['-webkit-transform'] = config.transform;
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney if (config.hasOwnProperty(attr) && !Transition._reKeywords.test(attr)) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney attrs[attr].transition._count--; // remapping attr to this transition
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney duration = (typeof transition.duration !== 'undefined') ? transition.duration :
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney delay = (typeof transition.delay !== 'undefined') ? transition.delay :
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney anim._count++; // track number of bound properties
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney * Starts or an animation.
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney * @method run
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney * @chainable
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney _start: function() {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney // preserve existing transitions
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney duration += computed[TRANSITION_DURATION] + ',';
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney easing += computed[TRANSITION_TIMING_FUNCTION] + ',';
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney // run transitions mapped to this instance
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney if (attrs.hasOwnProperty(name) && attr.transition === anim) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney duration += anim._prepDur(attr.duration) + ',';
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney transitionText = transitionText.replace(/,$/, ';');
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney // only one native end event per node
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney style.cssText += transitionText + duration + easing + delay + cssText;
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney setTimeout(function() { // IE: allow previous update to finish
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney _onNativeEnd: function(e) {
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney destroy: function() {
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyY.TransitionNative = Transition; // TODO: remove
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney Animate one or more css properties to a given value.
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney <pre>example usage:
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney Y.one('#demo').transition({
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney duration: 1, // seconds
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney easing: 'ease-out',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney height: '10px',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney width: '10px',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney opacity: { // per property duration and/or easing
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney duration: 2,
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney easing: 'ease-in'
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney @method transition
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney @param {Object} An object containing one or more style properties, a duration and an easing.