CSSProperty.d.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import type { DisplayObject } from '../display-objects';
  2. import type { IElement } from '../dom';
  3. import type { StyleValueRegistry } from './interfaces';
  4. export type CSSPropertySyntaxFactory = <P, U>(syntax: string) => CSSProperty<P, U>;
  5. export type Interpolatable = number | boolean | number[] | boolean[];
  6. type CSSPropertyMixer<Parsed = any, T extends Interpolatable = any> = (left: Parsed, right: Parsed, displayObject: IElement | null) => [T, T, (i: T) => string | any] | undefined;
  7. type CSSPropertyParser<Parsed> = (value: string | any, object: DisplayObject) => Parsed;
  8. type CSSPropertyCalculator<Parsed, Used> = (name: string, oldParsed: Parsed, parsed: Parsed, object: IElement, registry: StyleValueRegistry) => Used;
  9. /**
  10. * 1. parser: raw CSS string -> Computed Value
  11. * 2. calculator: Computed Value -> Used Value
  12. * 3. mixer(in animation system): Used Value -> new Used Value
  13. * 4. post processor
  14. */
  15. export interface CSSProperty<Parsed, Used> {
  16. /**
  17. * parse CSS string to CSSStyleValue
  18. *
  19. * @example
  20. * '10' -> CSS.number(10)
  21. * '10px' -> CSS.px(10)
  22. * '180deg' -> CSS.deg(180)
  23. */
  24. parser: CSSPropertyParser<Parsed>;
  25. parserWithCSSDisabled: CSSPropertyParser<Parsed>;
  26. /**
  27. * convert parsed value to used value.
  28. * eg. in `lineWidth`, convert [CSSUnitValue] to [CSSUnitValue, CSSUnitValue]
  29. *
  30. * in Blink, it convert a CSSValue to an appropriate platform value
  31. */
  32. calculator: CSSPropertyCalculator<Parsed, Used>;
  33. /**
  34. * used with interpolation in animation system
  35. */
  36. mixer: CSSPropertyMixer<Used>;
  37. preProcessor: (object: IElement) => void;
  38. /**
  39. * eg. update local position after x/y/z caculated
  40. */
  41. postProcessor: (object: IElement, attributes: string[]) => void;
  42. }
  43. export {};
  44. //# sourceMappingURL=CSSProperty.d.ts.map