transition-debug.js revision 576e5aadaa60b824ce0a3875d3551ca3151a1957
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyYUI.add('transition-native', function(Y) {
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney/**
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*/
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney/**
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney* Provides the base Transition class.
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney*
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney* @module node
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney* @submodule transition-native
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney*/
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney/**
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 */
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeneyvar TRANSITION = '-webkit-transition',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney TRANSITION_CAMEL = 'WebkitTransition',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney TRANSITION_PROPERTY = '-webkit-transition-property',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney TRANSITION_DURATION = '-webkit-transition-duration',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney TRANSITION_TIMING_FUNCTION = '-webkit-transition-timing-function',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney TRANSITION_DELAY = '-webkit-transition-delay',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney TRANSITION_END = 'webkitTransitionEnd',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyTransition = function() {
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney this.init.apply(this, arguments);
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney};
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyTransition._reKeywords = /^(?:node|duration|iterations|easing|delay)$/;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyTransition.useNative = false;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeneyif (TRANSITION in Y.config.doc.documentElement.style) {
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney Transition.useNative = true;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney Transition.supported = true; // TODO: remove
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney}
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyY.Node.DOM_EVENTS[TRANSITION_END] = 1;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyTransition.NAME = 'transition';
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyTransition.DEFAULT_EASING = 'ease-in-out';
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyTransition.DEFAULT_DURATION = 0.5;
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyTransition.DEFAULT_DELAY = 0;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt SweeneyTransition._nodeAttrs = {};
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt SweeneyTransition._count = 0;
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyTransition.prototype = {
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney constructor: Transition,
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney init: function(node, config) {
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney var anim = this;
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney if (!anim._running) {
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._node = node;
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._config = config;
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney node._transition = anim; // cache for reuse
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._duration = ('duration' in config) ?
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney config.duration: anim.constructor.DEFAULT_DURATION;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._delay = ('delay' in config) ?
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney config.delay: anim.constructor.DEFAULT_DELAY;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._easing = config.easing || anim.constructor.DEFAULT_EASING;
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._count = 0; // track number of animated properties
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._running = false;
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim.initAttrs(config);
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney }
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney return anim;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney },
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney initAttrs: function(config) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney var anim = this,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney node = anim._node,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney uid = Y.stamp(node),
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney attrs = Transition._nodeAttrs[uid],
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney duration,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney delay,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney easing,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney val,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney transition,
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney attr;
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney if (!attrs) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney attrs = Transition._nodeAttrs[uid] = {};
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney }
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney if (config.transform && !config['-webkit-transform']) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney config['-webkit-transform'] = config.transform;
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney delete config.transform; // TODO: copy
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney }
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney for (attr in config) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney if (config.hasOwnProperty(attr) && !Transition._reKeywords.test(attr)) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney val = transition = config[attr];
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney if (attrs[attr] && attrs[attr].transition) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney attrs[attr].transition._count--; // remapping attr to this transition
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney } else {
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney Transition._count += 1;
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney }
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney if (typeof transition.value !== 'undefined') {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney val = transition.value;
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney }
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney if (typeof val === 'function') {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney val = val.call(node, node);
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney }
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney duration = (typeof transition.duration !== 'undefined') ? transition.duration :
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney anim._duration;
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney delay = (typeof transition.delay !== 'undefined') ? transition.delay :
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney anim._delay;
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney if (!duration) { // make async and fire events
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney duration = 0.00001;
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney }
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney easing = transition.easing || anim._easing;
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney anim._count++; // track number of bound properties
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney attrs[attr] = {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney value: val,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney duration: duration,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney delay: delay,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney easing: easing,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney transition: anim
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney };
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney }
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney }
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney },
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney /**
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney * Starts or an animation.
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney * @method run
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney * @chainable
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney */
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney run: function(callback) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney var anim = this;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney if (!anim._running) {
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney anim._running = true;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._node.fire('transition:start', {
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney type: 'transition:start',
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney config: anim._config
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney });
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney anim._start();
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney anim._callback = callback;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney }
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney return anim;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney },
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney _start: function() {
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney this._runNative();
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney },
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney _prepDur: function(dur) {
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney dur = parseFloat(dur);
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney return dur + 's';
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney },
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney _runNative: function(time) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney var anim = this,
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney node = anim._node,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney uid = Y.stamp(node),
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney domNode = node._node,
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney style = domNode.style,
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney computed = getComputedStyle(domNode),
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney attrs = Transition._nodeAttrs[uid],
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney cssText = '',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney cssTransition = computed[TRANSITION_PROPERTY],
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney transitionText = TRANSITION_PROPERTY + ': ',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney duration = TRANSITION_DURATION + ': ',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney easing = TRANSITION_TIMING_FUNCTION + ': ',
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney delay = TRANSITION_DELAY + ': ',
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney attr,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney name;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney // preserve existing transitions
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney if (cssTransition !== 'all') {
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney transitionText += cssTransition + ',';
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney duration += computed[TRANSITION_DURATION] + ',';
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney easing += computed[TRANSITION_TIMING_FUNCTION] + ',';
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney delay += computed[TRANSITION_DELAY] + ',';
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney }
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney // run transitions mapped to this instance
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney for (name in attrs) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney attr = attrs[name];
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney if (attrs.hasOwnProperty(name) && attr.transition === anim) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney duration += anim._prepDur(attr.duration) + ',';
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney delay += anim._prepDur(attr.delay) + ',';
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney easing += (attr.easing) + ',';
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney transitionText += name + ',';
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney cssText += name + ': ' + attr.value + '; ';
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney }
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney }
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney transitionText = transitionText.replace(/,$/, ';');
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney duration = duration.replace(/,$/, ';');
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney easing = easing.replace(/,$/, ';');
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney delay = delay.replace(/,$/, ';');
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney // only one native end event per node
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney if (!node._hasTransitionEnd) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney node.on(TRANSITION_END, anim._onNativeEnd);
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney node._hasTransitionEnd = true;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney }
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney style.cssText += transitionText + duration + easing + delay + cssText;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney },
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney _end: function(elapsed) {
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney var anim = this,
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney node = anim._node,
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney callback = anim._callback,
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney data = {
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney type: 'transition:end',
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney config: anim._config,
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney elapsedTime: elapsed
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney };
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._running = false;
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney if (callback) {
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._callback = null;
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney setTimeout(function() { // IE: allow previous update to finish
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney callback.call(node, data);
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney }, 1);
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney }
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney node.fire('transition:end', data);
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney },
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney _endNative: function() {
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney var node = this._node;
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney if (Transition._count <= 0) {
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney node._node.style[TRANSITION_CAMEL] = '';
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney }
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney },
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney _onNativeEnd: function(e) {
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney var node = this,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney uid = Y.stamp(node),
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney event = e._event,
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney name = event.propertyName,
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney elapsed = event.elapsedTime,
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney attrs = Transition._nodeAttrs[uid],
448834d88f7c2818b5a70125bba193051806ccf9Matt Sweeney attr = attrs[name],
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney anim = (attr) ? attr.transition :null,
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney callback;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney if (anim) {
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney callback = anim._callback;
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney anim._count--;
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney delete attrs[name];
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney Transition._count--;
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney node.fire('transition:propertyEnd', {
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney type: 'propertyEnd',
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney propertyName: name,
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney elapsedTime: elapsed
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney });
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney if (anim._count <= 0) {
0dfbad86367ee46837c580e51d7d76e8bd6d88b7Matt Sweeney
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._endNative();
576e5aadaa60b824ce0a3875d3551ca3151a1957Matt Sweeney anim._end(elapsed);
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney }
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney }
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney },
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney destroy: function() {
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney this.detachAll();
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney this._node = null;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney }
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney};
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyY.Transition = Transition;
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyY.TransitionNative = Transition; // TODO: remove
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney/**
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 value: 0,
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney duration: 2,
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney easing: 'ease-in'
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney }
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney });
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney </pre>
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney @for node
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney @method transition
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney @param {Object} An object containing one or more style properties, a duration and an easing.
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney @chainable
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney*/
959c053d56a076109993a2f14094d20b1f8c0c17Matt SweeneyY.Node.prototype.transition = function(config, callback) {
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney var anim = this._transition;
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney if (anim && !anim._running) {
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney anim.init(this, config);
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney } else {
959c053d56a076109993a2f14094d20b1f8c0c17Matt Sweeney anim = new Transition(this, config);
959c Error!

 

There was an error!

null

java.lang.NullPointerException