chnobli 0.1.7 → 0.1.9

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 (225) hide show
  1. package/package.json +24 -11
  2. package/src/animation/Animation.ts +10 -6
  3. package/src/animation/public.ts +47 -10
  4. package/src/chnobli.ts +20 -11
  5. package/src/property/BasicProperty.ts +3 -3
  6. package/src/property/ClassProperty.ts +2 -2
  7. package/src/property/Property.ts +7 -5
  8. package/src/property/StyleProperty.ts +7 -7
  9. package/src/property/TransformProperty.ts +4 -4
  10. package/src/property/TransformXYProperty.ts +3 -3
  11. package/src/responsive/TestEvent.ts +1 -1
  12. package/src/scroll/Scroll.ts +174 -90
  13. package/src/scroll/index.ts +8 -0
  14. package/src/scroll/public.ts +23 -12
  15. package/src/stagger/stagger.ts +34 -14
  16. package/src/target/BaseTarget.old.ts +2 -2
  17. package/src/target/DomTarget.ts +3 -3
  18. package/src/target/ObjectTarget.ts +124 -0
  19. package/src/target/Target.ts +16 -3
  20. package/src/tests/properties.test.ts +54 -4
  21. package/src/tests/timeline.test.ts +3 -3
  22. package/src/tests/timing.test.ts +1 -1
  23. package/src/tests/usecases.test.ts +5 -5
  24. package/src/tests/values.test.ts +4 -4
  25. package/src/timeline/Nested.ts +7 -7
  26. package/src/timeline/{TimeLine.ts → Timeline.ts} +29 -9
  27. package/src/timeline/public.ts +198 -58
  28. package/src/timing/AnimationFrameTicker.ts +2 -2
  29. package/src/timing/TestTicker.ts +2 -2
  30. package/src/timing/Ticker.ts +1 -1
  31. package/src/timing/Timing.ts +38 -4
  32. package/src/utils/internal.ts +6 -3
  33. package/src/utils/utils.ts +18 -9
  34. package/src/values/ColorValue.ts +1 -1
  35. package/src/values/StyleValue.ts +15 -3
  36. package/tsconfig.build.json +2 -2
  37. package/tsconfig.json +2 -3
  38. package/.editorconfig +0 -11
  39. package/.github/workflows/ci.yaml +0 -34
  40. package/.prettierignore +0 -4
  41. package/.prettierrc +0 -6
  42. package/.vscode/settings.json +0 -4
  43. package/LICENSE.md +0 -21
  44. package/README.md +0 -5
  45. package/auto-docs/easing.js.html +0 -342
  46. package/auto-docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  47. package/auto-docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
  48. package/auto-docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  49. package/auto-docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  50. package/auto-docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  51. package/auto-docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  52. package/auto-docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  53. package/auto-docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
  54. package/auto-docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  55. package/auto-docs/fonts/OpenSans-Light-webfont.eot +0 -0
  56. package/auto-docs/fonts/OpenSans-Light-webfont.svg +0 -1831
  57. package/auto-docs/fonts/OpenSans-Light-webfont.woff +0 -0
  58. package/auto-docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  59. package/auto-docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  60. package/auto-docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  61. package/auto-docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  62. package/auto-docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
  63. package/auto-docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  64. package/auto-docs/global.html +0 -4810
  65. package/auto-docs/index.html +0 -65
  66. package/auto-docs/scripts/linenumber.js +0 -25
  67. package/auto-docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  68. package/auto-docs/scripts/prettify/lang-css.js +0 -2
  69. package/auto-docs/scripts/prettify/prettify.js +0 -28
  70. package/auto-docs/styles/jsdoc-default.css +0 -358
  71. package/auto-docs/styles/prettify-jsdoc.css +0 -111
  72. package/auto-docs/styles/prettify-tomorrow.css +0 -132
  73. package/dist/animation/Animation.d.ts +0 -36
  74. package/dist/animation/Animation.d.ts.map +0 -1
  75. package/dist/animation/Animation.js +0 -230
  76. package/dist/animation/Animation.js.map +0 -1
  77. package/dist/animation/animation.d.ts +0 -36
  78. package/dist/animation/animation.d.ts.map +0 -1
  79. package/dist/animation/animation.js +0 -230
  80. package/dist/animation/animation.js.map +0 -1
  81. package/dist/animation/public.d.ts +0 -55
  82. package/dist/animation/public.d.ts.map +0 -1
  83. package/dist/animation/public.js +0 -104
  84. package/dist/animation/public.js.map +0 -1
  85. package/dist/chnobli.d.ts +0 -15
  86. package/dist/chnobli.d.ts.map +0 -1
  87. package/dist/chnobli.js +0 -63
  88. package/dist/chnobli.js.map +0 -1
  89. package/dist/property/BasicProperty.d.ts +0 -38
  90. package/dist/property/BasicProperty.d.ts.map +0 -1
  91. package/dist/property/BasicProperty.js +0 -72
  92. package/dist/property/BasicProperty.js.map +0 -1
  93. package/dist/property/ClassProperty.d.ts +0 -32
  94. package/dist/property/ClassProperty.d.ts.map +0 -1
  95. package/dist/property/ClassProperty.js +0 -108
  96. package/dist/property/ClassProperty.js.map +0 -1
  97. package/dist/property/Property.d.ts +0 -13
  98. package/dist/property/Property.d.ts.map +0 -1
  99. package/dist/property/Property.js +0 -20
  100. package/dist/property/Property.js.map +0 -1
  101. package/dist/property/StyleProperty.d.ts +0 -25
  102. package/dist/property/StyleProperty.d.ts.map +0 -1
  103. package/dist/property/StyleProperty.js +0 -221
  104. package/dist/property/StyleProperty.js.map +0 -1
  105. package/dist/property/TransformProperty.d.ts +0 -15
  106. package/dist/property/TransformProperty.d.ts.map +0 -1
  107. package/dist/property/TransformProperty.js +0 -43
  108. package/dist/property/TransformProperty.js.map +0 -1
  109. package/dist/property/TransformXYProperty.d.ts +0 -28
  110. package/dist/property/TransformXYProperty.d.ts.map +0 -1
  111. package/dist/property/TransformXYProperty.js +0 -65
  112. package/dist/property/TransformXYProperty.js.map +0 -1
  113. package/dist/responsive/ResponsiveEvent.d.ts +0 -17
  114. package/dist/responsive/ResponsiveEvent.d.ts.map +0 -1
  115. package/dist/responsive/ResponsiveEvent.js +0 -45
  116. package/dist/responsive/ResponsiveEvent.js.map +0 -1
  117. package/dist/responsive/TestEvent.d.ts +0 -11
  118. package/dist/responsive/TestEvent.d.ts.map +0 -1
  119. package/dist/responsive/TestEvent.js +0 -26
  120. package/dist/responsive/TestEvent.js.map +0 -1
  121. package/dist/responsive/event.d.ts +0 -10
  122. package/dist/responsive/event.d.ts.map +0 -1
  123. package/dist/responsive/event.js +0 -39
  124. package/dist/responsive/event.js.map +0 -1
  125. package/dist/scroll/Scroll.d.ts +0 -27
  126. package/dist/scroll/Scroll.d.ts.map +0 -1
  127. package/dist/scroll/Scroll.js +0 -132
  128. package/dist/scroll/Scroll.js.map +0 -1
  129. package/dist/scroll/ScrollEvent.d.ts +0 -17
  130. package/dist/scroll/ScrollEvent.d.ts.map +0 -1
  131. package/dist/scroll/ScrollEvent.js +0 -39
  132. package/dist/scroll/ScrollEvent.js.map +0 -1
  133. package/dist/scroll/public.d.ts +0 -7
  134. package/dist/scroll/public.d.ts.map +0 -1
  135. package/dist/scroll/public.js +0 -17
  136. package/dist/scroll/public.js.map +0 -1
  137. package/dist/stagger/stagger.d.ts +0 -13
  138. package/dist/stagger/stagger.d.ts.map +0 -1
  139. package/dist/stagger/stagger.js +0 -35
  140. package/dist/stagger/stagger.js.map +0 -1
  141. package/dist/target/BaseTarget.old.d.ts +0 -33
  142. package/dist/target/BaseTarget.old.d.ts.map +0 -1
  143. package/dist/target/BaseTarget.old.js +0 -73
  144. package/dist/target/BaseTarget.old.js.map +0 -1
  145. package/dist/target/DomTarget.d.ts +0 -41
  146. package/dist/target/DomTarget.d.ts.map +0 -1
  147. package/dist/target/DomTarget.js +0 -230
  148. package/dist/target/DomTarget.js.map +0 -1
  149. package/dist/target/Target.d.ts +0 -22
  150. package/dist/target/Target.d.ts.map +0 -1
  151. package/dist/target/Target.js +0 -21
  152. package/dist/target/Target.js.map +0 -1
  153. package/dist/target/TestDomNode.d.ts +0 -14
  154. package/dist/target/TestDomNode.d.ts.map +0 -1
  155. package/dist/target/TestDomNode.js +0 -55
  156. package/dist/target/TestDomNode.js.map +0 -1
  157. package/dist/timeline/Nested.d.ts +0 -30
  158. package/dist/timeline/Nested.d.ts.map +0 -1
  159. package/dist/timeline/Nested.js +0 -51
  160. package/dist/timeline/Nested.js.map +0 -1
  161. package/dist/timeline/TimeLine.d.ts +0 -32
  162. package/dist/timeline/TimeLine.d.ts.map +0 -1
  163. package/dist/timeline/TimeLine.js +0 -288
  164. package/dist/timeline/TimeLine.js.map +0 -1
  165. package/dist/timeline/public.d.ts +0 -120
  166. package/dist/timeline/public.d.ts.map +0 -1
  167. package/dist/timeline/public.js +0 -301
  168. package/dist/timeline/public.js.map +0 -1
  169. package/dist/timing/AnimationFrameTicker.d.ts +0 -32
  170. package/dist/timing/AnimationFrameTicker.d.ts.map +0 -1
  171. package/dist/timing/AnimationFrameTicker.js +0 -134
  172. package/dist/timing/AnimationFrameTicker.js.map +0 -1
  173. package/dist/timing/Ease.d.ts +0 -6
  174. package/dist/timing/Ease.d.ts.map +0 -1
  175. package/dist/timing/Ease.js +0 -15
  176. package/dist/timing/Ease.js.map +0 -1
  177. package/dist/timing/TestTicker.d.ts +0 -19
  178. package/dist/timing/TestTicker.d.ts.map +0 -1
  179. package/dist/timing/TestTicker.js +0 -81
  180. package/dist/timing/TestTicker.js.map +0 -1
  181. package/dist/timing/Ticker.d.ts +0 -14
  182. package/dist/timing/Ticker.d.ts.map +0 -1
  183. package/dist/timing/Ticker.js +0 -2
  184. package/dist/timing/Ticker.js.map +0 -1
  185. package/dist/timing/Timing.d.ts +0 -62
  186. package/dist/timing/Timing.d.ts.map +0 -1
  187. package/dist/timing/Timing.js +0 -257
  188. package/dist/timing/Timing.js.map +0 -1
  189. package/dist/timing/easing.d.ts +0 -158
  190. package/dist/timing/easing.d.ts.map +0 -1
  191. package/dist/timing/easing.js +0 -273
  192. package/dist/timing/easing.js.map +0 -1
  193. package/dist/utils/Events.d.ts +0 -9
  194. package/dist/utils/Events.d.ts.map +0 -1
  195. package/dist/utils/Events.js +0 -35
  196. package/dist/utils/Events.js.map +0 -1
  197. package/dist/utils/internal.d.ts +0 -2
  198. package/dist/utils/internal.d.ts.map +0 -1
  199. package/dist/utils/internal.js +0 -6
  200. package/dist/utils/internal.js.map +0 -1
  201. package/dist/utils/motionpath.d.ts +0 -16
  202. package/dist/utils/motionpath.d.ts.map +0 -1
  203. package/dist/utils/motionpath.js +0 -41
  204. package/dist/utils/motionpath.js.map +0 -1
  205. package/dist/utils/utils.d.ts +0 -43
  206. package/dist/utils/utils.d.ts.map +0 -1
  207. package/dist/utils/utils.js +0 -93
  208. package/dist/utils/utils.js.map +0 -1
  209. package/dist/values/ColorValue.d.ts +0 -12
  210. package/dist/values/ColorValue.d.ts.map +0 -1
  211. package/dist/values/ColorValue.js +0 -133
  212. package/dist/values/ColorValue.js.map +0 -1
  213. package/dist/values/StyleValue.d.ts +0 -40
  214. package/dist/values/StyleValue.d.ts.map +0 -1
  215. package/dist/values/StyleValue.js +0 -149
  216. package/dist/values/StyleValue.js.map +0 -1
  217. package/dist/values/Value.d.ts +0 -13
  218. package/dist/values/Value.d.ts.map +0 -1
  219. package/dist/values/Value.js +0 -38
  220. package/dist/values/Value.js.map +0 -1
  221. package/dist/values/defaultcolors.d.ts +0 -2
  222. package/dist/values/defaultcolors.d.ts.map +0 -1
  223. package/dist/values/defaultcolors.js +0 -149
  224. package/dist/values/defaultcolors.js.map +0 -1
  225. package/docs/INDEX.md +0 -15
@@ -1,5 +1,5 @@
1
- import { GlobalTargets } from './AnimationFrameTicker';
2
- import Ticker, { Callback } from './Ticker';
1
+ import { GlobalTargets } from './AnimationFrameTicker.js';
2
+ import Ticker, { Callback } from './Ticker.js';
3
3
 
4
4
  export default class TestTicker implements Ticker {
5
5
  private _listeners: Set<Callback>;
@@ -1,4 +1,4 @@
1
- import { Target } from '../target/Target';
1
+ import { Target } from '../target/Target.js';
2
2
 
3
3
  export type Callback = (change: number, api: { remove: () => void }) => void;
4
4
 
@@ -1,4 +1,4 @@
1
- import { takeProp } from '../utils/internal';
1
+ import { takeProp } from '../utils/internal.js';
2
2
 
3
3
  export const STATE_BEFORE = 0;
4
4
  /// start only occurs if the current position is exactly 0 or 1 if reversed
@@ -12,6 +12,14 @@ export type Position = {
12
12
  progress: number;
13
13
  };
14
14
 
15
+ export type TimingProps = {
16
+ duration: number;
17
+ ease?: (t: number) => number;
18
+ repeat?: number;
19
+ alternate?: boolean;
20
+ reversed?: boolean;
21
+ };
22
+
15
23
  /**
16
24
  * This class handles everything timing related
17
25
  *
@@ -58,7 +66,7 @@ export default class Timing {
58
66
  alternate
59
67
  }
60
68
  */
61
- constructor(props: Record<string, any>) {
69
+ constructor(props: TimingProps) {
62
70
  // these vars are only readonly
63
71
  // use functions to update them
64
72
 
@@ -90,6 +98,7 @@ export default class Timing {
90
98
  }
91
99
 
92
100
  positionMs() {
101
+ // todo should this not return pos * duration?
93
102
  return this.position * this.iterDuration;
94
103
  }
95
104
 
@@ -132,6 +141,31 @@ export default class Timing {
132
141
  }
133
142
 
134
143
  this._updateProgress(ms / this.iterDuration);
144
+
145
+ // return this.seek(this.normalizeMs(ms));
146
+ }
147
+
148
+ normalizeMs(ms: number) {
149
+ if (this.iterDuration <= 0) {
150
+ return Math.sign(ms);
151
+ }
152
+
153
+ const pos = ms / this.iterDuration;
154
+
155
+ if (this.isFinite()) {
156
+ return pos / (this.repeat + 1);
157
+ }
158
+
159
+ return pos;
160
+ }
161
+
162
+ // todo how to call this
163
+ positionLinear(): number {
164
+ if (this.isFinite()) {
165
+ return this._progress / (this.repeat + 1);
166
+ }
167
+
168
+ return this._progress;
135
169
  }
136
170
 
137
171
  // should be between 0-1 if outside might change the state
@@ -241,7 +275,7 @@ export default class Timing {
241
275
  }
242
276
  }
243
277
 
244
- export function newTiming(props: Record<string, any>) {
278
+ export function newTiming(props: Record<string, any>): Timing {
245
279
  const nProps = {
246
280
  duration: parseDuration(takeProp(props, 'duration', 1000)),
247
281
  ease: parseEase(takeProp(props, 'ease', null)),
@@ -253,7 +287,7 @@ export function newTiming(props: Record<string, any>) {
253
287
  return new Timing(nProps);
254
288
  }
255
289
 
256
- export function parseDuration(dur: any) {
290
+ export function parseDuration(dur: any): number {
257
291
  if (typeof dur !== 'number') throw new Error('duration is not a number');
258
292
 
259
293
  dur = Math.round(dur);
@@ -1,8 +1,11 @@
1
- export function takeProp(
1
+ /**
2
+ * Take a property from an object and delete it from the object.
3
+ */
4
+ export function takeProp<T>(
2
5
  props: Record<string, any>,
3
6
  name: string,
4
- def: any = null,
5
- ): any {
7
+ def: T,
8
+ ): T {
6
9
  const v = props[name] ?? def;
7
10
  delete props[name];
8
11
 
@@ -1,5 +1,5 @@
1
- import { Callback } from '../responsive/ResponsiveEvent';
2
- import { curve } from './motionpath';
1
+ import { Callback } from '../responsive/ResponsiveEvent.js';
2
+ import { curve } from './motionpath.js';
3
3
 
4
4
  export { curve };
5
5
 
@@ -59,10 +59,24 @@ export function chars(element: HTMLElement) {
59
59
  .filter(c => !!c);
60
60
  }
61
61
 
62
+ export type WordCallback = (element: HTMLElement, word: string) => HTMLElement;
63
+
64
+ function defWordCallback(element: HTMLElement, word: string): HTMLElement {
65
+ const span = document.createElement('span');
66
+ span.textContent = word;
67
+ span.style.display = 'inline-block';
68
+ element.appendChild(span);
69
+
70
+ return span;
71
+ }
72
+
62
73
  /**
63
74
  * Converts an element with text into span with words
64
75
  */
65
- export function words(element: HTMLElement) {
76
+ export function words(
77
+ element: HTMLElement,
78
+ cb: WordCallback = defWordCallback,
79
+ ) {
66
80
  if (element.dataset.processedWords) return Array.from(element.children);
67
81
 
68
82
  const words = element.textContent!.split(/(\s+)/);
@@ -77,12 +91,7 @@ export function words(element: HTMLElement) {
77
91
  return null;
78
92
  }
79
93
 
80
- const span = document.createElement('span');
81
- span.textContent = word;
82
- span.style.display = 'inline-block';
83
- element.appendChild(span);
84
-
85
- return span;
94
+ return cb(element, word);
86
95
  })
87
96
  .filter(w => !!w);
88
97
  }
@@ -1,4 +1,4 @@
1
- import { COLORS } from './defaultcolors';
1
+ import { COLORS } from './defaultcolors.js';
2
2
 
3
3
  export type RGBA = [number, number, number, number];
4
4
  export type HSLA = [number, number, number, number];
@@ -1,5 +1,5 @@
1
- import Value from './Value';
2
- import ColorValue from './ColorValue';
1
+ import Value from './Value.js';
2
+ import ColorValue from './ColorValue.js';
3
3
 
4
4
  const AT_THE_END_VALUES = ['none', 'hidden'];
5
5
 
@@ -168,7 +168,7 @@ export default class StyleValue {
168
168
  );
169
169
  }
170
170
 
171
- toString() {
171
+ toString(): string {
172
172
  switch (this.inner.kind) {
173
173
  case 'text':
174
174
  return this.inner.values;
@@ -183,4 +183,16 @@ export default class StyleValue {
183
183
  throw new Error('unknown kind ' + this.kind);
184
184
  }
185
185
  }
186
+
187
+ // returns the value as a number if possible otherwise as a string
188
+ toMixed(): string | number {
189
+ if (this.inner.kind !== 'values' || this.inner.values.length !== 1)
190
+ return this.toString();
191
+
192
+ // length already checks that kind is values
193
+ const val = (this.inner.values as Value[])[0];
194
+
195
+ if (val.unit) return this.toString();
196
+ return val.num;
197
+ }
186
198
  }
@@ -2,8 +2,8 @@
2
2
  "compilerOptions": {
3
3
  "target": "ESNext",
4
4
  "useDefineForClassFields": true,
5
- "module": "ESNext",
6
- "moduleResolution": "Bundler",
5
+ "module": "NodeNext",
6
+ "moduleResolution": "NodeNext",
7
7
  "declaration": true,
8
8
  "declarationMap": true,
9
9
  "sourceMap": true,
package/tsconfig.json CHANGED
@@ -2,12 +2,11 @@
2
2
  "compilerOptions": {
3
3
  "target": "ESNext",
4
4
  "useDefineForClassFields": true,
5
- "module": "ESNext",
6
- "moduleResolution": "Bundler",
5
+ "module": "NodeNext",
6
+ "moduleResolution": "NodeNext",
7
7
  "declaration": true,
8
8
  "declarationMap": true,
9
9
  "sourceMap": true,
10
- "baseUrl": ".",
11
10
  "allowJs": true,
12
11
  "checkJs": false,
13
12
  "isolatedModules": true,
package/.editorconfig DELETED
@@ -1,11 +0,0 @@
1
- [*]
2
- end_of_line = lf
3
-
4
- [*{yaml}]
5
- indent_style = tab
6
- indent_size = 2
7
-
8
- [*{js,ts,json,ts,md}]
9
- indent_size = 4
10
- charset = utf-8
11
- indent_style = tab
@@ -1,34 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches: [ master ]
6
- pull_request:
7
- branches: [ master ]
8
-
9
- jobs:
10
- lint:
11
- runs-on: ubuntu-latest
12
-
13
- steps:
14
- - name: Checkout code
15
- uses: actions/checkout@v3
16
-
17
- - name: Install dependencies
18
- run: npm ci
19
-
20
- - name: Lint
21
- run: npm run lint
22
-
23
- test:
24
- runs-on: ubuntu-latest
25
-
26
- steps:
27
- - name: Checkout code
28
- uses: actions/checkout@v3
29
-
30
- - name: Install dependencies
31
- run: npm ci
32
-
33
- - name: Run tests
34
- run: npm run test:once
package/.prettierignore DELETED
@@ -1,4 +0,0 @@
1
- /*.md
2
- /*.json
3
- /*.yaml
4
- /.github/*
package/.prettierrc DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "tabWidth": 4,
3
- "useTabs": true,
4
- "singleQuote": true,
5
- "arrowParens": "avoid"
6
- }
@@ -1,4 +0,0 @@
1
- {
2
- "editor.formatOnPaste": true,
3
- "editor.formatOnSave": true
4
- }
package/LICENSE.md DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Sören Meier
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/README.md DELETED
@@ -1,5 +0,0 @@
1
-
2
- ## Chnobli js
3
-
4
- ## Version 0.1 unstable
5
- Version 0.1 is unstable the api might change at any version number
@@ -1,342 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <title>JSDoc: Source: easing.js</title>
6
-
7
- <script src="scripts/prettify/prettify.js"> </script>
8
- <script src="scripts/prettify/lang-css.js"> </script>
9
- <!--[if lt IE 9]>
10
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
- <![endif]-->
12
- <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
- <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
- </head>
15
-
16
- <body>
17
-
18
- <div id="main">
19
-
20
- <h1 class="page-title">Source: easing.js</h1>
21
-
22
-
23
-
24
-
25
-
26
-
27
- <section>
28
- <article>
29
- <pre class="prettyprint source linenums"><code>/*
30
- Adapted from https://github.com/sveltejs/svelte
31
- Distributed under MIT License https://github.com/sveltejs/svelte/blob/main/LICENSE.md
32
- */
33
-
34
- import bezierEasing from 'bezier-easing';
35
-
36
- /**
37
- * @param {number} t
38
- * @returns {number}
39
- */
40
- export function linear(t) {
41
- return t;
42
- }
43
-
44
- /**
45
- * @param {number} t
46
- * @returns {number}
47
- */
48
- export function backInOut(t) {
49
- const s = 1.70158 * 1.525;
50
- if ((t *= 2) &lt; 1) return 0.5 * (t * t * ((s + 1) * t - s));
51
- return 0.5 * ((t -= 2) * t * ((s + 1) * t + s) + 2);
52
- }
53
-
54
- /**
55
- * @param {number} t
56
- * @returns {number}
57
- */
58
- export function backIn(t) {
59
- const s = 1.70158;
60
- return t * t * ((s + 1) * t - s);
61
- }
62
-
63
- /**
64
- * @param {number} t
65
- * @returns {number}
66
- */
67
- export function backOut(t) {
68
- const s = 1.70158;
69
- return --t * t * ((s + 1) * t + s) + 1;
70
- }
71
-
72
- /**
73
- * @param {number} t
74
- * @returns {number}
75
- */
76
- export function bounceOut(t) {
77
- const a = 4.0 / 11.0;
78
- const b = 8.0 / 11.0;
79
- const c = 9.0 / 10.0;
80
- const ca = 4356.0 / 361.0;
81
- const cb = 35442.0 / 1805.0;
82
- const cc = 16061.0 / 1805.0;
83
- const t2 = t * t;
84
- return t &lt; a
85
- ? 7.5625 * t2
86
- : t &lt; b
87
- ? 9.075 * t2 - 9.9 * t + 3.4
88
- : t &lt; c
89
- ? ca * t2 - cb * t + cc
90
- : 10.8 * t * t - 20.52 * t + 10.72;
91
- }
92
-
93
- /**
94
- * @param {number} t
95
- * @returns {number}
96
- */
97
- export function bounceInOut(t) {
98
- return t &lt; 0.5 ? 0.5 * (1.0 - bounceOut(1.0 - t * 2.0)) : 0.5 * bounceOut(t * 2.0 - 1.0) + 0.5;
99
- }
100
-
101
- /**
102
- * @param {number} t
103
- * @returns {number}
104
- */
105
- export function bounceIn(t) {
106
- return 1.0 - bounceOut(1.0 - t);
107
- }
108
-
109
- /**
110
- * @param {number} t
111
- * @returns {number}
112
- */
113
- export function circInOut(t) {
114
- if ((t *= 2) &lt; 1) return -0.5 * (Math.sqrt(1 - t * t) - 1);
115
- return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
116
- }
117
-
118
- /**
119
- * @param {number} t
120
- * @returns {number}
121
- */
122
- export function circIn(t) {
123
- return 1.0 - Math.sqrt(1.0 - t * t);
124
- }
125
-
126
- /**
127
- * @param {number} t
128
- * @returns {number}
129
- */
130
- export function circOut(t) {
131
- return Math.sqrt(1 - --t * t);
132
- }
133
-
134
- /**
135
- * @param {number} t
136
- * @returns {number}
137
- */
138
- export function cubicInOut(t) {
139
- return t &lt; 0.5 ? 4.0 * t * t * t : 0.5 * Math.pow(2.0 * t - 2.0, 3.0) + 1.0;
140
- }
141
-
142
- /**
143
- * @param {number} t
144
- * @returns {number}
145
- */
146
- export function cubicIn(t) {
147
- return t * t * t;
148
- }
149
-
150
- /**
151
- * @param {number} t
152
- * @returns {number}
153
- */
154
- export function cubicOut(t) {
155
- const f = t - 1.0;
156
- return f * f * f + 1.0;
157
- }
158
-
159
- /**
160
- * @param {number} t
161
- * @returns {number}
162
- */
163
- export function elasticInOut(t) {
164
- return t &lt; 0.5
165
- ? 0.5 * Math.sin(((+13.0 * Math.PI) / 2) * 2.0 * t) * Math.pow(2.0, 10.0 * (2.0 * t - 1.0))
166
- : 0.5 *
167
- Math.sin(((-13.0 * Math.PI) / 2) * (2.0 * t - 1.0 + 1.0)) *
168
- Math.pow(2.0, -10.0 * (2.0 * t - 1.0)) +
169
- 1.0;
170
- }
171
-
172
- /**
173
- * @param {number} t
174
- * @returns {number}
175
- */
176
- export function elasticIn(t) {
177
- return Math.sin((13.0 * t * Math.PI) / 2) * Math.pow(2.0, 10.0 * (t - 1.0));
178
- }
179
-
180
- /**
181
- * @param {number} t
182
- * @returns {number}
183
- */
184
- export function elasticOut(t) {
185
- return Math.sin((-13.0 * (t + 1.0) * Math.PI) / 2) * Math.pow(2.0, -10.0 * t) + 1.0;
186
- }
187
-
188
- /**
189
- * @param {number} t
190
- * @returns {number}
191
- */
192
- export function expoInOut(t) {
193
- return t === 0.0 || t === 1.0
194
- ? t
195
- : t &lt; 0.5
196
- ? +0.5 * Math.pow(2.0, 20.0 * t - 10.0)
197
- : -0.5 * Math.pow(2.0, 10.0 - t * 20.0) + 1.0;
198
- }
199
-
200
- /**
201
- * @param {number} t
202
- * @returns {number}
203
- */
204
- export function expoIn(t) {
205
- return t === 0.0 ? t : Math.pow(2.0, 10.0 * (t - 1.0));
206
- }
207
-
208
- /**
209
- * @param {number} t
210
- * @returns {number}
211
- */
212
- export function expoOut(t) {
213
- return t === 1.0 ? t : 1.0 - Math.pow(2.0, -10.0 * t);
214
- }
215
-
216
- /**
217
- * @param {number} t
218
- * @returns {number}
219
- */
220
- export function quadInOut(t) {
221
- t /= 0.5;
222
- if (t &lt; 1) return 0.5 * t * t;
223
- t--;
224
- return -0.5 * (t * (t - 2) - 1);
225
- }
226
-
227
- /**
228
- * @param {number} t
229
- * @returns {number}
230
- */
231
- export function quadIn(t) {
232
- return t * t;
233
- }
234
-
235
- /**
236
- * @param {number} t
237
- * @returns {number}
238
- */
239
- export function quadOut(t) {
240
- return -t * (t - 2.0);
241
- }
242
-
243
- /**
244
- * @param {number} t
245
- * @returns {number}
246
- */
247
- export function quartInOut(t) {
248
- return t &lt; 0.5 ? +8.0 * Math.pow(t, 4.0) : -8.0 * Math.pow(t - 1.0, 4.0) + 1.0;
249
- }
250
-
251
- /**
252
- * @param {number} t
253
- * @returns {number}
254
- */
255
- export function quartIn(t) {
256
- return Math.pow(t, 4.0);
257
- }
258
-
259
- /**
260
- * @param {number} t
261
- * @returns {number}
262
- */
263
- export function quartOut(t) {
264
- return Math.pow(t - 1.0, 3.0) * (1.0 - t) + 1.0;
265
- }
266
-
267
- /**
268
- * @param {number} t
269
- * @returns {number}
270
- */
271
- export function quintInOut(t) {
272
- if ((t *= 2) &lt; 1) return 0.5 * t * t * t * t * t;
273
- return 0.5 * ((t -= 2) * t * t * t * t + 2);
274
- }
275
-
276
- /**
277
- * @param {number} t
278
- * @returns {number}
279
- */
280
- export function quintIn(t) {
281
- return t * t * t * t * t;
282
- }
283
-
284
- /**
285
- * @param {number} t
286
- * @returns {number}
287
- */
288
- export function quintOut(t) {
289
- return --t * t * t * t * t + 1;
290
- }
291
-
292
- /**
293
- * @param {number} t
294
- * @returns {number}
295
- */
296
- export function sineInOut(t) {
297
- return -0.5 * (Math.cos(Math.PI * t) - 1);
298
- }
299
-
300
- /**
301
- * @param {number} t
302
- * @returns {number}
303
- */
304
- export function sineIn(t) {
305
- const v = Math.cos(t * Math.PI * 0.5);
306
- if (Math.abs(v) &lt; 1e-14) return 1;
307
- else return 1 - v;
308
- }
309
-
310
- /**
311
- * @param {number} t
312
- * @returns {number}
313
- */
314
- export function sineOut(t) {
315
- return Math.sin((t * Math.PI) / 2);
316
- }
317
-
318
- export function cubicBezier(x1, y1, x2, y2) {
319
- return bezierEasing(x1, y1, x2, y2);
320
- }</code></pre>
321
- </article>
322
- </section>
323
-
324
-
325
-
326
-
327
- </div>
328
-
329
- <nav>
330
- <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#backIn">backIn</a></li><li><a href="global.html#backInOut">backInOut</a></li><li><a href="global.html#backOut">backOut</a></li><li><a href="global.html#bounceIn">bounceIn</a></li><li><a href="global.html#bounceInOut">bounceInOut</a></li><li><a href="global.html#bounceOut">bounceOut</a></li><li><a href="global.html#circIn">circIn</a></li><li><a href="global.html#circInOut">circInOut</a></li><li><a href="global.html#circOut">circOut</a></li><li><a href="global.html#cubicIn">cubicIn</a></li><li><a href="global.html#cubicInOut">cubicInOut</a></li><li><a href="global.html#cubicOut">cubicOut</a></li><li><a href="global.html#elasticIn">elasticIn</a></li><li><a href="global.html#elasticInOut">elasticInOut</a></li><li><a href="global.html#elasticOut">elasticOut</a></li><li><a href="global.html#expoIn">expoIn</a></li><li><a href="global.html#expoInOut">expoInOut</a></li><li><a href="global.html#expoOut">expoOut</a></li><li><a href="global.html#linear">linear</a></li><li><a href="global.html#quadIn">quadIn</a></li><li><a href="global.html#quadInOut">quadInOut</a></li><li><a href="global.html#quadOut">quadOut</a></li><li><a href="global.html#quartIn">quartIn</a></li><li><a href="global.html#quartInOut">quartInOut</a></li><li><a href="global.html#quartOut">quartOut</a></li><li><a href="global.html#quintIn">quintIn</a></li><li><a href="global.html#quintInOut">quintInOut</a></li><li><a href="global.html#quintOut">quintOut</a></li><li><a href="global.html#sineIn">sineIn</a></li><li><a href="global.html#sineInOut">sineInOut</a></li><li><a href="global.html#sineOut">sineOut</a></li></ul>
331
- </nav>
332
-
333
- <br class="clear">
334
-
335
- <footer>
336
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Sat Jan 13 2024 11:54:27 GMT+0100 (Central European Standard Time)
337
- </footer>
338
-
339
- <script> prettyPrint(); </script>
340
- <script src="scripts/linenumber.js"> </script>
341
- </body>
342
- </html>