A task is a function executed at the beginning of addAnimations,
before selector and properties information is processed,
and has the following goals:
Setup: A setup allows to prepare elements for further processing.
An example is text splitting. text splitting prepares DOM for individual
character manipulation.
Setup tasks can stop the processing of a addAnimations, and might not
require a selector..
Wrapping: Only addAnimations can be stored in a JSON file or sent
for remote rendering. In this case, methods such as addStills and scene transitions
need to be wrapped in a task.
Wrapping tasks can stop the processing of a addAnimations, and might not
require a selector.
Asset creation: A task can create an asset avoiding the need of loading external assets such as svg shape files.
Complex animations: A task can simplify the creation of a complex animation.
If you just want to do a single-shot animation, use scene.addAnimations,
but if you want to reuse the animation or want to break down the complexity
into multiple parts, the best is to create a task.
A task implementation is a function with the following syntax:
function myTaskFunc(anime: Animation, wkTask: WorkTask,
params: FactoryTaskParams, stage?: uint, args?: BeamToIXArgs): TaskResult;
And add this task to BeamToIX using BeamToIX.pluginManager.addTasks([['my-task', myTaskFunc]]);.
If the task just uses plain DOM, the simplest is to:
selector, and thenswitch (stage) {
case TS_INIT:
const adapters = args.scene.getElementAdapters(anime.selector);
elAdapters.forEach((elAdapter, elIndex) => {
const html = elAdapter.getProp('html', args);
const myPiece = '<div>Hello</div>';
elAdapter.setProp('html', html + myPiece, args);
});
}
switch (stage) {
case TS_INIT:
anime.props.push({ prop: 'text', value: ['hello'] });
}
public export type
export type TaskResult = 0 | 1 | 2;
public export type
export type TaskFunc = (anime: Animation, wkTask: WorkTask,
params?: AnyParams, stage?: uint, args?: BeamToIXArgs) => TaskResult;
public export type
export type TaskHandler = TaskName | TaskFunc;
public export type
export type TaskName = string
| GeneralTaskName
| TextTaskName
| ShapeTaskName
| AttackTaskName;
public export type
export type TaskParams = AnyParams
| GeneralTaskParams
| TextTaskParams
| ShapeTaskParams
| AttackTaskParams;
public export interface
export interface Task{ }
Parameters provided by the user during an addAnimation.
public property [Task]
handler: TaskHandler;
Task Name, Expression or Input Function defined by the user.
public property [Task]
params?: TaskParams;
Parameters passed to the task function
public export interface
export interface WorkTask{ }
Parameters passed to a task during the execution.
public property [WorkTask]
name: string;
public property [WorkTask]
params: TaskParams;
public property [WorkTask]
animeIndex: uint;
public export type
export type GeneralTaskName =
/** @see TaskFactoryParams */
| 'factory';
public export type
export type GeneralTaskParams =
| FactoryTaskParams;
public export type
export type FactoryTaskAttr = string | ExprString | number | string[] | number[];
public export interface
export interface FactoryTaskParams extends AnyParams{ }
public property [FactoryTaskParams]
count: uint | ExprString;
public property [FactoryTaskParams]
tag?: string;
public property [FactoryTaskParams]
content?: FactoryTaskAttr;
public property [FactoryTaskParams]
isContentFormatted?: boolean;
public property [FactoryTaskParams]
attrs?: {
name: string;