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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../src/animation/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,CAA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K,EAAE,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,UAAU;QACT,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,MAAM;QACL,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,UAAU;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,QAAiB;QAC5B,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,OAAO;QACN,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;IAED,EAAE,CAAC,KAAa,EAAE,EAA4B;QAC7C,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED,cAAc;IACd,SAAS,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,OAAO;QACN,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACnB,aAAa;QACb,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;IACjB,CAAC;CACD;AAED,SAAS,aAAa,CAAC,QAAa;IACnC,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,KAAK;QAC1C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAEpD,OAAO,QAAQ,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Animation from './animation/public';
|
|
2
|
+
import Timeline from './timeline/public';
|
|
3
|
+
import Scroll from './scroll/public';
|
|
4
|
+
import Stagger from './stagger/stagger';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a simple animation
|
|
7
|
+
*
|
|
8
|
+
* ## Properties
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare function animate(targets: any, props?: Record<string, any>): Animation;
|
|
12
|
+
export declare function timeline(props?: Record<string, any>): Timeline;
|
|
13
|
+
export declare function stagger(value: any): Stagger;
|
|
14
|
+
export declare function scroll(props?: Record<string, any>): Scroll;
|
|
15
|
+
//# sourceMappingURL=chnobli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chnobli.d.ts","sourceRoot":"","sources":["../src/chnobli.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAIxC;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,aAEpE;AAED,wBAAgB,QAAQ,CAAC,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,YAEvD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,WAEjC;AAED,wBAAgB,MAAM,CAAC,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,UAErD"}
|
package/dist/chnobli.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import Animation from './animation/public';
|
|
2
|
+
import Timeline from './timeline/public';
|
|
3
|
+
import Scroll from './scroll/public';
|
|
4
|
+
import Stagger from './stagger/stagger';
|
|
5
|
+
// todo maybe add, to, from and fromTo to the animate function
|
|
6
|
+
/**
|
|
7
|
+
* Creates a simple animation
|
|
8
|
+
*
|
|
9
|
+
* ## Properties
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export function animate(targets, props = {}) {
|
|
13
|
+
return new Animation(targets, props);
|
|
14
|
+
}
|
|
15
|
+
export function timeline(props = {}) {
|
|
16
|
+
return new Timeline(props);
|
|
17
|
+
}
|
|
18
|
+
export function stagger(value) {
|
|
19
|
+
return new Stagger(value);
|
|
20
|
+
}
|
|
21
|
+
export function scroll(props = {}) {
|
|
22
|
+
return new Scroll(props);
|
|
23
|
+
}
|
|
24
|
+
/*
|
|
25
|
+
|
|
26
|
+
animate(target, {
|
|
27
|
+
|
|
28
|
+
// special
|
|
29
|
+
// translate
|
|
30
|
+
x
|
|
31
|
+
y
|
|
32
|
+
scale
|
|
33
|
+
scaleX
|
|
34
|
+
scaleY
|
|
35
|
+
rotation
|
|
36
|
+
skew
|
|
37
|
+
skewX
|
|
38
|
+
skewY
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
// stagger
|
|
43
|
+
repeatDelay
|
|
44
|
+
stagger: {
|
|
45
|
+
// wrap advanced options in an object
|
|
46
|
+
each: 0.1,
|
|
47
|
+
from: "center",
|
|
48
|
+
grid: "auto",
|
|
49
|
+
ease: "power2.inOut",
|
|
50
|
+
repeat: -1, // Repeats immediately, not waiting for the other staggered animations to finish
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
ease,
|
|
55
|
+
duration,
|
|
56
|
+
repeat, (-1?)
|
|
57
|
+
repeatDelay?
|
|
58
|
+
delay,
|
|
59
|
+
alternate
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
*/
|
|
63
|
+
//# sourceMappingURL=chnobli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chnobli.js","sourceRoot":"","sources":["../src/chnobli.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAExC,8DAA8D;AAE9D;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,OAAY,EAAE,QAA6B,EAAE;IACpE,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,QAA6B,EAAE;IACvD,OAAO,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAU;IACjC,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,QAA6B,EAAE;IACrD,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Value from '../values/Value';
|
|
2
|
+
import Property, { ParseableValue } from './Property';
|
|
3
|
+
import { Target } from '../target/Target';
|
|
4
|
+
export default class BasicProperty implements Property<Value> {
|
|
5
|
+
/**
|
|
6
|
+
* The name of the property
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* The value at the start
|
|
11
|
+
*/
|
|
12
|
+
from: Value | null;
|
|
13
|
+
/**
|
|
14
|
+
* The value at the end
|
|
15
|
+
*/
|
|
16
|
+
to: Value | null;
|
|
17
|
+
constructor(name: string);
|
|
18
|
+
allowsValueFn(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* From or to might be null
|
|
21
|
+
*/
|
|
22
|
+
init(target: Target, from: Value | null, to: Value | null): void;
|
|
23
|
+
/**
|
|
24
|
+
* Gets called with the value of a property
|
|
25
|
+
*
|
|
26
|
+
* For examply during initializiation
|
|
27
|
+
*/
|
|
28
|
+
parseValue(val: ParseableValue): Value;
|
|
29
|
+
defaultValue(): Value;
|
|
30
|
+
getValue(target: Target): Value;
|
|
31
|
+
/**
|
|
32
|
+
* Pos needs to be between 0 and 1
|
|
33
|
+
*/
|
|
34
|
+
interpolate(pos: number): Value;
|
|
35
|
+
setValue(target: Target, val: Value): void;
|
|
36
|
+
removeValue(target: Target): void;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=BasicProperty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasicProperty.d.ts","sourceRoot":"","sources":["../../src/property/BasicProperty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,QAAQ,EAAE,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,QAAQ,CAAC,KAAK,CAAC;IAC5D;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IAEnB;;OAEG;IACH,EAAE,EAAE,KAAK,GAAG,IAAI,CAAC;gBAEL,IAAI,EAAE,MAAM;IAQxB,aAAa;IAIb;;OAEG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,EAAE,EAAE,KAAK,GAAG,IAAI;IAczD;;;;OAIG;IACH,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,KAAK;IAOtC,YAAY,IAAI,KAAK;IAKrB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK;IAQ/B;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK;IAM/B,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK;IAInC,WAAW,CAAC,MAAM,EAAE,MAAM;CAG1B"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import Value from '../values/Value';
|
|
2
|
+
export default class BasicProperty {
|
|
3
|
+
/**
|
|
4
|
+
* The name of the property
|
|
5
|
+
*/
|
|
6
|
+
name;
|
|
7
|
+
/**
|
|
8
|
+
* The value at the start
|
|
9
|
+
*/
|
|
10
|
+
from;
|
|
11
|
+
/**
|
|
12
|
+
* The value at the end
|
|
13
|
+
*/
|
|
14
|
+
to;
|
|
15
|
+
constructor(name) {
|
|
16
|
+
// this is the property name
|
|
17
|
+
this.name = name;
|
|
18
|
+
this.from = null;
|
|
19
|
+
this.to = null;
|
|
20
|
+
}
|
|
21
|
+
allowsValueFn() {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* From or to might be null
|
|
26
|
+
*/
|
|
27
|
+
init(target, from, to) {
|
|
28
|
+
if (!from)
|
|
29
|
+
from = this.getValue(target);
|
|
30
|
+
if (!to)
|
|
31
|
+
to = this.getValue(target);
|
|
32
|
+
if (!from || !to)
|
|
33
|
+
throw new Error('could not determine from or to value');
|
|
34
|
+
const [nFrom, nTo] = target.unifyValues(this.name, from, to);
|
|
35
|
+
this.from = nFrom;
|
|
36
|
+
this.to = nTo;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Gets called with the value of a property
|
|
40
|
+
*
|
|
41
|
+
* For examply during initializiation
|
|
42
|
+
*/
|
|
43
|
+
parseValue(val) {
|
|
44
|
+
if (typeof val !== 'string')
|
|
45
|
+
throw new Error('only strings are supported');
|
|
46
|
+
return Value.parse(val);
|
|
47
|
+
}
|
|
48
|
+
defaultValue() {
|
|
49
|
+
throw new Error('default value for ' + this.name + ' not known');
|
|
50
|
+
}
|
|
51
|
+
// try to access the value from the target
|
|
52
|
+
getValue(target) {
|
|
53
|
+
const val = target.getValue(this.name);
|
|
54
|
+
if (typeof val === 'undefined' || val === null)
|
|
55
|
+
return this.defaultValue();
|
|
56
|
+
return val;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Pos needs to be between 0 and 1
|
|
60
|
+
*/
|
|
61
|
+
interpolate(pos) {
|
|
62
|
+
const dif = this.to.num - this.from.num;
|
|
63
|
+
return this.from.cloneAdd(pos * dif);
|
|
64
|
+
}
|
|
65
|
+
setValue(target, val) {
|
|
66
|
+
return target.setValue(this.name, val);
|
|
67
|
+
}
|
|
68
|
+
removeValue(target) {
|
|
69
|
+
return target.removeValue(this.name);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=BasicProperty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasicProperty.js","sourceRoot":"","sources":["../../src/property/BasicProperty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,iBAAiB,CAAC;AAIpC,MAAM,CAAC,OAAO,OAAO,aAAa;IACjC;;OAEG;IACH,IAAI,CAAS;IAEb;;OAEG;IACH,IAAI,CAAe;IAEnB;;OAEG;IACH,EAAE,CAAe;IAEjB,YAAY,IAAY;QACvB,4BAA4B;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;IAChB,CAAC;IAED,aAAa;QACZ,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,MAAc,EAAE,IAAkB,EAAE,EAAgB;QACxD,IAAI,CAAC,IAAI;YAAE,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAExC,IAAI,CAAC,EAAE;YAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEpC,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAEzD,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAE7D,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;IACf,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,GAAmB;QAC7B,IAAI,OAAO,GAAG,KAAK,QAAQ;YAC1B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAE/C,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,YAAY;QACX,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,CAAC;IAClE,CAAC;IAED,0CAA0C;IAC1C,QAAQ,CAAC,MAAc;QACtB,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,IAAI;YAC7C,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC;QAE5B,OAAO,GAAG,CAAC;IACZ,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,GAAW;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,EAAG,CAAC,GAAG,GAAG,IAAI,CAAC,IAAK,CAAC,GAAG,CAAC;QAE1C,OAAO,IAAI,CAAC,IAAK,CAAC,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,QAAQ,CAAC,MAAc,EAAE,GAAU;QAClC,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,WAAW,CAAC,MAAc;QACzB,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Target } from '../target/Target';
|
|
2
|
+
import Property, { type ParseableValue } from './Property';
|
|
3
|
+
export type Interpolated = {
|
|
4
|
+
add: string[];
|
|
5
|
+
remove: string[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* In most cases we wan't to add the class at pos 0
|
|
9
|
+
* and in reverse remove it at pos 0
|
|
10
|
+
*
|
|
11
|
+
* so this behaviour should be in str|{ to }
|
|
12
|
+
*
|
|
13
|
+
* If we wan't to remove the class at pos 1
|
|
14
|
+
* and in reverse add it at pos 1
|
|
15
|
+
* we do it in { from }
|
|
16
|
+
*/
|
|
17
|
+
export default class ClassProperty implements Property<string[], Interpolated> {
|
|
18
|
+
name: string;
|
|
19
|
+
from: string[];
|
|
20
|
+
to: string[];
|
|
21
|
+
private preStates;
|
|
22
|
+
private states;
|
|
23
|
+
constructor(name: string);
|
|
24
|
+
allowsValueFn(): boolean;
|
|
25
|
+
init(target: Target, from: string[] | null, to: string[] | null): void;
|
|
26
|
+
parseValue(val: ParseableValue): string[];
|
|
27
|
+
getValue(_target: Target): string[] | null;
|
|
28
|
+
interpolate(pos: number): Interpolated;
|
|
29
|
+
setValue(target: Target, val: Interpolated): void;
|
|
30
|
+
removeValue(target: Target): void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=ClassProperty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassProperty.d.ts","sourceRoot":"","sources":["../../src/property/ClassProperty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,QAAQ,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG;IAC1B,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,MAAM,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,QAAQ,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC;IAC7E,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAG,MAAM,EAAE,CAAC;IAChB,EAAE,EAAG,MAAM,EAAE,CAAC;IAEd,OAAO,CAAC,SAAS,CAAwB;IACzC,OAAO,CAAC,MAAM,CAAwB;gBAE1B,IAAI,EAAE,MAAM;IAIxB,aAAa,IAAI,OAAO;IAIxB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,IAAI;IAc/D,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM,EAAE;IAezC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAI1C,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY;IA+BtC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY;IAyB1C,WAAW,CAAC,MAAM,EAAE,MAAM;CAO1B"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In most cases we wan't to add the class at pos 0
|
|
3
|
+
* and in reverse remove it at pos 0
|
|
4
|
+
*
|
|
5
|
+
* so this behaviour should be in str|{ to }
|
|
6
|
+
*
|
|
7
|
+
* If we wan't to remove the class at pos 1
|
|
8
|
+
* and in reverse add it at pos 1
|
|
9
|
+
* we do it in { from }
|
|
10
|
+
*/
|
|
11
|
+
export default class ClassProperty {
|
|
12
|
+
name;
|
|
13
|
+
from;
|
|
14
|
+
to;
|
|
15
|
+
preStates;
|
|
16
|
+
states;
|
|
17
|
+
constructor(name) {
|
|
18
|
+
this.name = name;
|
|
19
|
+
}
|
|
20
|
+
allowsValueFn() {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
init(target, from, to) {
|
|
24
|
+
this.from = from ?? [];
|
|
25
|
+
this.to = to ?? [];
|
|
26
|
+
this.preStates = new Map();
|
|
27
|
+
this.states = new Map();
|
|
28
|
+
for (const cls of [...this.from, ...this.to]) {
|
|
29
|
+
const exists = target.hasClass(cls);
|
|
30
|
+
this.preStates.set(cls, exists);
|
|
31
|
+
this.states.set(cls, exists);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
parseValue(val) {
|
|
35
|
+
if (Array.isArray(val)) {
|
|
36
|
+
return val.map(v => {
|
|
37
|
+
if (typeof v !== 'string')
|
|
38
|
+
throw new Error('cls only accepts strings[]');
|
|
39
|
+
return v;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (typeof val === 'string')
|
|
43
|
+
return [val];
|
|
44
|
+
throw new Error('cls only accepts strings and strings[]');
|
|
45
|
+
}
|
|
46
|
+
getValue(_target) {
|
|
47
|
+
throw new Error('unused');
|
|
48
|
+
}
|
|
49
|
+
interpolate(pos) {
|
|
50
|
+
/**
|
|
51
|
+
* ## to
|
|
52
|
+
* add the class at pos >0
|
|
53
|
+
* and in reverse remove it at pos 0
|
|
54
|
+
*
|
|
55
|
+
* ## from
|
|
56
|
+
* remove the class at pos <1
|
|
57
|
+
* and in reverse add it at pos 1
|
|
58
|
+
*/
|
|
59
|
+
let obj = {
|
|
60
|
+
add: [],
|
|
61
|
+
remove: [],
|
|
62
|
+
};
|
|
63
|
+
if (pos <= 0) {
|
|
64
|
+
obj.remove = this.to;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
obj.add = this.to;
|
|
68
|
+
}
|
|
69
|
+
if (pos >= 1) {
|
|
70
|
+
obj.remove = this.from;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
obj.add = [...obj.add, ...this.from];
|
|
74
|
+
}
|
|
75
|
+
return obj;
|
|
76
|
+
}
|
|
77
|
+
setValue(target, val) {
|
|
78
|
+
let { add, remove } = val;
|
|
79
|
+
add = add ?? [];
|
|
80
|
+
remove = remove ?? [];
|
|
81
|
+
if (!Array.isArray(add) || !Array.isArray(remove))
|
|
82
|
+
throw new Error('add or remove expected');
|
|
83
|
+
add.forEach(cls => {
|
|
84
|
+
const exists = this.states.get(cls);
|
|
85
|
+
if (!exists) {
|
|
86
|
+
target.addClass(cls);
|
|
87
|
+
this.states.set(cls, true);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
remove.forEach(cls => {
|
|
91
|
+
const exists = this.states.get(cls);
|
|
92
|
+
if (exists) {
|
|
93
|
+
target.removeClass(cls);
|
|
94
|
+
this.states.set(cls, false);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
removeValue(target) {
|
|
99
|
+
this.preStates.forEach((exists, cls) => {
|
|
100
|
+
if (exists)
|
|
101
|
+
target.addClass(cls);
|
|
102
|
+
else
|
|
103
|
+
target.removeClass(cls);
|
|
104
|
+
});
|
|
105
|
+
this.states = new Map(this.preStates);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=ClassProperty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassProperty.js","sourceRoot":"","sources":["../../src/property/ClassProperty.ts"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IACjC,IAAI,CAAS;IAEb,IAAI,CAAY;IAChB,EAAE,CAAY;IAEN,SAAS,CAAwB;IACjC,MAAM,CAAwB;IAEtC,YAAY,IAAY;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAED,aAAa;QACZ,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAI,CAAC,MAAc,EAAE,IAAqB,EAAE,EAAmB;QAC9D,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;QAEnB,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QAExB,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAC9C,MAAM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C,CAAC;;gBAC5B,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;CACD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Target } from '../target/Target';
|
|
2
|
+
export type ParseableValue = string | number | (string | number)[];
|
|
3
|
+
export default interface Property<V, I = V> {
|
|
4
|
+
name: string;
|
|
5
|
+
allowsValueFn(): boolean;
|
|
6
|
+
init(target: Target, from: V | null, to: V | null): void;
|
|
7
|
+
parseValue(value: ParseableValue): V;
|
|
8
|
+
interpolate(pos: number): I;
|
|
9
|
+
setValue(target: Target, value: I): void;
|
|
10
|
+
removeValue(target: Target): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function newProperty(prop: string, targetType?: string): Property<any>;
|
|
13
|
+
//# sourceMappingURL=Property.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Property.d.ts","sourceRoot":"","sources":["../../src/property/Property.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM1C,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;AAEnE,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC;IACzC,IAAI,EAAE,MAAM,CAAC;IAEb,aAAa,IAAI,OAAO,CAAC;IAEzB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;IAEzD,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,CAAC,CAAC;IACrC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACzC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,SAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAWxE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import TransformProperty, { TRANSFORM_PROPS } from './TransformProperty';
|
|
2
|
+
import TransformXYProperty from './TransformXYProperty';
|
|
3
|
+
import StyleProperty, { STYLE_PROPS } from './StyleProperty';
|
|
4
|
+
import ClassProperty from './ClassProperty';
|
|
5
|
+
export function newProperty(prop, targetType = '') {
|
|
6
|
+
if (targetType !== 'dom')
|
|
7
|
+
throw new Error('only dom is supported as target');
|
|
8
|
+
if (prop in TRANSFORM_PROPS)
|
|
9
|
+
return new TransformProperty(prop);
|
|
10
|
+
if (prop === 'xy')
|
|
11
|
+
return new TransformXYProperty(prop);
|
|
12
|
+
if (prop.startsWith('--'))
|
|
13
|
+
return new StyleProperty(prop);
|
|
14
|
+
if (prop in STYLE_PROPS)
|
|
15
|
+
return new StyleProperty(prop);
|
|
16
|
+
if (prop === 'cls')
|
|
17
|
+
return new ClassProperty(prop);
|
|
18
|
+
throw new Error('unknown prop ' + prop);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=Property.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Property.js","sourceRoot":"","sources":["../../src/property/Property.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,EAAE,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,aAAa,EAAE,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAiB5C,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,UAAU,GAAG,EAAE;IACxD,IAAI,UAAU,KAAK,KAAK;QACvB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAEpD,IAAI,IAAI,IAAI,eAAe;QAAE,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAChE,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1D,IAAI,IAAI,IAAI,WAAW;QAAE,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IAEnD,MAAM,IAAI,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import StyleValue from '../values/StyleValue';
|
|
2
|
+
import Property, { ParseableValue } from './Property';
|
|
3
|
+
import { Target } from '../target/Target';
|
|
4
|
+
export declare const STYLE_PROPS: Record<string, string | [number, string | null]>;
|
|
5
|
+
export default class StyleProperty implements Property<StyleValue, StyleValue | null> {
|
|
6
|
+
name: string;
|
|
7
|
+
from: StyleValue | null;
|
|
8
|
+
to: StyleValue | null;
|
|
9
|
+
unit: string | null;
|
|
10
|
+
kind: 'text' | 'color' | 'values' | null;
|
|
11
|
+
private _defaultValue;
|
|
12
|
+
constructor(name: string);
|
|
13
|
+
allowsValueFn(): boolean;
|
|
14
|
+
init(target: Target, from: StyleValue | null, to: StyleValue | null): void;
|
|
15
|
+
parseValue(val: ParseableValue): StyleValue;
|
|
16
|
+
defaultValue(): StyleValue | null;
|
|
17
|
+
getValue(target: Target): StyleValue | null;
|
|
18
|
+
interpolate(pos: number): StyleValue | null;
|
|
19
|
+
private _interpolateText;
|
|
20
|
+
private _interpolateColor;
|
|
21
|
+
private _interpolateValues;
|
|
22
|
+
setValue(target: Target, val: StyleValue | null): void;
|
|
23
|
+
removeValue(target: Target): void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=StyleProperty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StyleProperty.d.ts","sourceRoot":"","sources":["../../src/property/StyleProperty.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,QAAQ,EAAE,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAmBxE,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,aACpB,YAAW,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAElD,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IACxB,EAAE,EAAE,UAAU,GAAG,IAAI,CAAC;IAEtB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpB,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,IAAI,CAAC;IAIzC,OAAO,CAAC,aAAa,CAAoB;gBAE7B,IAAI,EAAE,MAAM;IAyBxB,aAAa,IAAI,OAAO;IAIxB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,EAAE,EAAE,EAAE,UAAU,GAAG,IAAI;IAsFnE,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,UAAU;IAI3C,YAAY,IAAI,UAAU,GAAG,IAAI;IAIjC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAO3C,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAc3C,OAAO,CAAC,gBAAgB;IAyCxB,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,kBAAkB;IAkB1B,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,IAAI;IAM/C,WAAW,CAAC,MAAM,EAAE,MAAM;CAG1B"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import StyleValue from '../values/StyleValue';
|
|
2
|
+
import Value from '../values/Value';
|
|
3
|
+
import ColorValue from '../values/ColorValue';
|
|
4
|
+
export const STYLE_PROPS = {
|
|
5
|
+
position: 'static',
|
|
6
|
+
display: 'block',
|
|
7
|
+
visibility: 'visible',
|
|
8
|
+
minWidth: 'px',
|
|
9
|
+
width: 'px',
|
|
10
|
+
maxWidth: 'px',
|
|
11
|
+
minHeight: 'px',
|
|
12
|
+
height: 'px',
|
|
13
|
+
maxHeight: 'px',
|
|
14
|
+
top: 'px',
|
|
15
|
+
left: 'px',
|
|
16
|
+
right: 'px',
|
|
17
|
+
bottom: 'px',
|
|
18
|
+
opacity: [1, null],
|
|
19
|
+
padding: 'px',
|
|
20
|
+
margin: 'px',
|
|
21
|
+
color: '#000',
|
|
22
|
+
backgroundColor: '#fff',
|
|
23
|
+
};
|
|
24
|
+
export default class StyleProperty {
|
|
25
|
+
name;
|
|
26
|
+
from;
|
|
27
|
+
to;
|
|
28
|
+
unit;
|
|
29
|
+
kind;
|
|
30
|
+
// if the kind text is set
|
|
31
|
+
// from and to are text
|
|
32
|
+
_defaultValue;
|
|
33
|
+
constructor(name) {
|
|
34
|
+
this.name = name;
|
|
35
|
+
this.from = null;
|
|
36
|
+
this.to = null;
|
|
37
|
+
const def = STYLE_PROPS[name];
|
|
38
|
+
if (Array.isArray(def)) {
|
|
39
|
+
this._defaultValue = new StyleValue([new Value(def[0], def[1])]);
|
|
40
|
+
this.unit = def[1];
|
|
41
|
+
}
|
|
42
|
+
else if (def === 'px') {
|
|
43
|
+
this._defaultValue = new StyleValue([new Value(0, def)]);
|
|
44
|
+
this.unit = def;
|
|
45
|
+
}
|
|
46
|
+
else if (typeof def !== 'undefined') {
|
|
47
|
+
this._defaultValue = StyleValue.parse(def);
|
|
48
|
+
this.unit = null;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this._defaultValue = null;
|
|
52
|
+
this.unit = null;
|
|
53
|
+
}
|
|
54
|
+
// text|color|values
|
|
55
|
+
this.kind = null;
|
|
56
|
+
}
|
|
57
|
+
allowsValueFn() {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
init(target, from, to) {
|
|
61
|
+
// this check is probably not necessary?
|
|
62
|
+
if (!from && !to)
|
|
63
|
+
throw new Error('either from or to need to be defined');
|
|
64
|
+
/*
|
|
65
|
+
if the user inputed a text value both need to be treated as text
|
|
66
|
+
and interpolated as classes or in reverse if they are negative values
|
|
67
|
+
|
|
68
|
+
if the user inputed a value both need to be treated as values and need
|
|
69
|
+
to match in length
|
|
70
|
+
*/
|
|
71
|
+
if (from?.kind === 'text' || to?.kind === 'text') {
|
|
72
|
+
if (from && from.kind !== 'text')
|
|
73
|
+
throw new Error('from is expected to be a text because to is');
|
|
74
|
+
if (to && to.kind !== 'text')
|
|
75
|
+
throw new Error('to is expected to be a text because from is');
|
|
76
|
+
this.kind = 'text';
|
|
77
|
+
this.from = from;
|
|
78
|
+
this.to = to;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
// get the current value
|
|
82
|
+
if (!from)
|
|
83
|
+
from = this.getValue(target);
|
|
84
|
+
// get the current value
|
|
85
|
+
if (!to)
|
|
86
|
+
to = this.getValue(target);
|
|
87
|
+
if (!from || !to)
|
|
88
|
+
throw new Error('from or to could not be defined, specified ' +
|
|
89
|
+
'it with fromTo');
|
|
90
|
+
// if one is a color both need to be a color
|
|
91
|
+
if (from.kind === 'color' || to.kind === 'color') {
|
|
92
|
+
if (from.kind !== to.kind)
|
|
93
|
+
throw new Error('expected two colors');
|
|
94
|
+
this.kind = 'color';
|
|
95
|
+
this.from = from;
|
|
96
|
+
this.to = to;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
// check that both are of kind values
|
|
100
|
+
if (from.kind === 'text')
|
|
101
|
+
from = this.defaultValue();
|
|
102
|
+
if (to.kind === 'text')
|
|
103
|
+
to = this.defaultValue();
|
|
104
|
+
if (from.length === 0 || to.length === 0)
|
|
105
|
+
throw new Error('from or to has zero values');
|
|
106
|
+
// at this point from and to are values and both have some values
|
|
107
|
+
// either from or to needs to be 1 to work
|
|
108
|
+
if (from.length !== to.length && from.length !== 1 && to.length !== 1)
|
|
109
|
+
throw new Error('from or to need to match in length or be one');
|
|
110
|
+
const newLength = Math.max(from.length, to.length);
|
|
111
|
+
from.extendToLength(newLength);
|
|
112
|
+
to.extendToLength(newLength);
|
|
113
|
+
// now let's try to unify each value
|
|
114
|
+
const fromVals = [];
|
|
115
|
+
const toVals = [];
|
|
116
|
+
// now we need to make sure the values are the same
|
|
117
|
+
for (let i = 0; i < newLength; i++) {
|
|
118
|
+
const f = from.values[i];
|
|
119
|
+
const t = to.values[i];
|
|
120
|
+
const [nFrom, nTo] = target.unifyValues(this.name, f, t);
|
|
121
|
+
fromVals.push(nFrom);
|
|
122
|
+
toVals.push(nTo);
|
|
123
|
+
}
|
|
124
|
+
this.kind = 'values';
|
|
125
|
+
this.from = new StyleValue(fromVals);
|
|
126
|
+
this.to = new StyleValue(toVals);
|
|
127
|
+
}
|
|
128
|
+
parseValue(val) {
|
|
129
|
+
return StyleValue.parse(val);
|
|
130
|
+
}
|
|
131
|
+
defaultValue() {
|
|
132
|
+
return this._defaultValue?.clone() ?? null;
|
|
133
|
+
}
|
|
134
|
+
getValue(target) {
|
|
135
|
+
const val = target.getStyleValue(this.name);
|
|
136
|
+
if (!val)
|
|
137
|
+
return this.defaultValue();
|
|
138
|
+
return val;
|
|
139
|
+
}
|
|
140
|
+
interpolate(pos) {
|
|
141
|
+
switch (this.kind) {
|
|
142
|
+
case 'text':
|
|
143
|
+
return this._interpolateText(pos);
|
|
144
|
+
case 'color':
|
|
145
|
+
return this._interpolateColor(pos);
|
|
146
|
+
default:
|
|
147
|
+
return this._interpolateValues(pos);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// only call this if kind is text
|
|
151
|
+
_interpolateText(pos) {
|
|
152
|
+
/*
|
|
153
|
+
## if both values are set
|
|
154
|
+
|
|
155
|
+
<=0 the from value will be set
|
|
156
|
+
>0 the to value will be set
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
## if only one text is set
|
|
160
|
+
|
|
161
|
+
if the to value is
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
the text in the to value will be set >0
|
|
165
|
+
the text in the to value will be removed in <=0
|
|
166
|
+
|
|
167
|
+
the text in the from value will be set <1
|
|
168
|
+
the text in the from value will be removed in >=1
|
|
169
|
+
*/
|
|
170
|
+
if (this.from && this.to) {
|
|
171
|
+
if (pos <= 0)
|
|
172
|
+
return this.from.clone();
|
|
173
|
+
return this.to.clone();
|
|
174
|
+
}
|
|
175
|
+
if (this.to) {
|
|
176
|
+
if (pos <= 0)
|
|
177
|
+
return null;
|
|
178
|
+
return this.to.clone();
|
|
179
|
+
}
|
|
180
|
+
if (this.from) {
|
|
181
|
+
if (pos >= 1)
|
|
182
|
+
return null;
|
|
183
|
+
return this.from.clone();
|
|
184
|
+
}
|
|
185
|
+
throw new Error('expected from or to');
|
|
186
|
+
}
|
|
187
|
+
// only call this if kind is color
|
|
188
|
+
_interpolateColor(pos) {
|
|
189
|
+
const vals = [];
|
|
190
|
+
for (let i = 0; i < 4; i++) {
|
|
191
|
+
const f = this.from.values.values[i];
|
|
192
|
+
const t = this.to.values.values[i];
|
|
193
|
+
const dif = t - f;
|
|
194
|
+
vals.push(f + pos * dif);
|
|
195
|
+
}
|
|
196
|
+
return new StyleValue(new ColorValue(vals));
|
|
197
|
+
}
|
|
198
|
+
// only call this if kind is values
|
|
199
|
+
// both values should be the same length
|
|
200
|
+
_interpolateValues(pos) {
|
|
201
|
+
const vals = [];
|
|
202
|
+
const from = this.from.values;
|
|
203
|
+
const to = this.to.values;
|
|
204
|
+
for (let i = 0; i < from.length; i++) {
|
|
205
|
+
const f = from[i];
|
|
206
|
+
const t = to[i];
|
|
207
|
+
const dif = t.num - f.num;
|
|
208
|
+
vals.push(f.cloneAdd(pos * dif));
|
|
209
|
+
}
|
|
210
|
+
return new StyleValue(vals);
|
|
211
|
+
}
|
|
212
|
+
setValue(target, val) {
|
|
213
|
+
if (!val)
|
|
214
|
+
return target.removeStyleValue(this.name);
|
|
215
|
+
return target.setStyleValue(this.name, val.withDefaultUnit(this.unit));
|
|
216
|
+
}
|
|
217
|
+
removeValue(target) {
|
|
218
|
+
return target.removeStyleValue(this.name);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=StyleProperty.js.map
|