chnobli 0.1.5 → 0.1.7

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 (238) hide show
  1. package/.editorconfig +11 -0
  2. package/.prettierignore +4 -0
  3. package/.prettierrc +6 -0
  4. package/.vscode/settings.json +4 -0
  5. package/auto-docs/easing.js.html +342 -0
  6. package/auto-docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  7. package/auto-docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
  8. package/auto-docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  9. package/auto-docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  10. package/auto-docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  11. package/auto-docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  12. package/auto-docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  13. package/auto-docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
  14. package/auto-docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  15. package/auto-docs/fonts/OpenSans-Light-webfont.eot +0 -0
  16. package/auto-docs/fonts/OpenSans-Light-webfont.svg +1831 -0
  17. package/auto-docs/fonts/OpenSans-Light-webfont.woff +0 -0
  18. package/auto-docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  19. package/auto-docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  20. package/auto-docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  21. package/auto-docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  22. package/auto-docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
  23. package/auto-docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  24. package/auto-docs/global.html +4810 -0
  25. package/auto-docs/index.html +65 -0
  26. package/auto-docs/scripts/linenumber.js +25 -0
  27. package/auto-docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  28. package/auto-docs/scripts/prettify/lang-css.js +2 -0
  29. package/auto-docs/scripts/prettify/prettify.js +28 -0
  30. package/auto-docs/styles/jsdoc-default.css +358 -0
  31. package/auto-docs/styles/prettify-jsdoc.css +111 -0
  32. package/auto-docs/styles/prettify-tomorrow.css +132 -0
  33. package/dist/animation/Animation.d.ts +36 -0
  34. package/dist/animation/Animation.d.ts.map +1 -0
  35. package/dist/animation/Animation.js +230 -0
  36. package/dist/animation/Animation.js.map +1 -0
  37. package/dist/animation/animation.d.ts +36 -0
  38. package/dist/animation/animation.d.ts.map +1 -0
  39. package/dist/animation/animation.js +230 -0
  40. package/dist/animation/animation.js.map +1 -0
  41. package/dist/animation/public.d.ts +55 -0
  42. package/dist/animation/public.d.ts.map +1 -0
  43. package/dist/animation/public.js +104 -0
  44. package/dist/animation/public.js.map +1 -0
  45. package/dist/chnobli.d.ts +15 -0
  46. package/dist/chnobli.d.ts.map +1 -0
  47. package/dist/chnobli.js +63 -0
  48. package/dist/chnobli.js.map +1 -0
  49. package/dist/property/BasicProperty.d.ts +38 -0
  50. package/dist/property/BasicProperty.d.ts.map +1 -0
  51. package/dist/property/BasicProperty.js +72 -0
  52. package/dist/property/BasicProperty.js.map +1 -0
  53. package/dist/property/ClassProperty.d.ts +32 -0
  54. package/dist/property/ClassProperty.d.ts.map +1 -0
  55. package/dist/property/ClassProperty.js +108 -0
  56. package/dist/property/ClassProperty.js.map +1 -0
  57. package/dist/property/Property.d.ts +13 -0
  58. package/dist/property/Property.d.ts.map +1 -0
  59. package/dist/property/Property.js +20 -0
  60. package/dist/property/Property.js.map +1 -0
  61. package/dist/property/StyleProperty.d.ts +25 -0
  62. package/dist/property/StyleProperty.d.ts.map +1 -0
  63. package/dist/property/StyleProperty.js +221 -0
  64. package/dist/property/StyleProperty.js.map +1 -0
  65. package/dist/property/TransformProperty.d.ts +15 -0
  66. package/dist/property/TransformProperty.d.ts.map +1 -0
  67. package/dist/property/TransformProperty.js +43 -0
  68. package/dist/property/TransformProperty.js.map +1 -0
  69. package/dist/property/TransformXYProperty.d.ts +28 -0
  70. package/dist/property/TransformXYProperty.d.ts.map +1 -0
  71. package/dist/property/TransformXYProperty.js +65 -0
  72. package/dist/property/TransformXYProperty.js.map +1 -0
  73. package/dist/responsive/ResponsiveEvent.d.ts +17 -0
  74. package/dist/responsive/ResponsiveEvent.d.ts.map +1 -0
  75. package/dist/responsive/ResponsiveEvent.js +45 -0
  76. package/dist/responsive/ResponsiveEvent.js.map +1 -0
  77. package/dist/responsive/TestEvent.d.ts +11 -0
  78. package/dist/responsive/TestEvent.d.ts.map +1 -0
  79. package/dist/responsive/TestEvent.js +26 -0
  80. package/dist/responsive/TestEvent.js.map +1 -0
  81. package/dist/responsive/event.d.ts +10 -0
  82. package/dist/responsive/event.d.ts.map +1 -0
  83. package/dist/responsive/event.js +39 -0
  84. package/dist/responsive/event.js.map +1 -0
  85. package/dist/scroll/Scroll.d.ts +27 -0
  86. package/dist/scroll/Scroll.d.ts.map +1 -0
  87. package/dist/scroll/Scroll.js +132 -0
  88. package/dist/scroll/Scroll.js.map +1 -0
  89. package/dist/scroll/ScrollEvent.d.ts +17 -0
  90. package/dist/scroll/ScrollEvent.d.ts.map +1 -0
  91. package/dist/scroll/ScrollEvent.js +39 -0
  92. package/dist/scroll/ScrollEvent.js.map +1 -0
  93. package/dist/scroll/public.d.ts +7 -0
  94. package/dist/scroll/public.d.ts.map +1 -0
  95. package/dist/scroll/public.js +17 -0
  96. package/dist/scroll/public.js.map +1 -0
  97. package/dist/stagger/stagger.d.ts +13 -0
  98. package/dist/stagger/stagger.d.ts.map +1 -0
  99. package/dist/stagger/stagger.js +35 -0
  100. package/dist/stagger/stagger.js.map +1 -0
  101. package/dist/target/BaseTarget.old.d.ts +33 -0
  102. package/dist/target/BaseTarget.old.d.ts.map +1 -0
  103. package/dist/target/BaseTarget.old.js +73 -0
  104. package/dist/target/BaseTarget.old.js.map +1 -0
  105. package/dist/target/DomTarget.d.ts +41 -0
  106. package/dist/target/DomTarget.d.ts.map +1 -0
  107. package/dist/target/DomTarget.js +230 -0
  108. package/dist/target/DomTarget.js.map +1 -0
  109. package/dist/target/Target.d.ts +22 -0
  110. package/dist/target/Target.d.ts.map +1 -0
  111. package/dist/target/Target.js +21 -0
  112. package/dist/target/Target.js.map +1 -0
  113. package/dist/target/TestDomNode.d.ts +14 -0
  114. package/dist/target/TestDomNode.d.ts.map +1 -0
  115. package/dist/target/TestDomNode.js +55 -0
  116. package/dist/target/TestDomNode.js.map +1 -0
  117. package/dist/timeline/Nested.d.ts +30 -0
  118. package/dist/timeline/Nested.d.ts.map +1 -0
  119. package/dist/timeline/Nested.js +51 -0
  120. package/dist/timeline/Nested.js.map +1 -0
  121. package/dist/timeline/TimeLine.d.ts +32 -0
  122. package/dist/timeline/TimeLine.d.ts.map +1 -0
  123. package/dist/timeline/TimeLine.js +288 -0
  124. package/dist/timeline/TimeLine.js.map +1 -0
  125. package/dist/timeline/public.d.ts +120 -0
  126. package/dist/timeline/public.d.ts.map +1 -0
  127. package/dist/timeline/public.js +301 -0
  128. package/dist/timeline/public.js.map +1 -0
  129. package/dist/timing/AnimationFrameTicker.d.ts +32 -0
  130. package/dist/timing/AnimationFrameTicker.d.ts.map +1 -0
  131. package/dist/timing/AnimationFrameTicker.js +134 -0
  132. package/dist/timing/AnimationFrameTicker.js.map +1 -0
  133. package/dist/timing/Ease.d.ts +6 -0
  134. package/dist/timing/Ease.d.ts.map +1 -0
  135. package/dist/timing/Ease.js +15 -0
  136. package/dist/timing/Ease.js.map +1 -0
  137. package/dist/timing/TestTicker.d.ts +19 -0
  138. package/dist/timing/TestTicker.d.ts.map +1 -0
  139. package/dist/timing/TestTicker.js +81 -0
  140. package/dist/timing/TestTicker.js.map +1 -0
  141. package/dist/timing/Ticker.d.ts +14 -0
  142. package/dist/timing/Ticker.d.ts.map +1 -0
  143. package/dist/timing/Ticker.js +2 -0
  144. package/dist/timing/Ticker.js.map +1 -0
  145. package/dist/timing/Timing.d.ts +62 -0
  146. package/dist/timing/Timing.d.ts.map +1 -0
  147. package/dist/timing/Timing.js +257 -0
  148. package/dist/timing/Timing.js.map +1 -0
  149. package/dist/timing/easing.d.ts +158 -0
  150. package/dist/timing/easing.d.ts.map +1 -0
  151. package/dist/timing/easing.js +273 -0
  152. package/dist/timing/easing.js.map +1 -0
  153. package/dist/utils/Events.d.ts +9 -0
  154. package/dist/utils/Events.d.ts.map +1 -0
  155. package/dist/utils/Events.js +35 -0
  156. package/dist/utils/Events.js.map +1 -0
  157. package/dist/utils/internal.d.ts +2 -0
  158. package/dist/utils/internal.d.ts.map +1 -0
  159. package/dist/utils/internal.js +6 -0
  160. package/dist/utils/internal.js.map +1 -0
  161. package/dist/utils/motionpath.d.ts +16 -0
  162. package/dist/utils/motionpath.d.ts.map +1 -0
  163. package/dist/utils/motionpath.js +41 -0
  164. package/dist/utils/motionpath.js.map +1 -0
  165. package/dist/utils/utils.d.ts +43 -0
  166. package/dist/utils/utils.d.ts.map +1 -0
  167. package/dist/utils/utils.js +93 -0
  168. package/dist/utils/utils.js.map +1 -0
  169. package/dist/values/ColorValue.d.ts +12 -0
  170. package/dist/values/ColorValue.d.ts.map +1 -0
  171. package/dist/values/ColorValue.js +133 -0
  172. package/dist/values/ColorValue.js.map +1 -0
  173. package/dist/values/StyleValue.d.ts +40 -0
  174. package/dist/values/StyleValue.d.ts.map +1 -0
  175. package/dist/values/StyleValue.js +149 -0
  176. package/dist/values/StyleValue.js.map +1 -0
  177. package/dist/values/Value.d.ts +13 -0
  178. package/dist/values/Value.d.ts.map +1 -0
  179. package/dist/values/Value.js +38 -0
  180. package/dist/values/Value.js.map +1 -0
  181. package/dist/values/defaultcolors.d.ts +2 -0
  182. package/dist/values/defaultcolors.d.ts.map +1 -0
  183. package/dist/values/defaultcolors.js +149 -0
  184. package/dist/values/defaultcolors.js.map +1 -0
  185. package/package.json +11 -7
  186. package/src/animation/{animation.js → Animation.ts} +56 -54
  187. package/src/animation/{public.js → public.ts} +23 -18
  188. package/src/{chnobli.js → chnobli.ts} +11 -12
  189. package/src/property/BasicProperty.ts +91 -0
  190. package/src/property/ClassProperty.ts +132 -0
  191. package/src/property/Property.ts +33 -0
  192. package/src/property/StyleProperty.ts +273 -0
  193. package/src/property/TransformProperty.ts +56 -0
  194. package/src/property/TransformXYProperty.ts +88 -0
  195. package/src/responsive/ResponsiveEvent.ts +60 -0
  196. package/src/responsive/{testevent.js → TestEvent.ts} +12 -10
  197. package/src/scroll/{scroll.js → Scroll.ts} +53 -35
  198. package/src/scroll/ScrollEvent.ts +53 -0
  199. package/src/scroll/public.ts +20 -0
  200. package/src/stagger/stagger.ts +45 -0
  201. package/src/target/{basetarget.js → BaseTarget.old.ts} +25 -26
  202. package/src/target/DomTarget.ts +281 -0
  203. package/src/target/Target.ts +48 -0
  204. package/src/target/{testdomnode.js → TestDomNode.ts} +18 -15
  205. package/src/tests/{properties.test.js → properties.test.ts} +54 -49
  206. package/src/tests/{timeline.test.js → timeline.test.ts} +92 -75
  207. package/src/tests/{timing.test.js → timing.test.ts} +25 -22
  208. package/src/tests/{usecases.test.js → usecases.test.ts} +13 -10
  209. package/src/tests/{values.test.js → values.test.ts} +21 -21
  210. package/src/timeline/{nested.js → Nested.ts} +18 -12
  211. package/src/timeline/{timeline.js → TimeLine.ts} +100 -60
  212. package/src/timeline/{public.js → public.ts} +75 -60
  213. package/src/timing/{ticker.js → AnimationFrameTicker.ts} +36 -21
  214. package/src/timing/{ease.js → Ease.ts} +6 -5
  215. package/src/timing/{testticker.js → TestTicker.ts} +27 -24
  216. package/src/timing/Ticker.ts +11 -0
  217. package/src/timing/{timing.js → Timing.ts} +72 -63
  218. package/src/timing/{easing.js → easing.ts} +52 -43
  219. package/src/utils/{events.js → Events.ts} +12 -11
  220. package/src/utils/internal.ts +10 -0
  221. package/src/utils/{motionpath.js → motionpath.ts} +36 -13
  222. package/src/utils/utils.ts +110 -0
  223. package/src/values/{colorvalue.js → ColorValue.ts} +46 -47
  224. package/src/values/StyleValue.ts +186 -0
  225. package/src/values/{value.js → Value.ts} +14 -12
  226. package/src/values/{defaultcolors.js → defaultcolors.ts} +2 -2
  227. package/tsconfig.build.json +19 -0
  228. package/tsconfig.json +17 -108
  229. package/src/animation/property.js +0 -556
  230. package/src/responsive/event.js +0 -46
  231. package/src/scroll/event.js +0 -41
  232. package/src/scroll/public.js +0 -17
  233. package/src/stagger/stagger.js +0 -42
  234. package/src/target/domtarget.js +0 -266
  235. package/src/target/target.js +0 -22
  236. package/src/utils/internal.js +0 -7
  237. package/src/utils/utils.js +0 -107
  238. package/src/values/stylevalue.js +0 -148
@@ -1,27 +1,28 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import TestTicker from '../timing/testticker.js';
3
- import TestResponsiveEvent from '../responsive/testevent.js';
2
+ import TestTicker from '../timing/TestTicker';
3
+ import TestResponsiveEvent from '../responsive/TestEvent';
4
4
  import { animate, timeline } from '../chnobli.js';
5
- import { responsive, curve } from '../utils/utils.js';
6
- import { el } from '../target/testdomnode.js';
7
- import { timeout } from 'fire/util.js';
5
+ import { responsive, curve } from '../utils/utils';
6
+ import { el } from '../target/TestDomNode';
7
+ import { timeout } from 'fire/utils';
8
8
 
9
9
  describe('properties', () => {
10
10
  it('resetprops', () => {
11
- const ticker = new TestTicker;
11
+ const ticker = new TestTicker();
12
12
 
13
13
  const div = el();
14
14
  const tl = timeline()
15
15
  .add(div, {
16
16
  x: 100,
17
17
  width: 100,
18
- duration: 10
18
+ duration: 10,
19
19
  })
20
20
  .play();
21
21
 
22
22
  ticker.run();
23
- expect(div.style.transform)
24
- .toBe('translate3d(100.000px,0.000px,0.000px)');
23
+ expect(div.style.transform).toBe(
24
+ 'translate3d(100.000px,0.000px,0.000px)',
25
+ );
25
26
  expect(div.style.width).toBe('100.000px');
26
27
 
27
28
  tl.resetProps();
@@ -30,10 +31,9 @@ describe('properties', () => {
30
31
  });
31
32
 
32
33
  it('destroy', async () => {
33
- const ticker = new TestTicker;
34
-
35
- function runDestroyTest(cleanup, ticker) {
34
+ const ticker = new TestTicker();
36
35
 
36
+ function runDestroyTest(cleanup: any, ticker: any) {
37
37
  const div = el();
38
38
  cleanup.register(div, 'div');
39
39
  expect(ticker.targets.size()).toBe(0);
@@ -41,15 +41,16 @@ describe('properties', () => {
41
41
  .add(div, {
42
42
  x: 100,
43
43
  width: 100,
44
- duration: 10
44
+ duration: 10,
45
45
  })
46
46
  .play();
47
47
 
48
48
  expect(ticker.targets.size()).toBe(1);
49
49
 
50
50
  ticker.run();
51
- expect(div.style.transform)
52
- .toBe('translate3d(100.000px,0.000px,0.000px)');
51
+ expect(div.style.transform).toBe(
52
+ 'translate3d(100.000px,0.000px,0.000px)',
53
+ );
53
54
  expect(div.style.width).toBe('100.000px');
54
55
 
55
56
  tl.destroy();
@@ -58,35 +59,37 @@ describe('properties', () => {
58
59
  expect(ticker.targets.size()).toBe(0);
59
60
  }
60
61
 
61
- let resolveCleanupProm;
62
- let cleanupProm = new Promise(resolve => resolveCleanupProm = resolve);
62
+ let resolveCleanupProm: any;
63
+ let cleanupProm = new Promise(
64
+ resolve => (resolveCleanupProm = resolve),
65
+ );
63
66
  const cleanup = new FinalizationRegistry(key => {
64
67
  resolveCleanupProm(key);
65
68
  });
66
69
 
67
70
  runDestroyTest(cleanup, ticker);
68
71
 
72
+ // @ts-ignore
69
73
  global.gc();
70
74
 
71
75
  const res = await Promise.race([
72
76
  cleanupProm,
73
- timeout(2000).then(() => 'timedout')
77
+ timeout(2000).then(() => 'timedout'),
74
78
  ]);
75
79
  expect(res).toBe('div');
76
80
  });
77
81
 
78
82
  it('update timeline', () => {
79
- const ticker = new TestTicker;
80
- const respEv = new TestResponsiveEvent;
83
+ const ticker = new TestTicker();
84
+ const respEv = new TestResponsiveEvent();
81
85
 
82
86
  const div = el();
83
87
  div.computedStyle.width = '10px';
84
88
 
85
- const tl = timeline()
86
- .add(div, {
87
- width: 100,
88
- duration: 10
89
- });
89
+ const tl = timeline().add(div, {
90
+ width: 100,
91
+ duration: 10,
92
+ });
90
93
 
91
94
  tl.seek(0);
92
95
  ticker.run();
@@ -112,28 +115,28 @@ describe('properties', () => {
112
115
  expect(div.style.width).toBe('60.000px');
113
116
 
114
117
  div.computedStyle.width = '30px';
115
- respEv.resize();
118
+ respEv.resize(100, 200);
116
119
  expect(div.style.width).toBe('65.000px');
117
120
  });
118
121
 
119
122
  it('responsive', () => {
120
- const ticker = new TestTicker;
121
- const respEv = new TestResponsiveEvent;
123
+ const ticker = new TestTicker();
124
+ const respEv = new TestResponsiveEvent();
122
125
 
123
126
  const div = el();
124
127
  div.computedStyle.width = '10px';
125
128
 
126
129
  let windowWidth = 16;
127
130
 
128
- let windowAspectRatio;
131
+ let windowAspectRatio: any;
129
132
  const resp1 = responsive(() => {
130
133
  windowAspectRatio = windowWidth / 9;
131
134
  });
132
135
 
133
136
  const tl = timeline()
134
137
  .add(div, {
135
- width: responsive(e => 20 * windowAspectRatio),
136
- duration: 10
138
+ width: responsive(() => 20 * windowAspectRatio),
139
+ duration: 10,
137
140
  })
138
141
  .addResponsive(resp1);
139
142
 
@@ -144,35 +147,37 @@ describe('properties', () => {
144
147
  expect(div.style.width).toBe('35.556px');
145
148
 
146
149
  windowWidth = 15;
147
- respEv.resize();
150
+ respEv.resize(100, 200);
148
151
  expect(div.style.width).toBe('33.333px');
149
152
  });
150
153
 
151
154
  it('xy', () => {
152
- const ticker = new TestTicker;
155
+ const ticker = new TestTicker();
153
156
 
154
157
  const div = el();
155
- const tl = timeline()
156
- .add(div, {
157
- xy: curve([
158
- { x: 0, y: 10 },
159
- { x: 100, y: 10 },
160
- { x: 50, y: 20 }
161
- ]),
162
- duration: 10
163
- });
158
+ const tl = timeline().add(div, {
159
+ xy: curve([
160
+ { x: 0, y: 10 },
161
+ { x: 100, y: 10 },
162
+ { x: 50, y: 20 },
163
+ ]),
164
+ duration: 10,
165
+ });
164
166
 
165
167
  tl.play();
166
168
  ticker.run(0);
167
- expect(div.style.transform)
168
- .toBe('translate3d(0.000px,10.000px,0.000px)');
169
+ expect(div.style.transform).toBe(
170
+ 'translate3d(0.000px,10.000px,0.000px)',
171
+ );
169
172
 
170
173
  ticker.run(5);
171
- expect(div.style.transform)
172
- .toBe('translate3d(100.000px,10.000px,0.000px)');
174
+ expect(div.style.transform).toBe(
175
+ 'translate3d(100.000px,10.000px,0.000px)',
176
+ );
173
177
 
174
178
  ticker.run();
175
- expect(div.style.transform)
176
- .toBe('translate3d(50.000px,20.000px,0.000px)');
179
+ expect(div.style.transform).toBe(
180
+ 'translate3d(50.000px,20.000px,0.000px)',
181
+ );
177
182
  });
178
- });
183
+ });
@@ -1,11 +1,11 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import TestTicker from '../timing/testticker.js';
3
- import { animate, timeline } from '../chnobli.js';
4
- import { el } from '../target/testdomnode.js';
2
+ import TestTicker from '../timing/TestTicker';
3
+ import { animate, timeline } from '../chnobli';
4
+ import { el } from '../target/TestDomNode';
5
5
 
6
6
  describe('timeline', () => {
7
7
  it('empty timeline', () => {
8
- const ticker = new TestTicker;
8
+ const ticker = new TestTicker();
9
9
 
10
10
  const tl = timeline();
11
11
  tl.play();
@@ -14,23 +14,25 @@ describe('timeline', () => {
14
14
  });
15
15
 
16
16
  it('single timeline', () => {
17
- const ticker = new TestTicker;
17
+ const ticker = new TestTicker();
18
18
 
19
19
  const tl = timeline();
20
20
  const target = el();
21
21
  tl.add(target, {
22
22
  x: 10,
23
- duration: 10
23
+ duration: 10,
24
24
  });
25
25
  tl.play();
26
26
 
27
27
  ticker.run(0);
28
- expect(target.style.transform)
29
- .toBe('translate3d(0.000px,0.000px,0.000px)');
28
+ expect(target.style.transform).toBe(
29
+ 'translate3d(0.000px,0.000px,0.000px)',
30
+ );
30
31
 
31
32
  ticker.run();
32
- expect(target.style.transform)
33
- .toBe('translate3d(10.000px,0.000px,0.000px)');
33
+ expect(target.style.transform).toBe(
34
+ 'translate3d(10.000px,0.000px,0.000px)',
35
+ );
34
36
 
35
37
  tl.reverse();
36
38
  tl.play();
@@ -39,147 +41,162 @@ describe('timeline', () => {
39
41
  });
40
42
 
41
43
  it('timeline set', () => {
42
- const ticker = new TestTicker;
44
+ const ticker = new TestTicker();
43
45
 
44
46
  const target = el();
45
- const tl = timeline()
46
- .set(target, {
47
- x: 10
48
- });
47
+ const tl = timeline().set(target, {
48
+ x: 10,
49
+ });
49
50
  tl.play();
50
51
 
51
52
  ticker.run(0);
52
- expect(target.style.transform)
53
- .toBe('translate3d(10.000px,0.000px,0.000px)');
53
+ expect(target.style.transform).toBe(
54
+ 'translate3d(10.000px,0.000px,0.000px)',
55
+ );
54
56
 
55
57
  ticker.run();
56
- expect(target.style.transform)
57
- .toBe('translate3d(10.000px,0.000px,0.000px)');
58
+ expect(target.style.transform).toBe(
59
+ 'translate3d(10.000px,0.000px,0.000px)',
60
+ );
58
61
 
59
62
  tl.reverse();
60
63
  tl.play();
61
64
  ticker.run();
62
- expect(target.style.transform)
63
- .toBe('translate3d(10.000px,0.000px,0.000px)');
65
+ expect(target.style.transform).toBe(
66
+ 'translate3d(10.000px,0.000px,0.000px)',
67
+ );
64
68
  });
65
69
 
66
70
  it('offsetTimeline timeline', () => {
67
- const ticker = new TestTicker;
71
+ const ticker = new TestTicker();
68
72
 
69
73
  const tl = timeline();
70
74
  const target = el();
71
75
  tl.add(target, {
72
76
  x: 10,
73
- duration: 10
77
+ duration: 10,
74
78
  });
75
79
  tl.add(target, {
76
80
  x: 20,
77
- duration: 10
78
- })
81
+ duration: 10,
82
+ });
79
83
  tl.play();
80
84
 
81
85
  ticker.run(10);
82
- expect(target.style.transform)
83
- .toBe('translate3d(10.000px,0.000px,0.000px)');
86
+ expect(target.style.transform).toBe(
87
+ 'translate3d(10.000px,0.000px,0.000px)',
88
+ );
84
89
  ticker.run(1);
85
- expect(target.style.transform)
86
- .toBe('translate3d(11.000px,0.000px,0.000px)');
90
+ expect(target.style.transform).toBe(
91
+ 'translate3d(11.000px,0.000px,0.000px)',
92
+ );
87
93
 
88
94
  ticker.run();
89
- expect(target.style.transform)
90
- .toBe('translate3d(20.000px,0.000px,0.000px)');
95
+ expect(target.style.transform).toBe(
96
+ 'translate3d(20.000px,0.000px,0.000px)',
97
+ );
91
98
  });
92
99
 
93
100
  it('timeline seeking', () => {
94
- const ticker = new TestTicker;
101
+ const ticker = new TestTicker();
95
102
 
96
103
  const tl = timeline();
97
104
  const target = el();
98
105
  tl.add(target, {
99
106
  x: 10,
100
- duration: 10
107
+ duration: 10,
101
108
  });
102
109
  tl.add(target, {
103
110
  x: 20,
104
- duration: 10
105
- })
111
+ duration: 10,
112
+ });
106
113
 
107
114
  tl.seekMs(10);
108
115
  ticker.run();
109
- expect(target.style.transform)
110
- .toBe('translate3d(10.000px,0.000px,0.000px)');
116
+ expect(target.style.transform).toBe(
117
+ 'translate3d(10.000px,0.000px,0.000px)',
118
+ );
111
119
 
112
120
  tl.seekMs(11);
113
121
  ticker.run();
114
- expect(target.style.transform)
115
- .toBe('translate3d(11.000px,0.000px,0.000px)');
122
+ expect(target.style.transform).toBe(
123
+ 'translate3d(11.000px,0.000px,0.000px)',
124
+ );
116
125
 
117
126
  tl.seekMs(20);
118
127
  ticker.run();
119
- expect(target.style.transform)
120
- .toBe('translate3d(20.000px,0.000px,0.000px)');
128
+ expect(target.style.transform).toBe(
129
+ 'translate3d(20.000px,0.000px,0.000px)',
130
+ );
121
131
 
122
132
  tl.seekMs(8);
123
133
  ticker.run();
124
- expect(target.style.transform)
125
- .toBe('translate3d(8.000px,0.000px,0.000px)');
134
+ expect(target.style.transform).toBe(
135
+ 'translate3d(8.000px,0.000px,0.000px)',
136
+ );
126
137
  });
127
138
 
128
139
  it('seeking after', () => {
129
- const ticker = new TestTicker;
140
+ const ticker = new TestTicker();
130
141
 
131
142
  const target = el();
132
143
  const ani = animate(target, {
133
144
  autoplay: false,
134
145
  duration: 10,
135
- x: 10
146
+ x: 10,
136
147
  });
137
148
  ani.seek(2);
138
149
 
139
150
  ticker.run();
140
- expect(target.style.transform)
141
- .toBe('translate3d(10.000px,0.000px,0.000px)');
151
+ expect(target.style.transform).toBe(
152
+ 'translate3d(10.000px,0.000px,0.000px)',
153
+ );
142
154
  });
143
155
 
144
156
  it('timeline controls', () => {
145
- const ticker = new TestTicker;
157
+ const ticker = new TestTicker();
146
158
 
147
159
  const tl = timeline();
148
160
  const target = el();
149
161
  tl.add(target, {
150
162
  x: 10,
151
- duration: 10
163
+ duration: 10,
152
164
  });
153
165
  tl.add(target, {
154
166
  x: 20,
155
- duration: 10
156
- })
167
+ duration: 10,
168
+ });
157
169
 
158
170
  tl.seekMs(10);
159
171
  ticker.run();
160
- expect(target.style.transform)
161
- .toBe('translate3d(10.000px,0.000px,0.000px)');
172
+ expect(target.style.transform).toBe(
173
+ 'translate3d(10.000px,0.000px,0.000px)',
174
+ );
162
175
 
163
176
  tl.play();
164
177
  ticker.run();
165
- expect(target.style.transform)
166
- .toBe('translate3d(20.000px,0.000px,0.000px)');
178
+ expect(target.style.transform).toBe(
179
+ 'translate3d(20.000px,0.000px,0.000px)',
180
+ );
167
181
 
168
182
  tl.reset();
169
183
  tl.play();
170
184
  ticker.run(10);
171
- expect(target.style.transform)
172
- .toBe('translate3d(10.000px,0.000px,0.000px)');
185
+ expect(target.style.transform).toBe(
186
+ 'translate3d(10.000px,0.000px,0.000px)',
187
+ );
173
188
 
174
189
  tl.reverse();
175
190
  ticker.run(5);
176
- expect(target.style.transform)
177
- .toBe('translate3d(5.000px,0.000px,0.000px)');
191
+ expect(target.style.transform).toBe(
192
+ 'translate3d(5.000px,0.000px,0.000px)',
193
+ );
178
194
 
179
195
  tl.reverse();
180
196
  ticker.run();
181
- expect(target.style.transform)
182
- .toBe('translate3d(20.000px,0.000px,0.000px)');
197
+ expect(target.style.transform).toBe(
198
+ 'translate3d(20.000px,0.000px,0.000px)',
199
+ );
183
200
 
184
201
  tl.reverse();
185
202
  tl.play();
@@ -188,21 +205,21 @@ describe('timeline', () => {
188
205
  });
189
206
 
190
207
  it('timeline events', () => {
191
- const ticker = new TestTicker;
208
+ const ticker = new TestTicker();
192
209
 
193
210
  const target = el();
194
211
  const tl = timeline()
195
212
  .add(target, {
196
213
  x: 50,
197
- duration: 10
214
+ duration: 10,
198
215
  })
199
216
  .add(target, {
200
217
  y: 50,
201
- duration: 10
218
+ duration: 10,
202
219
  });
203
220
 
204
221
  let endCounter = 0;
205
- tl.on('end', () => endCounter += 1);
222
+ tl.on('end', () => (endCounter += 1));
206
223
 
207
224
  tl.play();
208
225
  ticker.run(5);
@@ -219,8 +236,9 @@ describe('timeline', () => {
219
236
  tl.reverse();
220
237
  ticker.run();
221
238
  expect(endCounter).toBe(2);
222
- expect(target.style.transform)
223
- .toBe('translate3d(50.000px,50.000px,0.000px)');
239
+ expect(target.style.transform).toBe(
240
+ 'translate3d(50.000px,50.000px,0.000px)',
241
+ );
224
242
 
225
243
  tl.play();
226
244
  ticker.run();
@@ -233,27 +251,26 @@ describe('timeline', () => {
233
251
  });
234
252
 
235
253
  it('nested timeline', () => {
236
- const ticker = new TestTicker;
254
+ const ticker = new TestTicker();
237
255
 
238
256
  const target = el();
239
257
  const tl = timeline()
240
258
  .add(target, {
241
259
  width: 50,
242
- duration: 10
260
+ duration: 10,
243
261
  })
244
262
  .nest(tl => {
245
263
  tl.add(target, {
246
264
  opacity: 0,
247
- duration: 5
248
- })
249
- .add(target, {
265
+ duration: 5,
266
+ }).add(target, {
250
267
  opacity: 1,
251
- duration: 5
268
+ duration: 5,
252
269
  });
253
270
  })
254
271
  .add(target, {
255
272
  height: 50,
256
- duration: 10
273
+ duration: 10,
257
274
  })
258
275
  .play();
259
276
 
@@ -270,4 +287,4 @@ describe('timeline', () => {
270
287
  ticker.run(10);
271
288
  expect(target.style.height).toBe('50.000px');
272
289
  });
273
- });
290
+ });
@@ -1,14 +1,18 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import Timing, {
3
- STATE_BEFORE, STATE_START, STATE_RUNNING, STATE_ENDED, STATE_AFTER
4
- } from '../timing/timing.js';
3
+ STATE_BEFORE,
4
+ STATE_START,
5
+ STATE_RUNNING,
6
+ STATE_ENDED,
7
+ STATE_AFTER,
8
+ } from '../timing/Timing';
5
9
 
6
10
  describe('timing', () => {
7
11
  it('zero duration', () => {
8
12
  // if duration is zero the position is always 1
9
13
  // and the state is either BEFORE or AFTER
10
14
  const timing = new Timing({
11
- duration: 0
15
+ duration: 0,
12
16
  });
13
17
  expect(timing.duration).toBe(0);
14
18
  expect(timing.state).toBe(STATE_BEFORE);
@@ -21,7 +25,7 @@ describe('timing', () => {
21
25
  expect(timing.position).toBe(1);
22
26
  expect(timing.state).toBe(STATE_AFTER);
23
27
 
24
- timing.seek(.5);
28
+ timing.seek(0.5);
25
29
  expect(timing.position).toBe(1);
26
30
  expect(timing.state).toBe(STATE_AFTER);
27
31
 
@@ -41,7 +45,7 @@ describe('timing', () => {
41
45
  expect(timing.position).toBe(1);
42
46
  expect(timing.state).toBe(STATE_AFTER);
43
47
 
44
- timing.seekMs(.5);
48
+ timing.seekMs(0.5);
45
49
  expect(timing.position).toBe(1);
46
50
  expect(timing.state).toBe(STATE_AFTER);
47
51
 
@@ -52,7 +56,7 @@ describe('timing', () => {
52
56
 
53
57
  it('short timing', () => {
54
58
  const timing = new Timing({
55
- duration: 1
59
+ duration: 1,
56
60
  });
57
61
  expect(timing.duration).toBe(1);
58
62
  expect(timing.state).toBe(STATE_BEFORE);
@@ -65,8 +69,8 @@ describe('timing', () => {
65
69
  expect(timing.position).toBe(0);
66
70
  expect(timing.state).toBe(STATE_START);
67
71
 
68
- timing.seek(.5);
69
- expect(timing.position).toBe(.5);
72
+ timing.seek(0.5);
73
+ expect(timing.position).toBe(0.5);
70
74
  expect(timing.state).toBe(STATE_RUNNING);
71
75
 
72
76
  timing.seek(1);
@@ -85,8 +89,8 @@ describe('timing', () => {
85
89
  expect(timing.position).toBe(0);
86
90
  expect(timing.state).toBe(STATE_START);
87
91
 
88
- timing.seekMs(.5);
89
- expect(timing.position).toBe(.5);
92
+ timing.seekMs(0.5);
93
+ expect(timing.position).toBe(0.5);
90
94
  expect(timing.state).toBe(STATE_RUNNING);
91
95
 
92
96
  timing.seekMs(1);
@@ -100,25 +104,25 @@ describe('timing', () => {
100
104
 
101
105
  it('state management', () => {
102
106
  const timing = new Timing({
103
- duration: 100
107
+ duration: 100,
104
108
  });
105
109
 
106
110
  timing.advance(20);
107
111
  expect(timing.state).toBe(STATE_RUNNING);
108
- expect(timing.position).toBe(.2);
112
+ expect(timing.position).toBe(0.2);
109
113
 
110
114
  timing.advance(20);
111
115
  expect(timing.positionMs()).toBe(40);
112
116
  expect(timing.state).toBe(STATE_RUNNING);
113
- expect(timing.position).toBe(.4);
117
+ expect(timing.position).toBe(0.4);
114
118
 
115
119
  timing.advance(20);
116
120
  expect(timing.state).toBe(STATE_RUNNING);
117
- expect(Math.floor(timing.position * 10) / 10).toBe(.6);
121
+ expect(Math.floor(timing.position * 10) / 10).toBe(0.6);
118
122
 
119
123
  timing.advance(20);
120
124
  expect(timing.state).toBe(STATE_RUNNING);
121
- expect(timing.position).toBe(.8);
125
+ expect(timing.position).toBe(0.8);
122
126
 
123
127
  timing.advance(20);
124
128
  expect(timing.state).toBe(STATE_ENDED);
@@ -131,7 +135,7 @@ describe('timing', () => {
131
135
 
132
136
  it('reverse', () => {
133
137
  const timing = new Timing({
134
- duration: 100
138
+ duration: 100,
135
139
  });
136
140
 
137
141
  expect(timing.state).toBe(STATE_BEFORE);
@@ -181,9 +185,8 @@ describe('timing', () => {
181
185
  timing.advance(10);
182
186
  expect(timing.position).toBe(0.65);
183
187
 
184
-
185
188
  const timing2 = new Timing({
186
- duration: 100
189
+ duration: 100,
187
190
  });
188
191
 
189
192
  timing2.advance(100);
@@ -198,15 +201,15 @@ describe('timing', () => {
198
201
  expect(timing2.state).toBe(STATE_BEFORE);
199
202
  expect(timing2.position).toBe(1);
200
203
 
201
- timing2.seek(.25);
204
+ timing2.seek(0.25);
202
205
  expect(timing2.state).toBe(STATE_RUNNING);
203
- expect(timing2.position).toBe(.75);
206
+ expect(timing2.position).toBe(0.75);
204
207
  });
205
208
 
206
209
  it('repeat', () => {
207
210
  const timing = new Timing({
208
211
  duration: 100,
209
- repeat: -1
212
+ repeat: -1,
210
213
  });
211
214
 
212
215
  // >
@@ -267,4 +270,4 @@ describe('timing', () => {
267
270
  timing.advance(50);
268
271
  expect(timing.position).toBe(0.25);
269
272
  });
270
- });
273
+ });