76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassYUI.add('transition-native', function(Y) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass/**
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass* Provides the transition method for Node.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass* Transition has no API of its own, but adds the transition method to Node.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass*
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass* @module transition
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass* @requires node-style
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass*/
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeneyvar CAMEL_VENDOR_PREFIX = '',
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney VENDOR_PREFIX = '',
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney DOCUMENT = Y.config.doc,
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney DOCUMENT_ELEMENT = 'documentElement',
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney TRANSITION = 'transition',
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney TRANSITION_CAMEL = 'Transition',
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney TRANSITION_PROPERTY_CAMEL,
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney TRANSITION_PROPERTY,
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney TRANSITION_DURATION,
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney TRANSITION_TIMING_FUNCTION,
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney TRANSITION_DELAY,
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney TRANSITION_END,
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney ON_TRANSITION_END,
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney TRANSFORM_CAMEL,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass EMPTY_OBJ = {},
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney VENDORS = [
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney 'Webkit',
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney 'Moz'
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney ],
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney VENDOR_TRANSITION_END = {
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney Webkit: 'webkitTransitionEnd'
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney },
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass/**
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * A class for constructing transition instances.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Adds the "transition" method to Node.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @class Transition
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @constructor
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass */
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassTransition = function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this.init.apply(this, arguments);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassTransition._toCamel = function(property) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass property = property.replace(/-([a-z])/gi, function(m0, m1) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return m1.toUpperCase();
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass });
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return property;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassTransition._toHyphen = function(property) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass property = property.replace(/([A-Z]?)([a-z]+)([A-Z]?)/g, function(m0, m1, m2, m3) {
416ff6e8477a5950c56e04adea6abf838140a852Matt Sweeney var str = ((m1) ? '-' + m1.toLowerCase() : '') + m2;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (m3) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass str += '-' + m3.toLowerCase();
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return str;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass });
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return property;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
5b1c89071eae2ae83f92260d7a50f9ad4e574f3dMatt SweeneyTransition.SHOW_TRANSITION = 'fadeIn';
5b1c89071eae2ae83f92260d7a50f9ad4e574f3dMatt SweeneyTransition.HIDE_TRANSITION = 'fadeOut';
5b1c89071eae2ae83f92260d7a50f9ad4e574f3dMatt Sweeney
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyTransition.useNative = false;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyY.Array.each(VENDORS, function(val) { // then vendor specific
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney var property = val + TRANSITION_CAMEL;
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney if (property in DOCUMENT[DOCUMENT_ELEMENT].style) {
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney CAMEL_VENDOR_PREFIX = val;
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney VENDOR_PREFIX = Transition._toHyphen(val) + '-';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney Transition.useNative = true;
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney Transition.supported = true; // TODO: remove
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney }
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney});
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney
416ff6e8477a5950c56e04adea6abf838140a852Matt SweeneyTRANSITION_CAMEL = CAMEL_VENDOR_PREFIX + TRANSITION_CAMEL;
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyTRANSITION_PROPERTY_CAMEL = CAMEL_VENDOR_PREFIX + 'TransitionProperty';
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyTRANSITION_PROPERTY = VENDOR_PREFIX + 'transition-property';
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyTRANSITION_DURATION = VENDOR_PREFIX + 'transition-duration';
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyTRANSITION_TIMING_FUNCTION = VENDOR_PREFIX + 'transition-timing-function';
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyTRANSITION_DELAY = VENDOR_PREFIX + 'transition-delay';
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyTRANSITION_END = 'transitionend';
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyON_TRANSITION_END = 'on' + CAMEL_VENDOR_PREFIX.toLowerCase() + 'transitionend';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyTRANSITION_END = VENDOR_TRANSITION_END[CAMEL_VENDOR_PREFIX] || TRANSITION_END;
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyTRANSFORM_CAMEL = CAMEL_VENDOR_PREFIX + 'Transform';
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyTransition.fx = {};
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyTransition.toggles = {};
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyTransition._hasEnd = {};
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt SweeneyTransition._reKeywords = /^(?:node|duration|iterations|easing|delay|on|onstart|onend)$/i;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassY.Node.DOM_EVENTS[TRANSITION_END] = 1;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassTransition.NAME = 'transition';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassTransition.DEFAULT_EASING = 'ease';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassTransition.DEFAULT_DURATION = 0.5;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassTransition.DEFAULT_DELAY = 0;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassTransition._nodeAttrs = {};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassTransition.prototype = {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass constructor: Transition,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass init: function(node, config) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var anim = this;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._node = node;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (!anim._running && config) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._config = config;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass node._transition = anim; // cache for reuse
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._duration = ('duration' in config) ?
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config.duration: anim.constructor.DEFAULT_DURATION;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._delay = ('delay' in config) ?
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config.delay: anim.constructor.DEFAULT_DELAY;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._easing = config.easing || anim.constructor.DEFAULT_EASING;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._count = 0; // track number of animated properties
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._running = false;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return anim;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass addProperty: function(prop, config) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var anim = this,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass node = this._node,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass uid = Y.stamp(node),
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass nodeInstance = Y.one(node),
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass attrs = Transition._nodeAttrs[uid],
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass computed,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass compareVal,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass dur,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass attr,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass val;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (!attrs) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass attrs = Transition._nodeAttrs[uid] = {};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass attr = attrs[prop];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // might just be a value
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (config && config.value !== undefined) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass val = config.value;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else if (config !== undefined) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass val = config;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config = EMPTY_OBJ;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (typeof val === 'function') {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass val = val.call(nodeInstance, nodeInstance);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (attr && attr.transition) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // take control if another transition owns this property
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (attr.transition !== anim) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass attr.transition._count--; // remapping attr to this transition
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._count++; // properties per transition
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // make 0 async and fire events
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass dur = ((typeof config.duration != 'undefined') ? config.duration :
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._duration) || 0.0001;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass attrs[prop] = {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value: val,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass duration: dur,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass delay: (typeof config.delay != 'undefined') ? config.delay :
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._delay,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass easing: config.easing || anim._easing,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass transition: anim
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass };
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // native end event doesnt fire when setting to same value
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // supplementing with timer
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // val may be a string or number (height: 0, etc), but computedStyle is always string
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass computed = Y.DOM.getComputedStyle(node, prop);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass compareVal = (typeof val === 'string') ? computed : parseFloat(computed);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (Transition.useNative && compareVal === val) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass setTimeout(function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._onNativeEnd.call(node, {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass propertyName: prop,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass elapsedTime: dur
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass });
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }, dur * 1000);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass removeProperty: function(prop) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var anim = this,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass attrs = Transition._nodeAttrs[Y.stamp(anim._node)];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (attrs && attrs[prop]) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass delete attrs[prop];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._count--;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass initAttrs: function(config) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var attr,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass node = this._node;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (config.transform && !config[TRANSFORM_CAMEL]) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config[TRANSFORM_CAMEL] = config.transform;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass delete config.transform; // TODO: copy
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass for (attr in config) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (config.hasOwnProperty(attr) && !Transition._reKeywords.test(attr)) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this.addProperty(attr, config[attr]);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // when size is auto or % webkit starts from zero instead of computed
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // (https://bugs.webkit.org/show_bug.cgi?id=16020)
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // TODO: selective set
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (node.style[attr] === '') {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.DOM.setStyle(node, attr, Y.DOM.getComputedStyle(node, attr));
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass /**
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Starts or an animation.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @method run
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @private
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass */
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass run: function(callback) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var anim = this,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass node = anim._node,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config = anim._config,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass data = {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass type: 'transition:start',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config: config
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass };
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (!anim._running) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._running = true;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass //anim._node.fire('transition:start', data);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (config.on && config.on.start) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config.on.start.call(Y.one(node), data);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim.initAttrs(anim._config);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._callback = callback;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._start();
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return anim;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass _start: function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this._runNative();
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass _prepDur: function(dur) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass dur = parseFloat(dur);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return dur + 's';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass _runNative: function(time) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var anim = this,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass node = anim._node,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass uid = Y.stamp(node),
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass style = node.style,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass computed = getComputedStyle(node),
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass attrs = Transition._nodeAttrs[uid],
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass cssText = '',
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney cssTransition = computed[Transition._toCamel(TRANSITION_PROPERTY)],
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass transitionText = TRANSITION_PROPERTY + ': ',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass duration = TRANSITION_DURATION + ': ',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass easing = TRANSITION_TIMING_FUNCTION + ': ',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass delay = TRANSITION_DELAY + ': ',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass hyphy,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass attr,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass name;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // preserve existing transitions
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (cssTransition !== 'all') {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass transitionText += cssTransition + ',';
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney duration += computed[Transition._toCamel(TRANSITION_DURATION)] + ',';
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney easing += computed[Transition._toCamel(TRANSITION_TIMING_FUNCTION)] + ',';
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney delay += computed[Transition._toCamel(TRANSITION_DELAY)] + ',';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // run transitions mapped to this instance
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass for (name in attrs) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass hyphy = Transition._toHyphen(name);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass attr = attrs[name];
416ff6e8477a5950c56e04adea6abf838140a852Matt Sweeney if ((attr = attrs[name]) && attr.transition === anim) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (name in node.style) { // only native styles allowed
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass duration += anim._prepDur(attr.duration) + ',';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass delay += anim._prepDur(attr.delay) + ',';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass easing += (attr.easing) + ',';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass transitionText += hyphy + ',';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass cssText += hyphy + ': ' + attr.value + '; ';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this.removeProperty(name);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass transitionText = transitionText.replace(/,$/, ';');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass duration = duration.replace(/,$/, ';');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass easing = easing.replace(/,$/, ';');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass delay = delay.replace(/,$/, ';');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // only one native end event per node
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (!Transition._hasEnd[uid]) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass //anim._detach = Y.on(TRANSITION_END, anim._onNativeEnd, node);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass //node[ON_TRANSITION_END] = anim._onNativeEnd;
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney node.addEventListener(TRANSITION_END, anim._onNativeEnd, '');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Transition._hasEnd[uid] = true;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass //setTimeout(function() { // allow updates to apply (size fix, onstart, etc)
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass style.cssText += transitionText + duration + easing + delay + cssText;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass //}, 1);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass _end: function(elapsed) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var anim = this,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass node = anim._node,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass callback = anim._callback,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config = anim._config,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass data = {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass type: 'transition:end',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config: config,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass elapsedTime: elapsed
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass nodeInstance = Y.one(node);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._running = false;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._callback = null;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (node) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (config.on && config.on.end) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass setTimeout(function() { // IE: allow previous update to finish
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config.on.end.call(nodeInstance, data);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // nested to ensure proper fire order
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (callback) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass callback.call(nodeInstance, data);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }, 1);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else if (callback) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass setTimeout(function() { // IE: allow previous update to finish
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass callback.call(nodeInstance, data);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }, 1);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass //node.fire('transition:end', data);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass _endNative: function(name) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var node = this._node,
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney value = node.ownerDocument.defaultView.getComputedStyle(node, '')[Transition._toCamel(TRANSITION_PROPERTY)];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (typeof value === 'string') {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value = value.replace(new RegExp('(?:^|,\\s)' + name + ',?'), ',');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass value = value.replace(/^,|,$/, '');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass node.style[TRANSITION_CAMEL] = value;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass _onNativeEnd: function(e) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var node = this,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass uid = Y.stamp(node),
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass event = e,//e._event,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass name = Transition._toCamel(event.propertyName),
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass elapsed = event.elapsedTime,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass attrs = Transition._nodeAttrs[uid],
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass attr = attrs[name],
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim = (attr) ? attr.transition : null,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass data,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (anim) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim.removeProperty(name);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._endNative(name);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config = anim._config[name];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass data = {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass type: 'propertyEnd',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass propertyName: name,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass elapsedTime: elapsed,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config: config
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass };
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (config && config.on && config.on.end) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config.on.end.call(Y.one(node), data);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass //node.fire('transition:propertyEnd', data);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (anim._count <= 0) { // after propertyEnd fires
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._end(elapsed);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass destroy: function() {
416ff6e8477a5950c56e04adea6abf838140a852Matt Sweeney var anim = this,
416ff6e8477a5950c56e04adea6abf838140a852Matt Sweeney node = anim._node;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass /*
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (anim._detach) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim._detach.detach();
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass */
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass //anim._node[ON_TRANSITION_END] = null;
416ff6e8477a5950c56e04adea6abf838140a852Matt Sweeney if (node) {
416ff6e8477a5950c56e04adea6abf838140a852Matt Sweeney node.removeEventListener(TRANSITION_END, anim._onNativeEnd, false);
416ff6e8477a5950c56e04adea6abf838140a852Matt Sweeney anim._node = null;
416ff6e8477a5950c56e04adea6abf838140a852Matt Sweeney }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassY.Transition = Transition;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassY.TransitionNative = Transition; // TODO: remove
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass/**
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Animate one or more css properties to a given value. Requires the "transition" module.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * <pre>example usage:
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Y.one('#demo').transition({
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * duration: 1, // in seconds, default is 0.5
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * easing: 'ease-out', // default is 'ease'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * delay: '1', // delay start for 1 second, default is 0
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass *
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * height: '10px',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * width: '10px',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass *
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * opacity: { // per property
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * value: 0,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * duration: 2,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * delay: 2,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * easing: 'ease-in'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * });
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * </pre>
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @for Node
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @method transition
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {Object} config An object containing one or more style properties, a duration and an easing.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {Function} callback A function to run after the transition has completed.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass*/
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassY.Node.prototype.transition = function(name, config, callback) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass transitionAttrs = Transition._nodeAttrs[Y.stamp(this._node)],
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim = (transitionAttrs) ? transitionAttrs.transition || null : null,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass fxConfig,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass prop;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (typeof name === 'string') { // named effect, pull config from registry
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (typeof config === 'function') {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass callback = config;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config = null;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass fxConfig = Transition.fx[name];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (config && typeof config !== 'boolean') {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config = Y.clone(config);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass for (prop in fxConfig) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (fxConfig.hasOwnProperty(prop)) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (! (prop in config)) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config[prop] = fxConfig[prop];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config = fxConfig;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else { // name is a config, config is a callback or undefined
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass callback = config;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config = name;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (anim && !anim._running) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim.init(this, config);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim = new Transition(this._node, config);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass anim.run(callback);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassY.Node.prototype.show = function(name, config, callback) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this._show(); // show prior to transition
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (name && Y.Transition) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (typeof name !== 'string' && !name.push) { // named effect or array of effects supercedes default
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (typeof config === 'function') {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass callback = config;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config = name;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney name = Transition.SHOW_TRANSITION;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this.transition(name, config, callback);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass else if (name && !Y.Transition) { Y.log('unable to transition show; missing transition module', 'warn', 'node'); }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glassvar _wrapCallBack = function(anim, fn, callback) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (fn) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass fn.call(anim);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (callback) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass callback.apply(anim._node, arguments);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass };
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassY.Node.prototype.hide = function(name, config, callback) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (name && Y.Transition) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (typeof config === 'function') {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass callback = config;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config = null;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass callback = _wrapCallBack(this, this._hide, callback); // wrap with existing callback
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (typeof name !== 'string' && !name.push) { // named effect or array of effects supercedes default
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (typeof config === 'function') {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass callback = config;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass config = name;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
2e49faa8717cc2acbd7ab2aac237061848568a6cMatt Sweeney name = Transition.HIDE_TRANSITION;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this.transition(name, config, callback);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else if (name && !Y.Transition) { Y.log('unable to transition hide; missing transition module', 'warn', 'node'); // end if on nex
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this._hide();
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass/**
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Animate one or more css properties to a given value. Requires the "transition" module.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * <pre>example usage:
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Y.all('.demo').transition({
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * duration: 1, // in seconds, default is 0.5
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * easing: 'ease-out', // default is 'ease'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * delay: '1', // delay start for 1 second, default is 0
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass *
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * height: '10px',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * width: '10px',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass *
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * opacity: { // per property
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * value: 0,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * duration: 2,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * delay: 2,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * easing: 'ease-in'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * });
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * </pre>
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @for NodeList
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @method transition
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {Object} config An object containing one or more style properties, a duration and an easing.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {Function} callback A function to run after the transition has completed. The callback fires
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * once per item in the NodeList.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass*/
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassY.NodeList.prototype.transition = function(config, callback) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var nodes = this._nodes,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass i = 0,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass node;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass while ((node = nodes[i++])) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.one(node).transition(config, callback);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassY.Node.prototype.toggleView = function(name, on, callback) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this._toggles = this._toggles || [];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass callback = arguments[arguments.length - 1];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (typeof name == 'boolean') { // no transition, just toggle
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass on = name;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass name = null;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass name = name || Y.Transition.DEFAULT_TOGGLE;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (typeof on == 'undefined' && name in this._toggles) { // reverse current toggle
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass on = ! this._toggles[name];
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass on = (on) ? 1 : 0;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (on) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this._show();
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } else {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass callback = _wrapCallBack(this, this._hide, callback);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this._toggles[name] = on;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this.transition(Y.Transition.toggles[name][on], callback);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassY.NodeList.prototype.toggleView = function(name, on, callback) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var nodes = this._nodes,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass i = 0,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass node;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass while ((node = nodes[i++])) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.one(node).toggleView(name, on, callback);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass};
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassY.mix(Transition.fx, {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass fadeOut: {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass opacity: 0,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass duration: 0.5,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass easing: 'ease-out'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass fadeIn: {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass opacity: 1,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass duration: 0.5,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass easing: 'ease-in'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass sizeOut: {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass height: 0,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass width: 0,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass duration: 0.75,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass easing: 'ease-out'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass sizeIn: {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass height: function(node) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return node.get('scrollHeight') + 'px';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass width: function(node) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return node.get('scrollWidth') + 'px';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass duration: 0.5,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass easing: 'ease-in',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass on: {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass start: function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass var overflow = this.getStyle('overflow');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (overflow !== 'hidden') { // enable scrollHeight/Width
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this.setStyle('overflow', 'hidden');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this._transitionOverflow = overflow;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass },
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass end: function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (this._transitionOverflow) { // revert overridden value
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this.setStyle('overflow', this._transitionOverflow);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass delete this._transitionOverflow;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass }
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass});
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassY.mix(Transition.toggles, {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass size: ['sizeOut', 'sizeIn'],
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass fade: ['fadeOut', 'fadeIn']
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass});
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassTransition.DEFAULT_TOGGLE = 'fade';
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass}, '@VERSION@' ,{requires:['node-base']});