Skip to content

Commit

Permalink
fix(animation): set property defaults to avoid inconsistencies (ionic…
Browse files Browse the repository at this point in the history
…-team#19321)

* set defaults to avoid inconsistencies

* update test
  • Loading branch information
liamdebeasi authored Sep 11, 2019
1 parent e627804 commit 1cbb52c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
12 changes: 6 additions & 6 deletions core/src/utils/animation/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export const createAnimation = () => {
if (_fill !== undefined) { return _fill; }
if (parentAnimation) { return parentAnimation.getFill(); }

return undefined;
return 'both';
};

/**
Expand All @@ -303,7 +303,7 @@ export const createAnimation = () => {
if (_direction !== undefined) { return _direction; }
if (parentAnimation) { return parentAnimation.getDirection(); }

return undefined;
return 'normal';

};

Expand All @@ -315,7 +315,7 @@ export const createAnimation = () => {
if (_easing !== undefined) { return _easing; }
if (parentAnimation) { return parentAnimation.getEasing(); }

return undefined;
return 'linear';
};

/**
Expand All @@ -327,7 +327,7 @@ export const createAnimation = () => {
if (_duration !== undefined) { return _duration; }
if (parentAnimation) { return parentAnimation.getDuration(); }

return undefined;
return 0;
};

/**
Expand All @@ -337,7 +337,7 @@ export const createAnimation = () => {
if (_iterations !== undefined) { return _iterations; }
if (parentAnimation) { return parentAnimation.getIterations(); }

return undefined;
return 1;
};

/**
Expand All @@ -348,7 +348,7 @@ export const createAnimation = () => {
if (_delay !== undefined) { return _delay; }
if (parentAnimation) { return parentAnimation.getDelay(); }

return undefined;
return 0;
};

/**
Expand Down
32 changes: 16 additions & 16 deletions core/src/utils/animation/test/animation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,17 @@ describe('Animation Class', () => {
animation = createAnimation();
});

it('should get undefined when easing not set', () => {
expect(animation.getEasing()).toEqual(undefined);
it('should get "linear" when easing not set', () => {
expect(animation.getEasing()).toEqual("linear");
});

it('should get parent easing when child easing is not set', () => {
const childAnimation = createAnimation();
animation
.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', () => {
Expand All @@ -185,8 +185,8 @@ describe('Animation Class', () => {
expect(animation.getEasing()).toEqual('ease-in-out');
});

it('should get undefined when duration not set', () => {
expect(animation.getDuration()).toEqual(undefined);
it('should get 0 when duration not set', () => {
expect(animation.getDuration()).toEqual(0);
});

it('should get parent duration when child duration is not set', () => {
Expand All @@ -209,8 +209,8 @@ describe('Animation Class', () => {
expect(childAnimation.getDuration()).toEqual(500);
});

it('should get undefined when delay not set', () => {
expect(animation.getDelay()).toEqual(undefined);
it('should get 0 when delay not set', () => {
expect(animation.getDelay()).toEqual(0);
});

it('should get parent delay when child delay is not set', () => {
Expand All @@ -233,8 +233,8 @@ describe('Animation Class', () => {
expect(childAnimation.getDelay()).toEqual(500);
});

it('should get undefined when iterations not set', () => {
expect(animation.getIterations()).toEqual(undefined);
it('should get 1 when iterations not set', () => {
expect(animation.getIterations()).toEqual(1);
});

it('should get parent iterations when child iterations is not set', () => {
Expand All @@ -257,17 +257,17 @@ describe('Animation Class', () => {
expect(childAnimation.getIterations()).toEqual(2);
});

it('should get undefined when fill not set', () => {
expect(animation.getFill()).toEqual(undefined);
it('should get "both" when fill not set', () => {
expect(animation.getFill()).toEqual("both");
});

it('should get parent fill when child fill is not set', () => {
const childAnimation = createAnimation();
animation
.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', () => {
Expand All @@ -281,8 +281,8 @@ describe('Animation Class', () => {
expect(childAnimation.getFill()).toEqual('none');
});

it('should get undefined when direction not set', () => {
expect(animation.getDirection()).toEqual(undefined);
it('should get "normal" when direction not set', () => {
expect(animation.getDirection()).toEqual('normal');
});

it('should get parent direction when child direction is not set', () => {
Expand Down
1 change: 1 addition & 0 deletions core/src/utils/animation/test/multiple/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@

rootAnimation
.addAnimation([animationA, animationB, animationC])
.fill('none')
.onFinish(() => {
const ev = new CustomEvent('ionAnimationFinished', { detail: 'AnimationRootFinished' });
squareA.dispatchEvent(ev);
Expand Down

0 comments on commit 1cbb52c

Please sign in to comment.