@ue-too/animate 0.5.2 → 0.6.0

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.
Files changed (28) hide show
  1. package/package.json +9 -10
  2. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/animate/dist/animatable-attribute.js +0 -112
  3. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/animate/dist/animatable-attribute.js.map +0 -1
  4. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/animate/dist/composite-animation.js +0 -792
  5. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/animate/dist/composite-animation.js.map +0 -1
  6. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/animate/dist/index.js +0 -3
  7. package/.rollup.cache/home/runner/work/ue-too/ue-too/packages/animate/dist/index.js.map +0 -1
  8. package/dist/animatable-attribute.d.ts +0 -39
  9. package/dist/animate.tsbuildinfo +0 -1
  10. package/dist/composite-animation.d.ts +0 -181
  11. package/dist/index.d.ts +0 -2
  12. package/dist/package.json +0 -22
  13. package/jest.config.js +0 -18
  14. package/project.json +0 -33
  15. package/rollup.config.js +0 -20
  16. package/src/animatable-attribute.ts +0 -146
  17. package/src/composite-animation.ts +0 -950
  18. package/src/index.ts +0 -2
  19. package/test/animatable-attributes.test.ts +0 -156
  20. package/test/composite-animation.test.ts +0 -238
  21. package/tsconfig.json +0 -22
  22. package/tsconfig.spec.json +0 -12
  23. /package/{.rollup.cache/home/runner/work/ue-too/ue-too/packages/animate/dist/animatable-attribute.d.ts → animatable-attribute.d.ts} +0 -0
  24. /package/{.rollup.cache/home/runner/work/ue-too/ue-too/packages/animate/dist/animate.tsbuildinfo → animate.tsbuildinfo} +0 -0
  25. /package/{.rollup.cache/home/runner/work/ue-too/ue-too/packages/animate/dist/composite-animation.d.ts → composite-animation.d.ts} +0 -0
  26. /package/{.rollup.cache/home/runner/work/ue-too/ue-too/packages/animate/dist/index.d.ts → index.d.ts} +0 -0
  27. /package/{dist/index.js → index.js} +0 -0
  28. /package/{dist/index.js.map → index.js.map} +0 -0
@@ -1,146 +0,0 @@
1
- import { PointCal, Point } from "@ue-too/math";
2
-
3
- export type Keyframe<T> = {
4
- percentage: number; // from 0 to 1;
5
- value: T;
6
- easingFn?: (percentage: number) => number;
7
- }
8
-
9
- export interface AnimatableAttributeHelper<T> {
10
- lerp(ratio: number, start: Keyframe<T>, end: Keyframe<T>): T;
11
- }
12
-
13
- export const pointHelperFunctions: AnimatableAttributeHelper<Point> = {
14
- lerp: (ratio: number, start: Keyframe<Point>, end: Keyframe<Point>): Point => {
15
- const inbetweenRatio = (ratio - start.percentage) / (end.percentage - start.percentage);
16
- let transformed = inbetweenRatio;
17
- if(start.easingFn){
18
- transformed = start.easingFn(inbetweenRatio);
19
- }
20
- const res = PointCal.addVector(start.value, PointCal.multiplyVectorByScalar(PointCal.subVector(end.value, start.value), transformed));
21
- return res;
22
- }
23
- };
24
-
25
- export class PointAnimationHelper implements AnimatableAttributeHelper<Point> {
26
-
27
- constructor(){
28
-
29
- }
30
-
31
- lerp(ratio: number, start: Keyframe<Point>, end: Keyframe<Point>): Point {
32
- const inbetweenRatio = (ratio - start.percentage) / (end.percentage - start.percentage);
33
- let transformed = inbetweenRatio;
34
- if(start.easingFn){
35
- transformed = start.easingFn(inbetweenRatio);
36
- }
37
- const res = PointCal.addVector(start.value, PointCal.multiplyVectorByScalar(PointCal.subVector(end.value, start.value), transformed));
38
- return res;
39
- }
40
-
41
- }
42
-
43
- export const numberHelperFunctions: AnimatableAttributeHelper<number> = {
44
- lerp: (ratio: number, start: Keyframe<number>, end: Keyframe<number>): number => {
45
- const inbetweenRatio = (ratio - start.percentage) / (end.percentage - start.percentage);
46
- let transformed = inbetweenRatio;
47
- if(start.easingFn){
48
- transformed = start.easingFn(inbetweenRatio);
49
- }
50
- const res = start.value + transformed * (end.value - start.value);
51
- return res;
52
- }
53
- }
54
-
55
- export class NumberAnimationHelper implements AnimatableAttributeHelper<number>{
56
-
57
- constructor(){
58
-
59
- }
60
-
61
- lerp(ratio: number, start: Keyframe<number>, end: Keyframe<number>): number {
62
- const inbetweenRatio = (ratio - start.percentage) / (end.percentage - start.percentage);
63
- let transformed = inbetweenRatio;
64
- if(start.easingFn){
65
- transformed = start.easingFn(inbetweenRatio);
66
- }
67
- const res = start.value + transformed * (end.value - start.value);
68
- return res;
69
- }
70
- }
71
-
72
- export const stringHelperFunctions: AnimatableAttributeHelper<string> = {
73
- lerp: (ratio: number, start: Keyframe<string>, end: Keyframe<string>): string => {
74
- const percentageScale = (ratio - start.percentage) / (end.percentage - start.percentage)
75
- // if percentageScale is negative that means it's before the start value just return start value
76
- // if percentageScale is more than 1 that means it's after the end value just return the end value
77
- // if percentageScale is less than 0.5 return the start value else return the end value
78
- return percentageScale < 0 || percentageScale < 0.5 ? start.value : end.value;
79
- }
80
- }
81
-
82
- export class StringAnimationHelper implements AnimatableAttributeHelper<string>{
83
- constructor(){
84
-
85
- }
86
-
87
- lerp(ratio: number, start: Keyframe<string>, end: Keyframe<string>): string {
88
- const percentageScale = (ratio - start.percentage) / (end.percentage - start.percentage)
89
- // if percentageScale is negative that means it's before the start value just return start value
90
- // if percentageScale is more than 1 that means it's after the end value just return the end value
91
- // if percentageScale is less than 0.5 return the start value else return the end value
92
- return percentageScale < 0 || percentageScale < 0.5 ? start.value : end.value;
93
- }
94
- }
95
-
96
- export const integerHelperFunctions: AnimatableAttributeHelper<number> = {
97
- lerp: (ratio: number, start: Keyframe<number>, end: Keyframe<number>): number => {
98
- const percentageScale = (ratio - start.percentage) / (end.percentage - start.percentage)
99
- // if percentageScale is negative that means it's before the start value just return start value
100
- // if percentageScale is more than 1 that means it's after the end value just return the end value
101
- // if percentageScale is less than 0.5 return the start value else return the end value
102
- return percentageScale < 0 || percentageScale < 0.5 ? start.value : end.value;
103
- }
104
- }
105
-
106
- export class IntegerAnimationHelper implements AnimatableAttributeHelper<number>{
107
- constructor(){
108
-
109
- }
110
-
111
- lerp(ratio: number, start: Keyframe<number>, end: Keyframe<number>): number {
112
- const percentageScale = (ratio - start.percentage) / (end.percentage - start.percentage)
113
- // if percentageScale is negative that means it's before the start value just return start value
114
- // if percentageScale is more than 1 that means it's after the end value just return the end value
115
- // if percentageScale is less than 0.5 return the start value else return the end value
116
- return percentageScale < 0 || percentageScale < 0.5 ? start.value : end.value;
117
- }
118
- }
119
-
120
- export type RGB = {r: number, g: number, b: number};
121
-
122
- export const rgbHelperFunctions: AnimatableAttributeHelper<RGB> = {
123
- lerp: (ratio: number, start: Keyframe<RGB>, end: Keyframe<RGB>): RGB => {
124
- const res = {
125
- r: start.value.r + ((ratio - start.percentage) / (end.percentage - start.percentage)) * (end.value.r - start.value.r),
126
- g: start.value.g + ((ratio - start.percentage) / (end.percentage - start.percentage)) * (end.value.g - start.value.g),
127
- b: start.value.b + ((ratio - start.percentage) / (end.percentage - start.percentage)) * (end.value.b - start.value.b),
128
- }
129
- return res;
130
- }
131
- }
132
-
133
- export class RGBAnimationHelper implements AnimatableAttributeHelper<RGB> {
134
- constructor(){
135
-
136
- }
137
-
138
- lerp(ratio: number, start: Keyframe<RGB>, end: Keyframe<RGB>): RGB {
139
- const res = {
140
- r: start.value.r + ((ratio - start.percentage) / (end.percentage - start.percentage)) * (end.value.r - start.value.r),
141
- g: start.value.g + ((ratio - start.percentage) / (end.percentage - start.percentage)) * (end.value.g - start.value.g),
142
- b: start.value.b + ((ratio - start.percentage) / (end.percentage - start.percentage)) * (end.value.b - start.value.b),
143
- }
144
- return res;
145
- }
146
- }