-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! feat(ivy): enhance [style] and [class] bindings to be animatio…
…n aware
- Loading branch information
Showing
24 changed files
with
328 additions
and
344 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
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,89 @@ | ||
/** | ||
* @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 | ||
*/ | ||
|
||
/** | ||
* A shared interface which contains an animation player | ||
*/ | ||
export interface Player { | ||
parent?: Player|null; | ||
state: PlayState; | ||
play(): void; | ||
pause(): void; | ||
finish(): void; | ||
destroy(): void; | ||
addEventListener(state: PlayState|string, cb: (data?: any) => any): void; | ||
} | ||
|
||
export abstract class PlayerFactory { | ||
public dirty !: boolean; | ||
abstract buildPlayer(existingPlayer?: Player|null): Player|null; | ||
} | ||
|
||
/** | ||
* The state of a given player | ||
* | ||
* Do not change the increasing nature of the numbers since the player | ||
* code may compare state by checking if a number is higher or lower than | ||
* a certain numeric value. | ||
*/ | ||
export const enum PlayState {Pending = 0, Running = 1, Paused = 2, Finished = 100, Destroyed = 200} | ||
|
||
/** | ||
* The context that stores all the active players and queued player factories present on an element. | ||
*/ | ||
export interface PlayerContext extends Array<null|number|Player|PlayerFactory> { | ||
[PlayerIndex.NonFactoryPlayersStart]: number; | ||
[PlayerIndex.ClassMapFactoryPosition]: PlayerFactory|null; | ||
[PlayerIndex.ClassMapPlayerPosition]: Player|null; | ||
[PlayerIndex.StyleMapFactoryPosition]: PlayerFactory|null; | ||
[PlayerIndex.StyleMapPlayerPosition]: Player|null; | ||
} | ||
|
||
/** | ||
* Designed to be used as an injection service to capture all animation players. | ||
* | ||
* When present all animation players will be passed into the flush method below. | ||
* This feature is designed to service application-wide animation testing, live | ||
* debugging as well as custom animation choreographing tools. | ||
*/ | ||
export interface PlayerHandler { | ||
/** | ||
* Designed to kick off the player at the end of change detection | ||
*/ | ||
flushPlayers(): void; | ||
|
||
/** | ||
* @param player The player that has been scheduled to run within the application. | ||
* @param context The context as to where the player was bound to | ||
*/ | ||
queuePlayer(player: Player, context: ComponentInstance|DirectiveInstance|HTMLElement): void; | ||
} | ||
|
||
export const enum PlayerIndex { | ||
// The position where the index that reveals where players start in the PlayerContext | ||
NonFactoryPlayersStart = 0, | ||
// The position where the factory to handle a {key:value} map expression for classes | ||
ClassMapFactoryPosition = 1, | ||
// The position where the last player assigned to the class factory is stored | ||
ClassMapPlayerPosition = 2, | ||
// The position where the factory to handle a {key:value} map expression for styles | ||
StyleMapFactoryPosition = 3, | ||
// The position where the last player assigned to the style factory is stored | ||
StyleMapPlayerPosition = 4, | ||
// The position where any factories start in the PlayerContext | ||
FactoriesStartPosition = 1, | ||
// The position where non map-based factories start in the PlayerContext | ||
SingleFactoriesStartPosition = 5, | ||
// For each factory there is a player in the player context (therefore size = 2) | ||
PlayerAndFactoryTupleSize = 2, | ||
// The player exists next to the factory in the list | ||
PlayerOffsetPosition = 1, | ||
} | ||
|
||
export declare type ComponentInstance = {}; | ||
export declare type DirectiveInstance = {}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @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 './ng_dev_mode'; | ||
|
||
import {getContext} from './context_discovery'; | ||
import {getRootContext} from './discovery_utils'; | ||
import {scheduleTick} from './instructions'; | ||
import {ComponentInstance, DirectiveInstance, Player} from './interfaces/player'; | ||
import {RootContextFlags} from './interfaces/view'; | ||
import {EMPTY_ARR, addPlayerInternal, getOrCreatePlayerContext, getPlayerContext, getPlayersInternal, getStylingContext, throwInvalidRefError} from './styling/util'; | ||
|
||
export function addPlayer( | ||
ref: ComponentInstance | DirectiveInstance | HTMLElement, player: Player): void { | ||
const context = getContext(ref); | ||
if (!context) { | ||
ngDevMode && throwInvalidRefError(); | ||
return; | ||
} | ||
|
||
const element = context.native as HTMLElement; | ||
const lViewData = context.lViewData; | ||
const playerContext = getOrCreatePlayerContext(element, context) !; | ||
const rootContext = getRootContext(lViewData); | ||
addPlayerInternal(playerContext, rootContext, element, player, 0, ref); | ||
scheduleTick(getRootContext(lViewData), RootContextFlags.FlushPlayers); | ||
} | ||
|
||
export function getPlayers(ref: ComponentInstance | DirectiveInstance | HTMLElement): Player[] { | ||
const context = getContext(ref); | ||
if (!context) { | ||
ngDevMode && throwInvalidRefError(); | ||
return EMPTY_ARR; | ||
} | ||
|
||
const stylingContext = getStylingContext(context.lViewData, context.lNodeIndex); | ||
const playerContext = stylingContext ? getPlayerContext(stylingContext) : null; | ||
return playerContext ? getPlayersInternal(playerContext) : EMPTY_ARR; | ||
} |
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
Oops, something went wrong.