Skip to content

Commit aaed4ff

Browse files
author
Rui Chen
committed
refactor: refactor to TypeScript
1 parent ea3d3bf commit aaed4ff

33 files changed

Lines changed: 2823 additions & 7633 deletions

dist/svg-text-animate.es.js

Lines changed: 416 additions & 489 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/svg-text-animate.es.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/svg-text-animate.es.min.js

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/svg-text-animate.js

Lines changed: 416 additions & 489 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/svg-text-animate.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/svg-text-animate.min.js

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types/config/config.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type { AnimationOptions, StrokeOptions } from '../types';
2+
export declare const DEFAULT_OPTIONS: Required<AnimationOptions>;
3+
export declare const DEFAULT_STROKE: Required<StrokeOptions>;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import type { AnimationOptions } from '../types';
2+
/**
3+
* Abstract class for animation creators
4+
* @abstract
5+
*/
6+
export default abstract class AnimationCreator {
7+
protected options: Required<AnimationOptions>;
8+
protected svgDom: SVGSVGElement | null;
9+
protected paths: NodeListOf<SVGPathElement> | null;
10+
/**
11+
* Creates an instance of AnimationCreator.
12+
* @param options - Animation options
13+
*/
14+
constructor(options?: AnimationOptions);
15+
/**
16+
* Set the svgDom
17+
* @param svgDom - SVG DOM element
18+
*/
19+
setSVGDom(svgDom: SVGSVGElement): void;
20+
/**
21+
* Set animation options
22+
* @param options - Animation options
23+
* @returns Current instance
24+
*/
25+
setOptions(options?: AnimationOptions): this;
26+
/**
27+
* Animate each path
28+
*/
29+
setAllPathsAnimation(): void;
30+
/**
31+
* Set the path stroke
32+
* @param path - SVG path element
33+
*/
34+
setPathStroke(path: SVGPathElement): void;
35+
/**
36+
* Function to set the SVG animation
37+
* Must be implemented in the inheritance class
38+
* @abstract
39+
*/
40+
abstract setSVGAnimation(): void;
41+
/**
42+
* Function to set the path animation
43+
* Must be implemented in the inheritance class
44+
* @abstract
45+
* @param path - SVG path element
46+
* @param i - Index of paths
47+
*/
48+
abstract setPathAnimation(path: SVGPathElement, i: number): void;
49+
/**
50+
* Function to format Options, using default options
51+
* Must be implemented in the inheritance class
52+
* @abstract
53+
* @param options - Options to format
54+
* @returns Formatted options
55+
*/
56+
abstract formatOptions(options: AnimationOptions | Required<AnimationOptions>): AnimationOptions | Required<AnimationOptions>;
57+
/**
58+
* Create animated SVG
59+
* @param svgDom - SVG DOM element
60+
* @returns Animated svgDom
61+
*/
62+
create(svgDom: SVGSVGElement): SVGSVGElement;
63+
}

dist/types/creator/CSSCreator.d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import AnimationCreator from './AnimationCreator';
2+
import type { AnimationOptions } from '../types';
3+
/**
4+
* CSS-based animation creator
5+
* @extends AnimationCreator
6+
*/
7+
export default class CSSCreator extends AnimationCreator {
8+
/**
9+
* Creates an instance of CSSCreator.
10+
* @param options - Animation options
11+
*/
12+
constructor(options?: AnimationOptions);
13+
/**
14+
* Function to set the SVG animation, using CSS animation
15+
*/
16+
setSVGAnimation(): void;
17+
/**
18+
* Function to set the path animation, using CSS animation
19+
* @param path - SVG path element
20+
* @param i - Index of paths
21+
*/
22+
setPathAnimation(path: SVGPathElement, i: number): void;
23+
/**
24+
* Function to format Options, using default options
25+
* @param options - Options of creator
26+
* @returns Formatted options
27+
*/
28+
formatOptions(options: AnimationOptions | Required<AnimationOptions>): AnimationOptions | Required<AnimationOptions>;
29+
}

dist/types/creator/SVGCreator.d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import AnimationCreator from './AnimationCreator';
2+
import type { AnimationOptions } from '../types';
3+
/**
4+
* SVG-based animation creator
5+
* @extends AnimationCreator
6+
*/
7+
export default class SVGCreator extends AnimationCreator {
8+
/**
9+
* Creates an instance of SVGCreator.
10+
* @param options - Animation options
11+
*/
12+
constructor(options?: AnimationOptions);
13+
/**
14+
* Function to set the SVG animation, using SVG animate elements
15+
*/
16+
setSVGAnimation(): void;
17+
/**
18+
* Function to set the path animation, using SVG animate elements
19+
* @param path - SVG path element
20+
* @param i - Index of paths
21+
*/
22+
setPathAnimation(path: SVGPathElement, i: number): void;
23+
/**
24+
* Function to format Options, using default options
25+
* @param options - Options of creator
26+
* @returns Formatted options
27+
*/
28+
formatOptions(options: AnimationOptions | Required<AnimationOptions>): AnimationOptions | Required<AnimationOptions>;
29+
}

0 commit comments

Comments
 (0)