fix(animations): error when setting position before starting animation (#28255)
it is now possible to set the position when the animation has not ever been started. PR Close #28255
This commit is contained in:
parent
09e1e1935a
commit
3b7d2ca179
@ -156,6 +156,9 @@ export class WebAnimationsPlayer implements AnimationPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setPosition(p: number): void {
|
setPosition(p: number): void {
|
||||||
|
if (this.domPlayer === undefined) {
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
this.domPlayer.currentTime = p * this.time;
|
this.domPlayer.currentTime = p * this.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +67,27 @@ import {WebAnimationsPlayer} from '../../../src/render/web_animations/web_animat
|
|||||||
player.finish();
|
player.finish();
|
||||||
expect(log).toEqual(['started', 'done']);
|
expect(log).toEqual(['started', 'done']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should allow setting position before animation is started', () => {
|
||||||
|
const player = new WebAnimationsPlayer(element, [], {duration: 1000});
|
||||||
|
|
||||||
|
player.setPosition(0.5);
|
||||||
|
const p = innerPlayer!;
|
||||||
|
expect(p.log).toEqual(['pause']);
|
||||||
|
expect(p.currentTime).toEqual(500);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should continue playing animations from setPosition', () => {
|
||||||
|
const player = new WebAnimationsPlayer(element, [], {duration: 1000});
|
||||||
|
|
||||||
|
player.play();
|
||||||
|
const p = innerPlayer!;
|
||||||
|
expect(p.log).toEqual(['play']);
|
||||||
|
|
||||||
|
player.setPosition(0.5);
|
||||||
|
expect(p.currentTime).toEqual(500);
|
||||||
|
expect(p.log).toEqual(['play']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user