/**
Provides the implementation of view transitions for `Y.App.Transitions` in
browsers which support native CSS3 transitions.
@module app
@submodule app-transitions-native
@since 3.5.0
**/
/**
Provides the implementation of view transitions for `Y.App.Transitions` in
browsers which support native CSS3 transitions.
When this module is used, `Y.App.TransitionsNative` will automatically mix
itself in to `Y.App`.
@class App.TransitionsNative
@since 3.5.0
**/
function AppTransitionsNative() {}
// -- Protected Properties -------------------------------------------------
/**
Whether this app is currently transitioning its `activeView`.
@property _transitioning
@type Boolean
@default false
@protected
@since 3.5.0
**/
/**
A queue that holds pending calls to this app's `_uiTransitionActiveView()`
method.
@property _viewTransitionQueue
@type Array
@default []
@protected
@since 3.5.0
**/
// -- Lifecycle Methods ----------------------------------------------------
initializer: function () {
this._transitioning = false;
this._viewTransitionQueue = [];
// TODO: Consider the AOP approach that `Plugin.WidgetAnim` uses.
},
// -- Protected Methods ----------------------------------------------------
/**
Dequeues any pending calls to `_uiTransitionActiveView()`.
**Note:** When there is more than one queued transition, only the most
recent `activeView` change will be visually transitioned, while the others
will have their `transition` option overridden to `false`.
@method _dequeueActiveView
@protected
@since 3.5.0
**/
_dequeueActiveView: function () {
var queue = this._viewTransitionQueue,
if (transition) {
// When items are still left in the queue, override the transition
// so it does not run.
// Overrides `transition` option and splices in the new options.
}
}
},
/**
Returns an object containing a named fx for both `viewIn` and `viewOut`
based on the relationship between the specified `newView` and `oldView`.
@method _getFx
@param {View} newView The view being transitioned-in.
@param {View} oldView The view being transitioned-out.
@param {String} [transition] The preferred transition to use.
@return {Object} An object containing a named fx for both `viewIn` and
`viewOut`.
@protected
@since 3.5.0
**/
if (transition === false || !transitions) {
return null;
}
if (transition) {
return fx[transition];
}
}
}
},
/**
Queues calls to `_uiTransitionActiveView()` to make sure a currently running
transition isn't interrupted.
**Note:** This method prevents the default `_uiSetActiveView()` method from
running.
@method _queueActiveView
@protected
@since 3.5.0
**/
_queueActiveView: function () {
if (!this._transitioning) {
this._dequeueActiveView();
}
},
/**
Performs the actual change of this app's `activeView` by visually
transitioning between the `newView` and `oldView` using any specified
`options`.
The `newView` is attached to the app by rendering it to the `viewContainer`,
and making this app a bubble target of its events.
The `oldView` is detached from the app by removing it from the
`viewContainer`, and removing this app as a bubble target for its events.
The `oldView` will either be preserved or properly destroyed.
**Note:** This method overrides `_uiSetActiveView()` and provides all of its
functionality plus supports visual transitions. Also, the `activeView`
attribute is read-only and can be changed by calling the `showView()`
method.
@method _uiTransitionActiveView
@param {View} newView The View which is now this app's `activeView`.
@param {View} [oldView] The View which was this app's `activeView`.
@param {Object} [options] Optional object containing any of the following
properties:
@param {Function} [options.callback] Optional callback function to call
after new `activeView` is ready to use, the function will be passed:
@param {View} options.callback.view A reference to the new
`activeView`.
@param {Boolean} [options.prepend] Whether the new view should be
prepended instead of appended to the `viewContainer`.
@param {Boolean|String} [options.transition] Optional transition override.
A transition can be specified which will override the default, or
`false` for no transition.
@protected
@since 3.5.0
**/
// Quits early when to new and old views are the same.
this._transitioning = false;
return this._dequeueActiveView();
}
// when there's no transition to perform.
if (!fx) {
this._detachView(oldView);
this._transitioning = false;
return this._dequeueActiveView();
}
this._transitioning = true;
// Called when view transitions completed, if none were added this will
// run right away.
function complete() {
this._detachView(oldView);
this._transitioning = false;
return this._dequeueActiveView();
}
// Setup a new stack to run the view transitions in parallel.
fxConfig = {
};
// Transition the new view first to prevent a gap when sliding.
}
}
}
};
// -- Transition fx ------------------------------------------------------------
'app:fadeIn': {
opacity : 1,
duration: 0.3,
on: {
}
},
end: function () {
}
}
},
'app:fadeOut': {
opacity : 0,
duration: 0.3,
on: {
}
},
end: function () {
}
}
},
'app:slideLeft': {
duration : 0.3,
transform: 'translateX(-100%)',
on: {
start: function () {
this.setStyles({
opacity : 1,
transform: 'translateX(0%)'
});
},
end: function () {
}
}
},
'app:slideRight': {
duration : 0.3,
transform: 'translateX(0)',
on: {
start: function () {
this.setStyles({
opacity : 1,
transform: 'translateX(-100%)'
});
},
end: function () {
}
}
}
});
// -- Namespacae ---------------------------------------------------------------