fix(animations): throw errors and normalize offset beyond the range of [0,1]

Closes #13348
Closes #13440
This commit is contained in:
Matias Niemelä
2016-12-12 15:22:16 -08:00
committed by Victor Berchet
parent 8395f0e138
commit b56474d067
4 changed files with 76 additions and 1 deletions

View File

@ -85,6 +85,22 @@ export function main() {
elm, startingStyles, styles, 1000, 1000, null, <AnimationPlayer[]>previousPlayers);
expect(player.previousStyles).toEqual({});
});
it('should round down offset values that are bigger than 1', () => {
const startingStyles = _makeStyles({});
const styles = [_makeKeyframe(0, {}), _makeKeyframe(2, {})];
const player = driver.animate(elm, startingStyles, styles, 1000, 1000, null);
expect(player.keyframes.pop()['offset']).toEqual(1);
});
it('should round down offset values that are bigger less than 0', () => {
const startingStyles = _makeStyles({});
const styles = [_makeKeyframe(-99, {}), _makeKeyframe(-0.1, {}), _makeKeyframe(1, {})];
const player = driver.animate(elm, startingStyles, styles, 1000, 1000, null);
player.keyframes.pop(); // remove the final keyframe that is `1`
const allZero = player.keyframes.every(kf => kf['offset'] == 0);
expect(allZero).toBe(true);
});
});
}