-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(animations): repair flicker issues with WA polyfill (#16937)
- Loading branch information
Showing
7 changed files
with
85 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
62 changes: 62 additions & 0 deletions
62
packages/animations/browser/test/render/web_animations/web_animations_player_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
import {DOMAnimation} from '../../../src/render/web_animations/dom_animation'; | ||
import {WebAnimationsPlayer} from '../../../src/render/web_animations/web_animations_player'; | ||
|
||
export function main() { | ||
let element: any; | ||
let innerPlayer: MockDomAnimation|null = null; | ||
beforeEach(() => { | ||
element = {}; | ||
element['animate'] = () => { return innerPlayer = new MockDomAnimation(); }; | ||
}); | ||
|
||
describe('WebAnimationsPlayer tests', () => { | ||
it('should automatically pause the player when created and initialized', () => { | ||
const keyframes = [ | ||
{opacity: 0, offset: 0}, | ||
{opacity: 1, offset: 1}, | ||
]; | ||
|
||
const player = new WebAnimationsPlayer(element, keyframes, {duration: 1000}); | ||
|
||
player.init(); | ||
const p = innerPlayer !; | ||
expect(p.log).toEqual(['pause']); | ||
|
||
player.play(); | ||
expect(p.log).toEqual(['pause', 'play']); | ||
}); | ||
|
||
it('should not pause the player if created and started before initialized', () => { | ||
const keyframes = [ | ||
{opacity: 0, offset: 0}, | ||
{opacity: 1, offset: 1}, | ||
]; | ||
|
||
const player = new WebAnimationsPlayer(element, keyframes, {duration: 1000}); | ||
|
||
player.play(); | ||
const p = innerPlayer !; | ||
expect(p.log).toEqual(['play']); | ||
}); | ||
}); | ||
} | ||
|
||
class MockDomAnimation implements DOMAnimation { | ||
log: string[] = []; | ||
cancel(): void { this.log.push('cancel'); } | ||
play(): void { this.log.push('play'); } | ||
pause(): void { this.log.push('pause'); } | ||
finish(): void { this.log.push('finish'); } | ||
onfinish: Function = () => {}; | ||
position: number = 0; | ||
currentTime: number = 0; | ||
addEventListener(eventName: string, handler: (event: any) => any): any {} | ||
dispatchEvent(eventName: string): any {} | ||
} |