mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 11:17:19 +08:00
fix(animation): set property defaults to avoid inconsistencies (#19321)
* set defaults to avoid inconsistencies * update test
This commit is contained in:
@ -292,7 +292,7 @@ export const createAnimation = () => {
|
|||||||
if (_fill !== undefined) { return _fill; }
|
if (_fill !== undefined) { return _fill; }
|
||||||
if (parentAnimation) { return parentAnimation.getFill(); }
|
if (parentAnimation) { return parentAnimation.getFill(); }
|
||||||
|
|
||||||
return undefined;
|
return 'both';
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -303,7 +303,7 @@ export const createAnimation = () => {
|
|||||||
if (_direction !== undefined) { return _direction; }
|
if (_direction !== undefined) { return _direction; }
|
||||||
if (parentAnimation) { return parentAnimation.getDirection(); }
|
if (parentAnimation) { return parentAnimation.getDirection(); }
|
||||||
|
|
||||||
return undefined;
|
return 'normal';
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ export const createAnimation = () => {
|
|||||||
if (_easing !== undefined) { return _easing; }
|
if (_easing !== undefined) { return _easing; }
|
||||||
if (parentAnimation) { return parentAnimation.getEasing(); }
|
if (parentAnimation) { return parentAnimation.getEasing(); }
|
||||||
|
|
||||||
return undefined;
|
return 'linear';
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -327,7 +327,7 @@ export const createAnimation = () => {
|
|||||||
if (_duration !== undefined) { return _duration; }
|
if (_duration !== undefined) { return _duration; }
|
||||||
if (parentAnimation) { return parentAnimation.getDuration(); }
|
if (parentAnimation) { return parentAnimation.getDuration(); }
|
||||||
|
|
||||||
return undefined;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -337,7 +337,7 @@ export const createAnimation = () => {
|
|||||||
if (_iterations !== undefined) { return _iterations; }
|
if (_iterations !== undefined) { return _iterations; }
|
||||||
if (parentAnimation) { return parentAnimation.getIterations(); }
|
if (parentAnimation) { return parentAnimation.getIterations(); }
|
||||||
|
|
||||||
return undefined;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -348,7 +348,7 @@ export const createAnimation = () => {
|
|||||||
if (_delay !== undefined) { return _delay; }
|
if (_delay !== undefined) { return _delay; }
|
||||||
if (parentAnimation) { return parentAnimation.getDelay(); }
|
if (parentAnimation) { return parentAnimation.getDelay(); }
|
||||||
|
|
||||||
return undefined;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,17 +151,17 @@ describe('Animation Class', () => {
|
|||||||
animation = createAnimation();
|
animation = createAnimation();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get undefined when easing not set', () => {
|
it('should get "linear" when easing not set', () => {
|
||||||
expect(animation.getEasing()).toEqual(undefined);
|
expect(animation.getEasing()).toEqual("linear");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get parent easing when child easing is not set', () => {
|
it('should get parent easing when child easing is not set', () => {
|
||||||
const childAnimation = createAnimation();
|
const childAnimation = createAnimation();
|
||||||
animation
|
animation
|
||||||
.addAnimation(childAnimation)
|
.addAnimation(childAnimation)
|
||||||
.easing('linear');
|
.easing('ease-in-out');
|
||||||
|
|
||||||
expect(childAnimation.getEasing()).toEqual('linear');
|
expect(childAnimation.getEasing()).toEqual('ease-in-out');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get prefer child easing over parent easing', () => {
|
it('should get prefer child easing over parent easing', () => {
|
||||||
@ -185,8 +185,8 @@ describe('Animation Class', () => {
|
|||||||
expect(animation.getEasing()).toEqual('ease-in-out');
|
expect(animation.getEasing()).toEqual('ease-in-out');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get undefined when duration not set', () => {
|
it('should get 0 when duration not set', () => {
|
||||||
expect(animation.getDuration()).toEqual(undefined);
|
expect(animation.getDuration()).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get parent duration when child duration is not set', () => {
|
it('should get parent duration when child duration is not set', () => {
|
||||||
@ -209,8 +209,8 @@ describe('Animation Class', () => {
|
|||||||
expect(childAnimation.getDuration()).toEqual(500);
|
expect(childAnimation.getDuration()).toEqual(500);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get undefined when delay not set', () => {
|
it('should get 0 when delay not set', () => {
|
||||||
expect(animation.getDelay()).toEqual(undefined);
|
expect(animation.getDelay()).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get parent delay when child delay is not set', () => {
|
it('should get parent delay when child delay is not set', () => {
|
||||||
@ -233,8 +233,8 @@ describe('Animation Class', () => {
|
|||||||
expect(childAnimation.getDelay()).toEqual(500);
|
expect(childAnimation.getDelay()).toEqual(500);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get undefined when iterations not set', () => {
|
it('should get 1 when iterations not set', () => {
|
||||||
expect(animation.getIterations()).toEqual(undefined);
|
expect(animation.getIterations()).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get parent iterations when child iterations is not set', () => {
|
it('should get parent iterations when child iterations is not set', () => {
|
||||||
@ -257,17 +257,17 @@ describe('Animation Class', () => {
|
|||||||
expect(childAnimation.getIterations()).toEqual(2);
|
expect(childAnimation.getIterations()).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get undefined when fill not set', () => {
|
it('should get "both" when fill not set', () => {
|
||||||
expect(animation.getFill()).toEqual(undefined);
|
expect(animation.getFill()).toEqual("both");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get parent fill when child fill is not set', () => {
|
it('should get parent fill when child fill is not set', () => {
|
||||||
const childAnimation = createAnimation();
|
const childAnimation = createAnimation();
|
||||||
animation
|
animation
|
||||||
.addAnimation(childAnimation)
|
.addAnimation(childAnimation)
|
||||||
.fill('both');
|
.fill('forwards');
|
||||||
|
|
||||||
expect(childAnimation.getFill()).toEqual('both');
|
expect(childAnimation.getFill()).toEqual('forwards');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get prefer child fill over parent fill', () => {
|
it('should get prefer child fill over parent fill', () => {
|
||||||
@ -281,8 +281,8 @@ describe('Animation Class', () => {
|
|||||||
expect(childAnimation.getFill()).toEqual('none');
|
expect(childAnimation.getFill()).toEqual('none');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get undefined when direction not set', () => {
|
it('should get "normal" when direction not set', () => {
|
||||||
expect(animation.getDirection()).toEqual(undefined);
|
expect(animation.getDirection()).toEqual('normal');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get parent direction when child direction is not set', () => {
|
it('should get parent direction when child direction is not set', () => {
|
||||||
|
@ -123,6 +123,7 @@
|
|||||||
|
|
||||||
rootAnimation
|
rootAnimation
|
||||||
.addAnimation([animationA, animationB, animationC])
|
.addAnimation([animationA, animationB, animationC])
|
||||||
|
.fill('none')
|
||||||
.onFinish(() => {
|
.onFinish(() => {
|
||||||
const ev = new CustomEvent('ionAnimationFinished', { detail: 'AnimationRootFinished' });
|
const ev = new CustomEvent('ionAnimationFinished', { detail: 'AnimationRootFinished' });
|
||||||
squareA.dispatchEvent(ev);
|
squareA.dispatchEvent(ev);
|
||||||
|
Reference in New Issue
Block a user