Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_adaptDimension: function(dimension, before, after) {
if (before[dimension] === after[dimension] || !this.get('enableGrowth')) {
var elt = this.$();
if (elt) {
elt[dimension](after[dimension]);
}
return Promise.resolve();
} else {
// Velocity deals in literal width/height, whereas jQuery deals
// in box-sizing-dependent measurements.
var target = {};
target[dimension] = [
after['literal'+capitalize(dimension)],
before['literal'+capitalize(dimension)],
];
return animate(this, target, {
duration: this._durationFor(before[dimension], after[dimension]),
queue: false,
easing: this.get('growEasing')
});
}
},
var overlay = jQuery('<div class="transition-overlay"></div>');
elementToOverlay.append(overlay);
if (dimension.toLowerCase() === 'x') {
property = 'translateX';
measure = 'width';
} else {
property = 'translateY';
measure = 'height';
}
if (isAnimating(this.oldElement, 'moving-in')) {
firstStep = finish(this.oldElement, 'moving-in');
} else {
stop(this.oldElement);
firstStep = Promise.resolve();
}
return firstStep.then(() => {
var bigger = biggestSize(this, measure);
this.oldElement[0].style.zIndex = direction > 0 ? 5 : 0;
this.newElement[0].style.zIndex = direction > 0 ? 0 : 5;
oldParams[property] = (bigger * (direction > 0 ? 1 : -0.5)) + 'px';
newParams[property] = ["0px", (bigger * (direction > 0 ? -0.5 : 1)) + 'px'];
return Promise.all([
animate(overlay, overlayParams, opts),
animate(this.oldElement, oldParams, opts),
animate(this.newElement, newParams, opts, 'moving-in')
]).then(() => overlay.remove());
export default function flyTo(opts={}) {
if (!this.newElement) {
return Promise.resolve();
} else if (!this.oldElement) {
this.newElement.css({visibility: ''});
return Promise.resolve();
}
var oldTarget = this.oldElement.find('.liquid-tether').length ?
this.oldElement.find('.liquid-tether').children().eq(0) :
this.oldElement;
var newTarget = this.newElement.find('.liquid-tether').length ?
this.newElement.find('.liquid-tether').children().eq(0) :
this.newElement;
var oldOffset = oldTarget.offset();
var newOffset = newTarget.offset();
export default function defaultTransition() {
if (this.newElement) {
this.newElement.css({visibility: ''});
}
if (this.newView) {
var view = getRealChildView(this.newView);
if (view && view.didAnimateTransition) {
view.didAnimateTransition();
}
}
return Promise.resolve();
}
var overlay = jQuery('<div class="transition-overlay"></div>');
this.oldElement.append(overlay);
if (dimension.toLowerCase() === 'x') {
property = 'translateX';
measure = 'width';
} else {
property = 'translateY';
measure = 'height';
}
if (isAnimating(this.oldElement, 'moving-in')) {
firstStep = finish(this.oldElement, 'moving-in');
} else {
stop(this.oldElement);
firstStep = Promise.resolve();
}
return firstStep.then(() => {
var bigger = biggestSize(this, measure);
this.oldElement[0].style.zIndex = direction > 0 ? 5 : 0;
this.newElement[0].style.zIndex = direction > 0 ? 0 : 5;
oldParams[property] = (bigger * (direction > 0 ? 1 : -0.5)) + 'px';
newParams[property] = ["0px", (bigger * (direction > 0 ? -0.5 : 1)) + 'px'];
return Promise.all([
animate(overlay, overlayParams, opts),
animate(this.oldElement, oldParams, opts),
animate(this.newElement, newParams, opts, 'moving-in')
]);
property,
measure;
if (dimension.toLowerCase() === 'x') {
property = 'translateX';
measure = 'width';
} else {
property = 'translateY';
measure = 'height';
}
if (isAnimating(this.oldElement, 'moving-in')) {
firstStep = finish(this.oldElement, 'moving-in');
} else {
stop(this.oldElement);
firstStep = Promise.resolve();
}
return firstStep.then(() => {
var bigger = biggestSize(this, measure);
oldParams[property] = (bigger * direction) + 'px';
newParams[property] = ["0px", (-1 * bigger * direction) + 'px'];
return Promise.all([
animate(this.oldElement, oldParams, opts),
animate(this.newElement, newParams, opts, 'moving-in')
]);
});
}
this.newElement.css({visibility: ''});
}
if (this.newView) {
const component = getComponent(this.newView);
if (component) {
if (component.didAnimateTransition) {
component.didAnimateTransition();
}
if (component.trigger) {
component.trigger('didAnimateTransition');
}
}
}
return Promise.resolve();
}
export function waitForPrevious(context, name) {
if (isAnimating(context.oldElement, name)) {
return finish(context.oldElement, name);
} else {
stop(context.oldElement);
return Promise.resolve();
}
}
return () => Promise.resolve();
}