File

projects/dvk/src/lib/dynamic-animations/dynamic-animations.service.ts

Description

This service is used to create a DynamicAnimationsHandler with the DynamicAnimationsService method.

The DynamicAnimationsHandler can be used to handle animations based on state transitions for the specified element.

The DynamicAnimationsHandler can be wired up to a particular component or directive to automatically handle the animations for the specified element.

Index

Methods

Constructor

constructor(animationsHandlerConstructor: DynamicAnimationsHandlerConstructor, cssMapperService: StateCssMapperService, animationStatesBuilder: AnimationStatesService)
Parameters :
Name Type Optional
animationsHandlerConstructor DynamicAnimationsHandlerConstructor no
cssMapperService StateCssMapperService no
animationStatesBuilder AnimationStatesService no

Methods

createAnimationsHandler
createAnimationsHandler(element: any, initialState: string, transitions: AnimationTransitionsMap, styles: AnimationStylesMap, cssMap: StateCSSMap)

Create a DynamicAnimationsHandler for the given element.

See DynamicAnimationsService for example usage.

Parameters :
Name Type Optional Default value Description
element any no

The element to attach the animations handler to.

initialState string no

The initial state of the AnimationStateMachine

transitions AnimationTransitionsMap no

The AnimationTransitionsMap for the AnimationStateMachine

styles AnimationStylesMap no

The AnimationStylesMap for the AnimationStateMachine

cssMap StateCSSMap no {}

The StateCSSMap for the AnimationStateMachine

Returns : any
import { StateCSSMap } from './state-css-map/state-css-map.model';
import { AnimationTransitionsMap, AnimationStylesMap } from './animation-transitions/animation-transitions.model';
import { Injectable, Inject } from '@angular/core';
import { DynamicAnimationsHandlerConstructor } from './dynamic-animations-handler/dynamic-animations-handler.constructor';
import { DynamicAnimationsHandlerConstructorToken } from './dynamic-animations-handler/dynamic-animations-handler.token';
import { StateCssMapperService } from './state-css-mapper/state-css-mapper.service';
import { AnimationStatesService } from './animation-states/animation-states.service';

/**
 * This import is required for ts to resolve the return of 
 * the createAnimationsHandler function.  Without it compilation
 * will fail.
 */
import { DynamicAnimationsHandler } from './dynamic-animations-handler/dynamic-animations-handler.model';

/**
 * This service is used to create a {@link DynamicAnimationsHandler} 
 * with the {@link DynamicAnimationsService#createAnimationsHandler} method.
 * 
 * The {@link DynamicAnimationsHandler} 
 * can be used to handle animations based on state transitions
 * for the specified element.
 * 
 * The {@link DynamicAnimationsHandler} can be wired up to a 
 * particular component or directive to automatically handle 
 * the animations for the specified element.
 *
 */
@Injectable()
export class DynamicAnimationsService {

  constructor(
    @Inject(DynamicAnimationsHandlerConstructorToken) 
    private animationsHandlerConstructor: DynamicAnimationsHandlerConstructor,
    private cssMapperService: StateCssMapperService,
    private animationStatesBuilder: AnimationStatesService,
  ) { }

  /**
   * Create a {@link DynamicAnimationsHandler} for 
   * the given element.
   * 
   * See {@link DynamicAnimationsService} for example
   * usage.
   * 
   * @param element The element to attach the animations
   * handler to. 
   * 
   * @param initialState The initial state of the AnimationStateMachine
   * @param transitions The AnimationTransitionsMap for the AnimationStateMachine
   * @param styles The AnimationStylesMap for the AnimationStateMachine
   * @param cssMap The StateCSSMap for the AnimationStateMachine
   * 
   */
  createAnimationsHandler(
    element: any, 
    initialState: string, 
    transitions: AnimationTransitionsMap, 
    styles: AnimationStylesMap,
    cssMap: StateCSSMap = {}) {

      return new this.animationsHandlerConstructor(
        element,
        initialState,
        transitions,
        styles,
        cssMap,
        this.cssMapperService,
        this.animationStatesBuilder);
  }
}

results matching ""

    No results matching ""