Skip to content

Commit

Permalink
Assorted transition fixes.
Browse files Browse the repository at this point in the history
- Fixes bug where transitions were failing to revert to implied layouts (my bad).
- Adds layoutProperties list to slide transitions.
- Fixes layoutProperties on slide transitions which was fixing transitioned properties at opacity: 1, overriding CSS (e.g. from isEnabled).
- Fixes bug where transitions were caching 0-value properties as null (my bad).
  • Loading branch information
dcporter committed Jan 14, 2014
1 parent cb3e19b commit 6891997
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
32 changes: 16 additions & 16 deletions frameworks/core_foundation/views/view/statechart.js
Expand Up @@ -1639,35 +1639,35 @@ SC.CoreView.reopen(
this._preTransitionFrame = this.get('borderFrame');
// Cache appropriate layout values.
var layoutProperties = SC.get(transition, 'layoutProperties');
// If the transition doesn't specify layoutProperties, cache all of them.
if (!layoutProperties) {
this._transitionLayoutCache = layout;
}
// Otherwise, cache just the specified ones.
else {
// If the transition specifies any layouts, cache them.
if (layoutProperties && layoutProperties.length) {
this._transitionLayoutCache = {};
var i, prop, len = layoutProperties.length;
for (i = 0; i < len; i++) {
prop = layoutProperties[i];
this._transitionLayoutCache[prop] = layout[prop] || null;
this._transitionLayoutCache[prop] = layout[prop] === undefined ? null : layout[prop];
}
}
},

/** @private */
_teardownTransition: function () {
// Some transition plugins will send a didTransitionIn/Out event even
// if the transition was cancelled. In either case, the transition can't
// be cleaned up multiple times.
// Make sure this isn't being called twice for the same transition. For example,
// some transition plugins will send a didTransitionIn/Out event even if the
// transition was cancelled.

// If we have a hash of cached layout properties, adjust back to it.
if (this._transitionLayoutCache) {
// Reset the layout with its cached values.
this.adjust(this._transitionLayoutCache);

// Clean up.
this._preTransitionLayout = null;
this._preTransitionFrame = null;
this._transitionLayoutCache = null;
}
// Otherwise, just set the layout back to what it was.
else if (this._preTransitionLayout) {
this.set('layout', this._preTransitionLayout);
}
// Clean up.
this._preTransitionLayout = null;
this._preTransitionFrame = null;
this._transitionLayoutCache = null;
},

/** @private Attempts to run a transition hide, ensuring any incoming transitions are stopped in place. */
Expand Down
4 changes: 2 additions & 2 deletions frameworks/foundation/transitions/fade_transition.js
Expand Up @@ -16,8 +16,8 @@ SC.mixin(SC.View,
*/
FADE_IN: {

/* @private Empty because we don't even need to reset opacity at the end: it ends up at 1. */
layoutProperties: [],
/* @private */
layoutProperties: ['opacity'],

/** @private */
setup: function (view, options, inPlace) {
Expand Down
4 changes: 4 additions & 0 deletions frameworks/foundation/transitions/slide_transition.js
Expand Up @@ -16,6 +16,8 @@ SC.mixin(SC.View,
*/
SLIDE_IN: {

layoutProperties: ['top', 'bottom', 'left', 'right', 'height', 'width'],

This comment has been minimized.

Copy link
@nicolasbadia

nicolasbadia Jan 18, 2014

Member

I think it misses centerX and centerY. Same for SLIDE_OUT.

This comment has been minimized.

Copy link
@dcporter

dcporter Jan 21, 2014

Author Member

Fixed this, thanks.


/** @private Starts from outside of parent unless inPlace is true. */
setup: function (view, options, inPlace) {
var parentView = view.get('parentView'),
Expand Down Expand Up @@ -86,6 +88,8 @@ SC.mixin(SC.View,
*/
SLIDE_OUT: {

layoutProperties: ['top', 'bottom', 'left', 'right', 'height', 'width'],

/** @private Starts from current position. */
setup: function (view, options) {
var viewFrame = view.get('borderFrame'),
Expand Down

0 comments on commit 6891997

Please sign in to comment.