chnobli 0.1.4 → 0.1.6
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/.prettierignore +4 -0
- package/.prettierrc +6 -0
- package/.vscode/settings.json +4 -0
- package/auto-docs/easing.js.html +342 -0
- package/auto-docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/auto-docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
- package/auto-docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/auto-docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/auto-docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
- package/auto-docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/auto-docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/auto-docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
- package/auto-docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/auto-docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/auto-docs/fonts/OpenSans-Light-webfont.svg +1831 -0
- package/auto-docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/auto-docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/auto-docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
- package/auto-docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/auto-docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/auto-docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
- package/auto-docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/auto-docs/global.html +4810 -0
- package/auto-docs/index.html +65 -0
- package/auto-docs/scripts/linenumber.js +25 -0
- package/auto-docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/auto-docs/scripts/prettify/lang-css.js +2 -0
- package/auto-docs/scripts/prettify/prettify.js +28 -0
- package/auto-docs/styles/jsdoc-default.css +358 -0
- package/auto-docs/styles/prettify-jsdoc.css +111 -0
- package/auto-docs/styles/prettify-tomorrow.css +132 -0
- package/dist/animation/Animation.d.ts +36 -0
- package/dist/animation/Animation.d.ts.map +1 -0
- package/dist/animation/Animation.js +230 -0
- package/dist/animation/Animation.js.map +1 -0
- package/dist/animation/animation.d.ts +36 -0
- package/dist/animation/animation.d.ts.map +1 -0
- package/dist/animation/animation.js +230 -0
- package/dist/animation/animation.js.map +1 -0
- package/dist/animation/public.d.ts +55 -0
- package/dist/animation/public.d.ts.map +1 -0
- package/dist/animation/public.js +104 -0
- package/dist/animation/public.js.map +1 -0
- package/dist/chnobli.d.ts +15 -0
- package/dist/chnobli.d.ts.map +1 -0
- package/dist/chnobli.js +63 -0
- package/dist/chnobli.js.map +1 -0
- package/dist/property/BasicProperty.d.ts +38 -0
- package/dist/property/BasicProperty.d.ts.map +1 -0
- package/dist/property/BasicProperty.js +72 -0
- package/dist/property/BasicProperty.js.map +1 -0
- package/dist/property/ClassProperty.d.ts +32 -0
- package/dist/property/ClassProperty.d.ts.map +1 -0
- package/dist/property/ClassProperty.js +108 -0
- package/dist/property/ClassProperty.js.map +1 -0
- package/dist/property/Property.d.ts +13 -0
- package/dist/property/Property.d.ts.map +1 -0
- package/dist/property/Property.js +20 -0
- package/dist/property/Property.js.map +1 -0
- package/dist/property/StyleProperty.d.ts +25 -0
- package/dist/property/StyleProperty.d.ts.map +1 -0
- package/dist/property/StyleProperty.js +221 -0
- package/dist/property/StyleProperty.js.map +1 -0
- package/dist/property/TransformProperty.d.ts +15 -0
- package/dist/property/TransformProperty.d.ts.map +1 -0
- package/dist/property/TransformProperty.js +43 -0
- package/dist/property/TransformProperty.js.map +1 -0
- package/dist/property/TransformXYProperty.d.ts +28 -0
- package/dist/property/TransformXYProperty.d.ts.map +1 -0
- package/dist/property/TransformXYProperty.js +65 -0
- package/dist/property/TransformXYProperty.js.map +1 -0
- package/dist/responsive/ResponsiveEvent.d.ts +17 -0
- package/dist/responsive/ResponsiveEvent.d.ts.map +1 -0
- package/dist/responsive/ResponsiveEvent.js +45 -0
- package/dist/responsive/ResponsiveEvent.js.map +1 -0
- package/dist/responsive/TestEvent.d.ts +11 -0
- package/dist/responsive/TestEvent.d.ts.map +1 -0
- package/dist/responsive/TestEvent.js +26 -0
- package/dist/responsive/TestEvent.js.map +1 -0
- package/dist/responsive/event.d.ts +10 -0
- package/dist/responsive/event.d.ts.map +1 -0
- package/dist/responsive/event.js +39 -0
- package/dist/responsive/event.js.map +1 -0
- package/dist/scroll/Scroll.d.ts +27 -0
- package/dist/scroll/Scroll.d.ts.map +1 -0
- package/dist/scroll/Scroll.js +132 -0
- package/dist/scroll/Scroll.js.map +1 -0
- package/dist/scroll/ScrollEvent.d.ts +17 -0
- package/dist/scroll/ScrollEvent.d.ts.map +1 -0
- package/dist/scroll/ScrollEvent.js +39 -0
- package/dist/scroll/ScrollEvent.js.map +1 -0
- package/dist/scroll/public.d.ts +7 -0
- package/dist/scroll/public.d.ts.map +1 -0
- package/dist/scroll/public.js +17 -0
- package/dist/scroll/public.js.map +1 -0
- package/dist/stagger/stagger.d.ts +13 -0
- package/dist/stagger/stagger.d.ts.map +1 -0
- package/dist/stagger/stagger.js +35 -0
- package/dist/stagger/stagger.js.map +1 -0
- package/dist/target/BaseTarget.old.d.ts +33 -0
- package/dist/target/BaseTarget.old.d.ts.map +1 -0
- package/dist/target/BaseTarget.old.js +73 -0
- package/dist/target/BaseTarget.old.js.map +1 -0
- package/dist/target/DomTarget.d.ts +41 -0
- package/dist/target/DomTarget.d.ts.map +1 -0
- package/dist/target/DomTarget.js +230 -0
- package/dist/target/DomTarget.js.map +1 -0
- package/dist/target/Target.d.ts +22 -0
- package/dist/target/Target.d.ts.map +1 -0
- package/dist/target/Target.js +21 -0
- package/dist/target/Target.js.map +1 -0
- package/dist/target/TestDomNode.d.ts +14 -0
- package/dist/target/TestDomNode.d.ts.map +1 -0
- package/dist/target/TestDomNode.js +55 -0
- package/dist/target/TestDomNode.js.map +1 -0
- package/dist/timeline/Nested.d.ts +30 -0
- package/dist/timeline/Nested.d.ts.map +1 -0
- package/dist/timeline/Nested.js +51 -0
- package/dist/timeline/Nested.js.map +1 -0
- package/dist/timeline/TimeLine.d.ts +32 -0
- package/dist/timeline/TimeLine.d.ts.map +1 -0
- package/dist/timeline/TimeLine.js +288 -0
- package/dist/timeline/TimeLine.js.map +1 -0
- package/dist/timeline/public.d.ts +120 -0
- package/dist/timeline/public.d.ts.map +1 -0
- package/dist/timeline/public.js +301 -0
- package/dist/timeline/public.js.map +1 -0
- package/dist/timing/AnimationFrameTicker.d.ts +32 -0
- package/dist/timing/AnimationFrameTicker.d.ts.map +1 -0
- package/dist/timing/AnimationFrameTicker.js +134 -0
- package/dist/timing/AnimationFrameTicker.js.map +1 -0
- package/dist/timing/Ease.d.ts +6 -0
- package/dist/timing/Ease.d.ts.map +1 -0
- package/dist/timing/Ease.js +15 -0
- package/dist/timing/Ease.js.map +1 -0
- package/dist/timing/TestTicker.d.ts +19 -0
- package/dist/timing/TestTicker.d.ts.map +1 -0
- package/dist/timing/TestTicker.js +81 -0
- package/dist/timing/TestTicker.js.map +1 -0
- package/dist/timing/Ticker.d.ts +14 -0
- package/dist/timing/Ticker.d.ts.map +1 -0
- package/dist/timing/Ticker.js +2 -0
- package/dist/timing/Ticker.js.map +1 -0
- package/dist/timing/Timing.d.ts +62 -0
- package/dist/timing/Timing.d.ts.map +1 -0
- package/dist/timing/Timing.js +257 -0
- package/dist/timing/Timing.js.map +1 -0
- package/dist/timing/easing.d.ts +158 -0
- package/dist/timing/easing.d.ts.map +1 -0
- package/dist/timing/easing.js +273 -0
- package/dist/timing/easing.js.map +1 -0
- package/dist/utils/Events.d.ts +9 -0
- package/dist/utils/Events.d.ts.map +1 -0
- package/dist/utils/Events.js +35 -0
- package/dist/utils/Events.js.map +1 -0
- package/dist/utils/internal.d.ts +2 -0
- package/dist/utils/internal.d.ts.map +1 -0
- package/dist/utils/internal.js +6 -0
- package/dist/utils/internal.js.map +1 -0
- package/dist/utils/motionpath.d.ts +16 -0
- package/dist/utils/motionpath.d.ts.map +1 -0
- package/dist/utils/motionpath.js +41 -0
- package/dist/utils/motionpath.js.map +1 -0
- package/dist/utils/utils.d.ts +43 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +93 -0
- package/dist/utils/utils.js.map +1 -0
- package/dist/values/ColorValue.d.ts +12 -0
- package/dist/values/ColorValue.d.ts.map +1 -0
- package/dist/values/ColorValue.js +133 -0
- package/dist/values/ColorValue.js.map +1 -0
- package/dist/values/StyleValue.d.ts +40 -0
- package/dist/values/StyleValue.d.ts.map +1 -0
- package/dist/values/StyleValue.js +149 -0
- package/dist/values/StyleValue.js.map +1 -0
- package/dist/values/Value.d.ts +13 -0
- package/dist/values/Value.d.ts.map +1 -0
- package/dist/values/Value.js +38 -0
- package/dist/values/Value.js.map +1 -0
- package/dist/values/defaultcolors.d.ts +2 -0
- package/dist/values/defaultcolors.d.ts.map +1 -0
- package/dist/values/defaultcolors.js +149 -0
- package/dist/values/defaultcolors.js.map +1 -0
- package/package.json +11 -7
- package/src/animation/{animation.js → Animation.ts} +56 -54
- package/src/animation/{public.js → public.ts} +23 -18
- package/src/{chnobli.js → chnobli.ts} +11 -12
- package/src/property/BasicProperty.ts +91 -0
- package/src/property/ClassProperty.ts +132 -0
- package/src/property/Property.ts +33 -0
- package/src/property/StyleProperty.ts +273 -0
- package/src/property/TransformProperty.ts +56 -0
- package/src/property/TransformXYProperty.ts +88 -0
- package/src/responsive/ResponsiveEvent.ts +60 -0
- package/src/responsive/{testevent.js → TestEvent.ts} +12 -10
- package/src/scroll/{scroll.js → Scroll.ts} +53 -35
- package/src/scroll/ScrollEvent.ts +53 -0
- package/src/scroll/public.ts +20 -0
- package/src/stagger/stagger.ts +45 -0
- package/src/target/{basetarget.js → BaseTarget.old.ts} +25 -26
- package/src/target/DomTarget.ts +281 -0
- package/src/target/Target.ts +48 -0
- package/src/target/{testdomnode.js → TestDomNode.ts} +18 -15
- package/src/tests/{properties.test.js → properties.test.ts} +54 -49
- package/src/tests/timeline.test.ts +290 -0
- package/src/tests/{timing.test.js → timing.test.ts} +25 -22
- package/src/tests/{usecases.test.js → usecases.test.ts} +13 -10
- package/src/tests/{values.test.js → values.test.ts} +21 -21
- package/src/timeline/Nested.ts +67 -0
- package/src/timeline/{timeline.js → TimeLine.ts} +126 -56
- package/src/timeline/{public.js → public.ts} +112 -73
- package/src/timing/{ticker.js → AnimationFrameTicker.ts} +36 -21
- package/src/timing/{ease.js → Ease.ts} +6 -5
- package/src/timing/{testticker.js → TestTicker.ts} +27 -24
- package/src/timing/Ticker.ts +11 -0
- package/src/timing/{timing.js → Timing.ts} +72 -63
- package/src/timing/{easing.js → easing.ts} +52 -43
- package/src/utils/{events.js → Events.ts} +12 -11
- package/src/utils/internal.ts +10 -0
- package/src/utils/{motionpath.js → motionpath.ts} +36 -13
- package/src/utils/utils.ts +110 -0
- package/src/values/{colorvalue.js → ColorValue.ts} +46 -47
- package/src/values/StyleValue.ts +186 -0
- package/src/values/{value.js → Value.ts} +14 -12
- package/src/values/{defaultcolors.js → defaultcolors.ts} +2 -2
- package/tsconfig.build.json +19 -0
- package/tsconfig.json +17 -108
- package/src/animation/property.js +0 -556
- package/src/responsive/event.js +0 -46
- package/src/scroll/event.js +0 -41
- package/src/scroll/public.js +0 -17
- package/src/stagger/stagger.js +0 -42
- package/src/target/domtarget.js +0 -266
- package/src/target/target.js +0 -22
- package/src/tests/timeline.test.js +0 -234
- package/src/utils/internal.js +0 -7
- package/src/utils/utils.js +0 -75
- package/src/values/stylevalue.js +0 -148
package/src/utils/utils.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { curve } from './motionpath.js';
|
|
2
|
-
|
|
3
|
-
export { curve };
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Explicitly tells a property to animate the to value
|
|
7
|
-
*/
|
|
8
|
-
export function to(to) {
|
|
9
|
-
return { to };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Explicitly tells a property to animate the from value
|
|
14
|
-
*/
|
|
15
|
-
export function from(from) {
|
|
16
|
-
return { from };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Explicitly tells a property to animate with the from and to values
|
|
21
|
-
*/
|
|
22
|
-
export function fromTo(from, to) {
|
|
23
|
-
return { from, to };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* makes a value reactive to `Timeline::update` calls or resizes
|
|
28
|
-
*/
|
|
29
|
-
export function responsive(fn) {
|
|
30
|
-
return { responsive: fn };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Converts an element with text into span with chars
|
|
35
|
-
*/
|
|
36
|
-
export function chars(element) {
|
|
37
|
-
if (element.dataset.processedChars)
|
|
38
|
-
return Array.from(element.children);
|
|
39
|
-
|
|
40
|
-
const chars = element.textContent.split('');
|
|
41
|
-
|
|
42
|
-
element.textContent = '';
|
|
43
|
-
element.dataset.processedChars = 'yes';
|
|
44
|
-
|
|
45
|
-
return chars.map(c => {
|
|
46
|
-
const span = document.createElement('span');
|
|
47
|
-
span.textContent = c;
|
|
48
|
-
span.style.display = 'inline-block';
|
|
49
|
-
element.appendChild(span);
|
|
50
|
-
|
|
51
|
-
return span;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* get the offset to the current page page
|
|
57
|
-
*/
|
|
58
|
-
export function pageOffset(el) {
|
|
59
|
-
if ('offsetTop' in el) {
|
|
60
|
-
return {
|
|
61
|
-
top: el.offsetTop,
|
|
62
|
-
left: el.offsetLeft,
|
|
63
|
-
width: el.offsetWidth,
|
|
64
|
-
height: el.offsetHeight
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const rect = el.getBoundingClientRect();
|
|
69
|
-
return {
|
|
70
|
-
top: window.scrollY + rect.top,
|
|
71
|
-
left: window.scrollX + rect.left,
|
|
72
|
-
width: rect.width,
|
|
73
|
-
height: rect.height
|
|
74
|
-
};
|
|
75
|
-
}
|
package/src/values/stylevalue.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import Value from './value.js';
|
|
2
|
-
import ColorValue from './colorvalue.js';
|
|
3
|
-
|
|
4
|
-
const AT_THE_END_VALUES = ['none', 'hidden'];
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A value from a style property
|
|
8
|
-
*
|
|
9
|
-
* might be a textual representation like none|auto|block|var(--abc)
|
|
10
|
-
* might be a value with unit or not
|
|
11
|
-
* might be multiple values `10 20px 4rem`
|
|
12
|
-
*
|
|
13
|
-
* values like hidden|none|null|undefined are market as at the end
|
|
14
|
-
* which means they should be set at the end
|
|
15
|
-
*/
|
|
16
|
-
export default class StyleValue {
|
|
17
|
-
/**
|
|
18
|
-
* Creates a style value
|
|
19
|
-
*
|
|
20
|
-
* ## value must be one of the following
|
|
21
|
-
* - string (meaning this is of kind text)
|
|
22
|
-
* - number (meaning this is of kind values with one value)
|
|
23
|
-
* - array (meaning this is of kind values and each array element needs to
|
|
24
|
-
* be a Value)
|
|
25
|
-
* - ColorValue
|
|
26
|
-
*/
|
|
27
|
-
constructor(value) {
|
|
28
|
-
if (typeof value === 'string') {
|
|
29
|
-
this.kind = 'text';
|
|
30
|
-
value = value.trim();
|
|
31
|
-
} else if (typeof value === 'number') {
|
|
32
|
-
this.kind = 'values';
|
|
33
|
-
value = [Value.parse(value)];
|
|
34
|
-
} else if (Array.isArray(value)) {
|
|
35
|
-
this.kind = 'values';
|
|
36
|
-
} else if (value instanceof ColorValue) {
|
|
37
|
-
this.kind = 'color';
|
|
38
|
-
} else {
|
|
39
|
-
throw new Error('unknown style value ' + value);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
this.values = value;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* If this is true the value should be set at the end of a animation
|
|
46
|
-
* this only works with kind === text
|
|
47
|
-
*/
|
|
48
|
-
this.textAtTheEnd = this.kind === 'text'
|
|
49
|
-
? AT_THE_END_VALUES.includes(this.values)
|
|
50
|
-
: false;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
static parse(v) {
|
|
55
|
-
if (typeof v === 'number')
|
|
56
|
-
return new StyleValue(v);
|
|
57
|
-
|
|
58
|
-
if (Array.isArray(v)) {
|
|
59
|
-
const val = v.map(v => Value.parse(v));
|
|
60
|
-
return new StyleValue(val);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (typeof v !== 'string')
|
|
64
|
-
throw new Error('expected a string as style value ' + v);
|
|
65
|
-
|
|
66
|
-
// let's first try to make it a color
|
|
67
|
-
if (ColorValue.mightBeAColor(v))
|
|
68
|
-
return new StyleValue(ColorValue.parse(v));
|
|
69
|
-
|
|
70
|
-
const split = v.split(' ').map(v => v.trim()).filter(v => !!v);
|
|
71
|
-
if (split.length === 0)
|
|
72
|
-
throw new Error('style value cannot be empty');
|
|
73
|
-
|
|
74
|
-
if (split.length === 1) {
|
|
75
|
-
try {
|
|
76
|
-
const val = Value.parse(split[0]);
|
|
77
|
-
return new StyleValue([val]);
|
|
78
|
-
} catch (e) {
|
|
79
|
-
// console.log('failed to parse first style value ', e);
|
|
80
|
-
return new StyleValue(split[0]);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return new StyleValue(split.map(v => Value.parse(v)));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/// only works if the kind is values
|
|
88
|
-
get length() {
|
|
89
|
-
if (this.kind !== 'values')
|
|
90
|
-
throw new Error('only works with kind values');
|
|
91
|
-
|
|
92
|
-
return this.values.length;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
extendToLength(length) {
|
|
96
|
-
if (this.length >= length)
|
|
97
|
-
return;
|
|
98
|
-
|
|
99
|
-
this.values = Array(length).fill(this.values).flat();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Throws if the this does not contain exactly one value
|
|
104
|
-
*/
|
|
105
|
-
intoValue() {
|
|
106
|
-
if (this.length !== 1)
|
|
107
|
-
throw new Error('style value does not contain only one value');
|
|
108
|
-
|
|
109
|
-
return this.values[0];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
clone() {
|
|
113
|
-
if (this.kind === 'text')
|
|
114
|
-
return new StyleValue(this.values);
|
|
115
|
-
|
|
116
|
-
if (this.kind === 'color')
|
|
117
|
-
return new StyleValue(this.values.clone());
|
|
118
|
-
|
|
119
|
-
return new StyleValue(this.values.map(v => v.clone()));
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/// if this is called with a text value nothing happens
|
|
123
|
-
withDefaultUnit(unit) {
|
|
124
|
-
if (this.kind === 'text')
|
|
125
|
-
return new StyleValue(this.values);
|
|
126
|
-
|
|
127
|
-
if (this.kind === 'color')
|
|
128
|
-
return new StyleValue(this.values.clone());
|
|
129
|
-
|
|
130
|
-
return new StyleValue(this.values.map(v => v.withDefaultUnit(unit)));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
toString() {
|
|
134
|
-
switch (this.kind) {
|
|
135
|
-
case 'text':
|
|
136
|
-
return this.values;
|
|
137
|
-
|
|
138
|
-
case 'color':
|
|
139
|
-
return this.values.toString();
|
|
140
|
-
|
|
141
|
-
case 'values':
|
|
142
|
-
return this.values.join(' ');
|
|
143
|
-
|
|
144
|
-
default:
|
|
145
|
-
throw new Error('unknown kind ' + this.kind);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|