presenter 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -3
- package/dist/src/index.d.ts +15 -0
- package/dist/src/objects/arrow.d.ts +36 -0
- package/dist/src/objects/group.d.ts +16 -0
- package/dist/src/objects/image.d.ts +11 -0
- package/dist/src/objects/line.d.ts +13 -0
- package/dist/src/objects/paragraph.d.ts +17 -0
- package/dist/src/objects/polygon.d.ts +13 -0
- package/dist/src/objects/rectangle.d.ts +14 -0
- package/dist/src/objects/text.d.ts +29 -0
- package/dist/src/objects/vectorGraphic.d.ts +14 -0
- package/dist/src/presentation/object.d.ts +122 -0
- package/dist/src/presentation/presentation.d.ts +99 -0
- package/dist/src/presentation/slide.d.ts +23 -0
- package/dist/src/util/animation.d.ts +37 -0
- package/dist/src/util/position.d.ts +11 -0
- package/dist/src/util/richText.d.ts +18 -0
- package/dist/webpack.config.d.ts +1 -1
- package/package.json +8 -4
- package/.husky/pre-commit +0 -1
- package/.prettierrc +0 -1
- package/dist/dist/presenter.d.ts +0 -1
- package/tsconfig.json +0 -12
- package/webpack.config.js +0 -32
package/README.md
CHANGED
|
@@ -6,17 +6,35 @@ This library is still in development and its API may change at any time.
|
|
|
6
6
|
|
|
7
7
|
## Getting Started
|
|
8
8
|
|
|
9
|
-
###
|
|
9
|
+
### Quick Start
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
The simplest way to get started with a Presenter.js presentation is via
|
|
12
|
+
`npm create presenter`.
|
|
12
13
|
|
|
14
|
+
```bash
|
|
15
|
+
$ npm create presenter
|
|
13
16
|
```
|
|
17
|
+
|
|
18
|
+
Running `npm create presenter` will prompt you to enter a project name and will
|
|
19
|
+
then create a new presentation with Presenter.js, written in TypeScript and
|
|
20
|
+
built with Webpack.
|
|
21
|
+
|
|
22
|
+
After creating the new presentation, `cd` into the directory and run
|
|
23
|
+
`npm run serve` to run the presentation. Edit `src/index.ts` to make changes
|
|
24
|
+
to your presentation.
|
|
25
|
+
|
|
26
|
+
### Installing Presenter.js Manually
|
|
27
|
+
|
|
28
|
+
Presenter.js can also be installed manually via `npm`.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
14
31
|
$ npm install presenter
|
|
15
32
|
```
|
|
16
33
|
|
|
17
34
|
### Sample Usage
|
|
18
35
|
|
|
19
|
-
Create a presentation by specifying a list of slides, where each slide may
|
|
36
|
+
Create a presentation by specifying a list of slides, where each slide may
|
|
37
|
+
contain objects and animations.
|
|
20
38
|
|
|
21
39
|
```javascript
|
|
22
40
|
import { Presentation, Slide, Text } from "presenter";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./presentation/presentation";
|
|
2
|
+
export * from "./presentation/slide";
|
|
3
|
+
export * from "./presentation/object";
|
|
4
|
+
export * from "./objects/arrow";
|
|
5
|
+
export * from "./objects/group";
|
|
6
|
+
export * from "./objects/image";
|
|
7
|
+
export * from "./objects/line";
|
|
8
|
+
export * from "./objects/paragraph";
|
|
9
|
+
export * from "./objects/polygon";
|
|
10
|
+
export * from "./objects/text";
|
|
11
|
+
export * from "./objects/rectangle";
|
|
12
|
+
export * from "./objects/vectorGraphic";
|
|
13
|
+
export * from "./util/animation";
|
|
14
|
+
export * from "./util/position";
|
|
15
|
+
export * from "./util/richText";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ObjectProps, SlideObject } from "../presentation/object";
|
|
2
|
+
import { AnimationProps } from "../util/animation";
|
|
3
|
+
import { Position } from "../util/position";
|
|
4
|
+
import { Line } from "./line";
|
|
5
|
+
import { Polygon } from "./polygon";
|
|
6
|
+
export interface ArrowProps extends ObjectProps {
|
|
7
|
+
start: Position;
|
|
8
|
+
end: Position;
|
|
9
|
+
color: string;
|
|
10
|
+
width: number;
|
|
11
|
+
arrowSize: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class Arrow extends SlideObject<ArrowProps> {
|
|
14
|
+
line: Line | null;
|
|
15
|
+
arrowhead: Polygon | null;
|
|
16
|
+
constructor(props?: Partial<ArrowProps>);
|
|
17
|
+
tagName(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Computes coordinates for the line and arrowhead of the arrow.
|
|
20
|
+
*/
|
|
21
|
+
calculateShapes(props: ArrowProps): {
|
|
22
|
+
line: {
|
|
23
|
+
start: Position;
|
|
24
|
+
end: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
arrowhead: Position[];
|
|
30
|
+
};
|
|
31
|
+
children(): Node[];
|
|
32
|
+
/**
|
|
33
|
+
* Returns animations for changes in arrowhead.
|
|
34
|
+
*/
|
|
35
|
+
animations(arrowProps: Partial<ArrowProps>, animationParams?: anime.AnimeParams): AnimationProps[];
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ObjectProps, SlideObject } from "../presentation/object";
|
|
2
|
+
export interface GroupProps extends ObjectProps {
|
|
3
|
+
/**
|
|
4
|
+
* A positioned group places the group's anchor at a particular coordinate.
|
|
5
|
+
* A non-positioned group uses the position as an offset for its children.
|
|
6
|
+
*/
|
|
7
|
+
positioned: boolean;
|
|
8
|
+
objects: SlideObject<any>[];
|
|
9
|
+
}
|
|
10
|
+
export declare class Group extends SlideObject<GroupProps> {
|
|
11
|
+
constructor(objects: SlideObject<any>[], props?: Partial<GroupProps>, positioned?: boolean | null);
|
|
12
|
+
tagName(): string;
|
|
13
|
+
attributes(): Partial<Record<string, string>>;
|
|
14
|
+
additionalAttributes(): Partial<Record<string, string>>;
|
|
15
|
+
children(): Node[];
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ObjectProps, SlideObject } from "../presentation/object";
|
|
2
|
+
export interface ImageProps extends ObjectProps {
|
|
3
|
+
href: string;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class Image extends SlideObject<ImageProps> {
|
|
8
|
+
constructor(href: string, props?: Partial<ImageProps>);
|
|
9
|
+
tagName(): string;
|
|
10
|
+
attributes(): Partial<Record<string, string>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ObjectProps, SlideObject } from "../presentation/object";
|
|
2
|
+
import { Position } from "../util/position";
|
|
3
|
+
export interface LineProps extends ObjectProps {
|
|
4
|
+
start: Position;
|
|
5
|
+
end: Position;
|
|
6
|
+
color: string;
|
|
7
|
+
width: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class Line extends SlideObject<LineProps> {
|
|
10
|
+
constructor(props?: Partial<LineProps>);
|
|
11
|
+
tagName(): string;
|
|
12
|
+
attributes(): Partial<Record<string, string>>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ObjectProps, SlideObject } from "../presentation/object";
|
|
2
|
+
export interface ParagraphProps extends ObjectProps {
|
|
3
|
+
content: string | string[];
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
fontSize: number;
|
|
7
|
+
fontFamily: string;
|
|
8
|
+
color: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class Paragraph extends SlideObject<ParagraphProps> {
|
|
11
|
+
constructor(content: string | string[], props?: Partial<ParagraphProps>);
|
|
12
|
+
tagName(): string;
|
|
13
|
+
attributes(): Partial<Record<string, string>>;
|
|
14
|
+
children(): Node[];
|
|
15
|
+
additionalAttributes(): Partial<Record<string, string>>;
|
|
16
|
+
requiresChildrenUpdate(props: Partial<ParagraphProps>): boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ObjectProps, SlideObject } from "../presentation/object";
|
|
2
|
+
import { Position } from "../util/position";
|
|
3
|
+
export interface PolygonProps extends ObjectProps {
|
|
4
|
+
points: Position[];
|
|
5
|
+
fill: string;
|
|
6
|
+
borderWidth: number;
|
|
7
|
+
borderColor: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class Polygon extends SlideObject<PolygonProps> {
|
|
10
|
+
constructor(points: Position[], props?: Partial<PolygonProps>);
|
|
11
|
+
tagName(): string;
|
|
12
|
+
attributes(): Partial<Record<string, string>>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ObjectProps, SlideObject } from "../presentation/object";
|
|
2
|
+
export interface RectangleProps extends ObjectProps {
|
|
3
|
+
fill: string;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
rounding: number;
|
|
7
|
+
borderWidth: number;
|
|
8
|
+
borderColor: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class Rectangle extends SlideObject<RectangleProps> {
|
|
11
|
+
constructor(props?: Partial<RectangleProps>);
|
|
12
|
+
tagName(): string;
|
|
13
|
+
attributes(): Partial<Record<string, string>>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ObjectProps, SlideObject } from "../presentation/object";
|
|
2
|
+
import { RichTextSpan } from "../util/richText";
|
|
3
|
+
export type TextContent = string | (string | RichTextSpan[])[];
|
|
4
|
+
export interface TextProps extends ObjectProps {
|
|
5
|
+
content: TextContent;
|
|
6
|
+
fontStyle: string;
|
|
7
|
+
fontWeight: string | number;
|
|
8
|
+
fontSize: number;
|
|
9
|
+
fontFamily: string;
|
|
10
|
+
color: string;
|
|
11
|
+
dominantBaseline: string;
|
|
12
|
+
textDecoration: string;
|
|
13
|
+
align: "left" | "center" | "right";
|
|
14
|
+
lineSpacing: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class Text extends SlideObject<TextProps> {
|
|
17
|
+
constructor(content: TextContent, props?: Partial<TextProps>);
|
|
18
|
+
isRichText(): boolean;
|
|
19
|
+
tagName(): string;
|
|
20
|
+
attributes(): Partial<Record<string, string>>;
|
|
21
|
+
/**
|
|
22
|
+
* Text elements return position as additional attributes since computing text
|
|
23
|
+
* size and position requires other properties to be set first.
|
|
24
|
+
*/
|
|
25
|
+
additionalAttributes(): Partial<Record<string, string>>;
|
|
26
|
+
styles(): Partial<Record<string, string>>;
|
|
27
|
+
children(): Node[];
|
|
28
|
+
requiresChildrenUpdate(props: Partial<TextProps>): boolean;
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ObjectProps, SlideObject } from "../presentation/object";
|
|
2
|
+
export interface VectorGraphicProps extends ObjectProps {
|
|
3
|
+
svg: string;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class VectorGraphic extends SlideObject<VectorGraphicProps> {
|
|
8
|
+
parsedChildren: Node[];
|
|
9
|
+
constructor(svg: string, props?: Partial<VectorGraphicProps>);
|
|
10
|
+
tagName(): string;
|
|
11
|
+
createElement(): SVGElement;
|
|
12
|
+
attributes(): Partial<Record<string, string>>;
|
|
13
|
+
children(): Node[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { BoundingBox, Position } from "../util/position";
|
|
2
|
+
import { Presentation } from "./presentation";
|
|
3
|
+
import { AnimationProps, BuildFunction } from "../util/animation";
|
|
4
|
+
export interface ObjectProps {
|
|
5
|
+
position: Position | null;
|
|
6
|
+
opacity?: number;
|
|
7
|
+
anchor: "topleft" | "top" | "topright" | "left" | "center" | "right" | "bottomleft" | "bottom" | "bottomright";
|
|
8
|
+
}
|
|
9
|
+
export declare class SlideObject<Props extends ObjectProps> {
|
|
10
|
+
/**
|
|
11
|
+
* Starting values for each property.
|
|
12
|
+
*/
|
|
13
|
+
initialProps: Props;
|
|
14
|
+
/**
|
|
15
|
+
* Current values for each property.
|
|
16
|
+
*/
|
|
17
|
+
props: Props;
|
|
18
|
+
_presentation: Presentation | null;
|
|
19
|
+
_element: SVGElement | null;
|
|
20
|
+
_children: Node[];
|
|
21
|
+
/**
|
|
22
|
+
* Initializes a new object to include on a slide.
|
|
23
|
+
* @param props Object properties.
|
|
24
|
+
*/
|
|
25
|
+
constructor(props: Partial<Props>);
|
|
26
|
+
/**
|
|
27
|
+
* Returns the tag name of the element.
|
|
28
|
+
* @returns Tag name.
|
|
29
|
+
*/
|
|
30
|
+
tagName(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the DOM attributes that should be set for the element.
|
|
33
|
+
* @returns Object with attribute names and values.
|
|
34
|
+
*/
|
|
35
|
+
attributes(): Partial<Record<string, string>>;
|
|
36
|
+
/**
|
|
37
|
+
* Returns additional DOM attributes to be set for the element.
|
|
38
|
+
* Some attributes can't be computed until after an element's other properties are set:
|
|
39
|
+
* e.g. text position depends on content and font size.
|
|
40
|
+
* Additional attributes are computed after all other attributes, styles, and children.
|
|
41
|
+
* @returns Object with attribute names and values.
|
|
42
|
+
*/
|
|
43
|
+
additionalAttributes(): Partial<Record<string, string>>;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the styles that should be set for the element.
|
|
46
|
+
* @returns Object with style names and values.
|
|
47
|
+
*/
|
|
48
|
+
styles(): Partial<Record<string, string>>;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the children that should be rendered for the object.
|
|
51
|
+
* @returns Array of SVG elements.
|
|
52
|
+
*/
|
|
53
|
+
children(): Node[];
|
|
54
|
+
/**
|
|
55
|
+
* Given a set of prop updates, checks if the children of the object need to be updated.
|
|
56
|
+
* @param props Properties to update.
|
|
57
|
+
* @returns Boolean indicating whether children need to be updated.
|
|
58
|
+
*/
|
|
59
|
+
requiresChildrenUpdate(props: Partial<Props>): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Given a particular initial bounding box, returns the DOM position attributes that should be set for the element.
|
|
62
|
+
* @param bbox Bounding box.
|
|
63
|
+
* @returns Object with attribute names and values.
|
|
64
|
+
*/
|
|
65
|
+
positionAttributes(bbox: BoundingBox): any;
|
|
66
|
+
/**
|
|
67
|
+
* Re-generates the SVG element for the object.
|
|
68
|
+
* @param presentation Presentation object.
|
|
69
|
+
* @returns SVG element.
|
|
70
|
+
*/
|
|
71
|
+
generate(presentation: Presentation): SVGElement;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new HTML element for the object.
|
|
74
|
+
*/
|
|
75
|
+
createElement(): SVGElement;
|
|
76
|
+
/**
|
|
77
|
+
* Returns the element for the object.
|
|
78
|
+
* @returns SVG element.
|
|
79
|
+
*/
|
|
80
|
+
element(): SVGElement;
|
|
81
|
+
/**
|
|
82
|
+
* Returns an animation to perform.
|
|
83
|
+
* @param props Properties of object to change.
|
|
84
|
+
* @param animationParams Animation behavior parameters.
|
|
85
|
+
* @returns Animation properties.
|
|
86
|
+
*/
|
|
87
|
+
animation(props: Partial<Props>, animationParams?: anime.AnimeParams, delay?: number | null, animate?: boolean): AnimationProps;
|
|
88
|
+
/**
|
|
89
|
+
* Returns an update animation that skips the animation and just performs the change.
|
|
90
|
+
* @param props Properties of object to change.
|
|
91
|
+
*/
|
|
92
|
+
update(props: Partial<Props>, delay?: number | null): AnimationProps;
|
|
93
|
+
/**
|
|
94
|
+
* Performs an animation on the object.
|
|
95
|
+
*/
|
|
96
|
+
animate(props: Partial<Props>, animationParams?: anime.AnimeParams): BuildFunction;
|
|
97
|
+
/**
|
|
98
|
+
* Sets properties of the object.
|
|
99
|
+
*/
|
|
100
|
+
set(props: Partial<Props>): BuildFunction;
|
|
101
|
+
/**
|
|
102
|
+
* Animates a movement of the object.
|
|
103
|
+
*/
|
|
104
|
+
move(position: Position, animationParams?: anime.AnimeParams): BuildFunction;
|
|
105
|
+
/**
|
|
106
|
+
* Allow for x and y values to be interpreted as percentages of total width/height.
|
|
107
|
+
*/
|
|
108
|
+
positionInPresentation(position: Position): Position;
|
|
109
|
+
/**
|
|
110
|
+
* Adjusts a bounding box to be anchored given the object's vertical and horizontal anchor settings.
|
|
111
|
+
* @param bbox Bounding box to anchor.
|
|
112
|
+
* @returns Anchored bounding box.
|
|
113
|
+
*/
|
|
114
|
+
anchorBoundingBox(bbox: BoundingBox): BoundingBox;
|
|
115
|
+
/**
|
|
116
|
+
* Computes a bounding box for a given element given its rendered size and defined position.
|
|
117
|
+
* @param element Element for which to compute size.
|
|
118
|
+
* @param children Custom children to use when computing bounding box.
|
|
119
|
+
* @returns
|
|
120
|
+
*/
|
|
121
|
+
computeRenderedBoundingBox(element: SVGGraphicsElement, children?: Node[] | null): BoundingBox;
|
|
122
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { BoundingBox } from "../util/position";
|
|
2
|
+
import { Slide } from "./slide";
|
|
3
|
+
export interface PresentationOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Width of the presentation.
|
|
6
|
+
*/
|
|
7
|
+
width: number;
|
|
8
|
+
/**
|
|
9
|
+
* Height of the presentation.
|
|
10
|
+
*/
|
|
11
|
+
height: number;
|
|
12
|
+
/**
|
|
13
|
+
* Slide color for the presentation.
|
|
14
|
+
*/
|
|
15
|
+
backgroundColor: string;
|
|
16
|
+
}
|
|
17
|
+
interface PresentationState {
|
|
18
|
+
currentSlide: number;
|
|
19
|
+
}
|
|
20
|
+
export declare class Presentation {
|
|
21
|
+
/**
|
|
22
|
+
* Title of the presentation.
|
|
23
|
+
*/
|
|
24
|
+
title: string;
|
|
25
|
+
/**
|
|
26
|
+
* Element where presentation should be mounted.
|
|
27
|
+
*/
|
|
28
|
+
element: HTMLElement;
|
|
29
|
+
/**
|
|
30
|
+
* SVG container element.
|
|
31
|
+
*/
|
|
32
|
+
container: HTMLElement;
|
|
33
|
+
/**
|
|
34
|
+
* Parent SVG element of presentation.
|
|
35
|
+
*/
|
|
36
|
+
svg: SVGSVGElement | null;
|
|
37
|
+
/**
|
|
38
|
+
* Shadow SVG element, not displayed and used for calculating sizes.
|
|
39
|
+
*/
|
|
40
|
+
shadow: SVGSVGElement | null;
|
|
41
|
+
/**
|
|
42
|
+
* Presentation settings.
|
|
43
|
+
*/
|
|
44
|
+
options: PresentationOptions;
|
|
45
|
+
/**
|
|
46
|
+
* Bounds of presentation.
|
|
47
|
+
*/
|
|
48
|
+
boundingBox: BoundingBox;
|
|
49
|
+
/**
|
|
50
|
+
* Presentation slides.
|
|
51
|
+
*/
|
|
52
|
+
slides: Slide[];
|
|
53
|
+
/**
|
|
54
|
+
* Presentation state.
|
|
55
|
+
*/
|
|
56
|
+
presentationState: PresentationState;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @param title Title of the presentation.
|
|
60
|
+
*/
|
|
61
|
+
constructor(title: string, slides: Slide[], element: HTMLElement, options?: Partial<PresentationOptions>);
|
|
62
|
+
present(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Sets up keyboard commands for the presentation.
|
|
65
|
+
*/
|
|
66
|
+
setupKeyboardCommands(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Updates the size of the parent SVG element.
|
|
69
|
+
*
|
|
70
|
+
* The size of the parent SVG element needs to be updated.
|
|
71
|
+
*/
|
|
72
|
+
updateSVGContainerSize(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Advances to next animation in slide, or next slide if there is no next animation.
|
|
75
|
+
* Returns true if we were able to successfully advance.
|
|
76
|
+
* @param includeIntermediateBuilds Determines whether to progress through builds.
|
|
77
|
+
*/
|
|
78
|
+
next(includeIntermediateBuilds: boolean): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Goes back to the previous slide.
|
|
81
|
+
* @param includeIntermediateBuilds Determines whether to progress through builds.
|
|
82
|
+
*/
|
|
83
|
+
previous(includeIntermediateBuilds: boolean): void;
|
|
84
|
+
/**
|
|
85
|
+
* Checks if the presentation takes the entire document body.
|
|
86
|
+
* @returns True if the presentation takes the entire document body.
|
|
87
|
+
*/
|
|
88
|
+
isFullBodyPresentation(): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Computes the current size of an element in the DOM.
|
|
91
|
+
* Optionally accepts a custom list of children to see what the size of an
|
|
92
|
+
* element would be with different children.
|
|
93
|
+
* @param element Element to compute size of.
|
|
94
|
+
* @param children Custom children to use for element.
|
|
95
|
+
* @returns BoundingBox
|
|
96
|
+
*/
|
|
97
|
+
computeRenderedBoundingBox(element: SVGGraphicsElement, children?: Node[] | null): BoundingBox;
|
|
98
|
+
}
|
|
99
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BuildFunction } from "../util/animation";
|
|
2
|
+
import { SlideObject } from "./object";
|
|
3
|
+
import { Presentation } from "./presentation";
|
|
4
|
+
export interface SlideProps {
|
|
5
|
+
}
|
|
6
|
+
export declare class Slide {
|
|
7
|
+
objects: SlideObject<any>[];
|
|
8
|
+
animations: BuildFunction[];
|
|
9
|
+
animationIndex: number;
|
|
10
|
+
/**
|
|
11
|
+
* Property for use during development/debugging only.
|
|
12
|
+
* Manually set this property to a build function index
|
|
13
|
+
* to debug a specific animation.
|
|
14
|
+
*/
|
|
15
|
+
debugAnimation: number | null;
|
|
16
|
+
constructor(objects: SlideObject<any>[], animations?: BuildFunction[]);
|
|
17
|
+
render(presentation: Presentation, animationIndex?: number): void;
|
|
18
|
+
nextAnimation(presentation: Presentation): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Sleep for a specified number of milliseconds in an animation.
|
|
21
|
+
*/
|
|
22
|
+
sleep(ms: number): Promise<unknown>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import anime from "animejs/lib/anime.es.js";
|
|
2
|
+
/**
|
|
3
|
+
* Data needed to process an animation.
|
|
4
|
+
*/
|
|
5
|
+
export interface AnimationProps {
|
|
6
|
+
/**
|
|
7
|
+
* Whether to animate the change.
|
|
8
|
+
*/
|
|
9
|
+
animate?: boolean;
|
|
10
|
+
element?: HTMLElement | SVGElement;
|
|
11
|
+
attributes?: Record<string, string>;
|
|
12
|
+
styles?: Record<string, string>;
|
|
13
|
+
animationParams?: anime.AnimeParams;
|
|
14
|
+
children?: Node[];
|
|
15
|
+
/**
|
|
16
|
+
* Delay, in milliseconds.
|
|
17
|
+
*/
|
|
18
|
+
delay?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Function that performs an animation on an element.
|
|
22
|
+
*/
|
|
23
|
+
export type Animator = (props: AnimationProps | AnimationProps[]) => Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Function that possibly applies a sequence of animations.
|
|
26
|
+
*/
|
|
27
|
+
export type BuildFunction = (animate: Animator) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Perform an animation on an element.
|
|
30
|
+
* @param props Animation properties.
|
|
31
|
+
*/
|
|
32
|
+
export declare const performAnimation: Animator;
|
|
33
|
+
/**
|
|
34
|
+
* Performs animations by skipping the animation duration and jumping to end of animation.
|
|
35
|
+
* @param props Animation properties.
|
|
36
|
+
*/
|
|
37
|
+
export declare const skipAnimation: Animator;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface Position {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class BoundingBox {
|
|
6
|
+
origin: Position;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
constructor(origin: Position, width: number, height: number);
|
|
10
|
+
static fromElement(element: SVGGraphicsElement): BoundingBox;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface RichTextProps {
|
|
2
|
+
fontStyle?: string;
|
|
3
|
+
fontWeight?: string | number;
|
|
4
|
+
fontSize?: number;
|
|
5
|
+
fontFamily?: string;
|
|
6
|
+
textDecoration?: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
dy?: number;
|
|
9
|
+
}
|
|
10
|
+
export type RichTextSpan = string | [string, RichTextProps];
|
|
11
|
+
/**
|
|
12
|
+
* Creates a text node with spaces replaced by non-breaking spaces.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createSpacePreservingTextNode(text: string): Text;
|
|
15
|
+
/**
|
|
16
|
+
* Given rich text configuration, returns the corresponding tspan nodes.
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateTextNodes(lines: (string | RichTextSpan[])[], lineSpacing?: string, anchor?: "start" | "middle" | "end"): Node[];
|
package/dist/webpack.config.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "presenter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "A JavaScript presentation library",
|
|
5
5
|
"main": "dist/presenter.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
"url": "https://github.com/brianyu28/presenter/issues"
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/brianyu28/presenter#readme",
|
|
22
|
+
"license": "GPL-3.0-or-later",
|
|
23
|
+
"files": [
|
|
24
|
+
"./dist/"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"animejs": "^3.2.2"
|
|
28
|
+
},
|
|
22
29
|
"devDependencies": {
|
|
23
30
|
"@types/animejs": "^3.1.12",
|
|
24
31
|
"husky": "^9.1.7",
|
|
@@ -31,8 +38,5 @@
|
|
|
31
38
|
},
|
|
32
39
|
"lint-staged": {
|
|
33
40
|
"**/*": "prettier --write --ignore-unknown"
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"animejs": "^3.2.2"
|
|
37
41
|
}
|
|
38
42
|
}
|
package/.husky/pre-commit
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npx lint-staged
|
package/.prettierrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
package/dist/dist/presenter.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export let Presenter: {};
|
package/tsconfig.json
DELETED
package/webpack.config.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
mode: process.env.NODE_ENV || "development",
|
|
5
|
-
entry: "./src/index.ts",
|
|
6
|
-
output: {
|
|
7
|
-
filename: "presenter.js",
|
|
8
|
-
path: path.resolve(__dirname, "dist"),
|
|
9
|
-
library: "Presenter",
|
|
10
|
-
libraryTarget: "umd",
|
|
11
|
-
globalObject: "this",
|
|
12
|
-
},
|
|
13
|
-
watchOptions: {
|
|
14
|
-
ignored: [
|
|
15
|
-
"**/node_modules",
|
|
16
|
-
path.resolve(__dirname, "dist"),
|
|
17
|
-
path.resolve(__dirname, "examples"),
|
|
18
|
-
],
|
|
19
|
-
},
|
|
20
|
-
resolve: {
|
|
21
|
-
extensions: [".ts", ".js"],
|
|
22
|
-
},
|
|
23
|
-
module: {
|
|
24
|
-
rules: [
|
|
25
|
-
{
|
|
26
|
-
test: /\.ts$/,
|
|
27
|
-
use: "ts-loader",
|
|
28
|
-
exclude: /node_modules/,
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
},
|
|
32
|
-
};
|