@easemate/web-kit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +824 -0
- package/build/components/code/index.cjs +152 -0
- package/build/components/code/index.d.cts +11 -0
- package/build/components/code/index.d.ts +11 -0
- package/build/components/code/index.js +148 -0
- package/build/components/code/utils/highlight-api.cjs +18 -0
- package/build/components/code/utils/highlight-api.d.cts +7 -0
- package/build/components/code/utils/highlight-api.d.ts +7 -0
- package/build/components/code/utils/highlight-api.js +14 -0
- package/build/components/code/utils/syntax-grammars.cjs +62 -0
- package/build/components/code/utils/syntax-grammars.d.cts +7 -0
- package/build/components/code/utils/syntax-grammars.d.ts +7 -0
- package/build/components/code/utils/syntax-grammars.js +59 -0
- package/build/components/code/utils/syntax-highlighter-theme.cjs +27 -0
- package/build/components/code/utils/syntax-highlighter-theme.d.cts +3 -0
- package/build/components/code/utils/syntax-highlighter-theme.d.ts +3 -0
- package/build/components/code/utils/syntax-highlighter-theme.js +23 -0
- package/build/components/code/utils/syntax-highlighter-types.cjs +2 -0
- package/build/components/code/utils/syntax-highlighter-types.d.cts +12 -0
- package/build/components/code/utils/syntax-highlighter-types.d.ts +12 -0
- package/build/components/code/utils/syntax-highlighter-types.js +1 -0
- package/build/components/code/utils/syntax-tokenizer.cjs +63 -0
- package/build/components/code/utils/syntax-tokenizer.d.cts +3 -0
- package/build/components/code/utils/syntax-tokenizer.d.ts +3 -0
- package/build/components/code/utils/syntax-tokenizer.js +58 -0
- package/build/components/curve/bezier-conversion.cjs +23 -0
- package/build/components/curve/bezier-conversion.d.cts +2 -0
- package/build/components/curve/bezier-conversion.d.ts +2 -0
- package/build/components/curve/bezier-conversion.js +19 -0
- package/build/components/curve/canvas-controls.cjs +300 -0
- package/build/components/curve/canvas-controls.d.cts +12 -0
- package/build/components/curve/canvas-controls.d.ts +12 -0
- package/build/components/curve/canvas-controls.js +296 -0
- package/build/components/curve/canvas.cjs +1208 -0
- package/build/components/curve/canvas.d.cts +24 -0
- package/build/components/curve/canvas.d.ts +24 -0
- package/build/components/curve/canvas.js +1204 -0
- package/build/components/curve/constants.cjs +203 -0
- package/build/components/curve/constants.d.cts +23 -0
- package/build/components/curve/constants.d.ts +23 -0
- package/build/components/curve/constants.js +200 -0
- package/build/components/curve/controls.cjs +942 -0
- package/build/components/curve/controls.d.cts +37 -0
- package/build/components/curve/controls.d.ts +37 -0
- package/build/components/curve/controls.js +938 -0
- package/build/components/curve/index.cjs +335 -0
- package/build/components/curve/index.d.cts +31 -0
- package/build/components/curve/index.d.ts +31 -0
- package/build/components/curve/index.js +330 -0
- package/build/components/curve/output.cjs +141 -0
- package/build/components/curve/output.d.cts +19 -0
- package/build/components/curve/output.d.ts +19 -0
- package/build/components/curve/output.js +137 -0
- package/build/components/curve/styles.cjs +493 -0
- package/build/components/curve/styles.d.cts +6 -0
- package/build/components/curve/styles.d.ts +6 -0
- package/build/components/curve/styles.js +490 -0
- package/build/components/curve/svg-renderer.cjs +185 -0
- package/build/components/curve/svg-renderer.d.cts +9 -0
- package/build/components/curve/svg-renderer.d.ts +9 -0
- package/build/components/curve/svg-renderer.js +175 -0
- package/build/components/curve/toolbar.cjs +368 -0
- package/build/components/curve/toolbar.d.cts +26 -0
- package/build/components/curve/toolbar.d.ts +26 -0
- package/build/components/curve/toolbar.js +364 -0
- package/build/components/curve/types.cjs +10 -0
- package/build/components/curve/types.d.cts +33 -0
- package/build/components/curve/types.d.ts +33 -0
- package/build/components/curve/types.js +7 -0
- package/build/components/curve/utils.cjs +541 -0
- package/build/components/curve/utils.d.cts +33 -0
- package/build/components/curve/utils.d.ts +33 -0
- package/build/components/curve/utils.js +521 -0
- package/build/components/index.cjs +18 -0
- package/build/components/index.d.cts +2 -0
- package/build/components/index.d.ts +2 -0
- package/build/components/index.js +2 -0
- package/build/decorators/Component.cjs +127 -0
- package/build/decorators/Component.d.cts +28 -0
- package/build/decorators/Component.d.ts +28 -0
- package/build/decorators/Component.js +123 -0
- package/build/decorators/Listen.cjs +154 -0
- package/build/decorators/Listen.d.cts +18 -0
- package/build/decorators/Listen.d.ts +18 -0
- package/build/decorators/Listen.js +151 -0
- package/build/decorators/OutsideClick.cjs +64 -0
- package/build/decorators/OutsideClick.d.cts +16 -0
- package/build/decorators/OutsideClick.d.ts +16 -0
- package/build/decorators/OutsideClick.js +59 -0
- package/build/decorators/Prop.cjs +273 -0
- package/build/decorators/Prop.d.cts +22 -0
- package/build/decorators/Prop.d.ts +22 -0
- package/build/decorators/Prop.js +270 -0
- package/build/decorators/Query.cjs +79 -0
- package/build/decorators/Query.d.cts +27 -0
- package/build/decorators/Query.d.ts +27 -0
- package/build/decorators/Query.js +76 -0
- package/build/decorators/Watch.cjs +52 -0
- package/build/decorators/Watch.d.cts +11 -0
- package/build/decorators/Watch.d.ts +11 -0
- package/build/decorators/Watch.js +49 -0
- package/build/decorators/index.cjs +15 -0
- package/build/decorators/index.d.cts +6 -0
- package/build/decorators/index.d.ts +6 -0
- package/build/decorators/index.js +6 -0
- package/build/elements/button/index.cjs +214 -0
- package/build/elements/button/index.d.cts +11 -0
- package/build/elements/button/index.d.ts +11 -0
- package/build/elements/button/index.js +210 -0
- package/build/elements/checkbox/index.cjs +316 -0
- package/build/elements/checkbox/index.d.cts +14 -0
- package/build/elements/checkbox/index.d.ts +14 -0
- package/build/elements/checkbox/index.js +312 -0
- package/build/elements/color/index.cjs +154 -0
- package/build/elements/color/index.d.cts +18 -0
- package/build/elements/color/index.d.ts +18 -0
- package/build/elements/color/index.js +150 -0
- package/build/elements/color/picker.cjs +544 -0
- package/build/elements/color/picker.d.cts +37 -0
- package/build/elements/color/picker.d.ts +37 -0
- package/build/elements/color/picker.js +540 -0
- package/build/elements/color/utils.cjs +235 -0
- package/build/elements/color/utils.d.cts +37 -0
- package/build/elements/color/utils.d.ts +37 -0
- package/build/elements/color/utils.js +218 -0
- package/build/elements/dropdown/index.cjs +875 -0
- package/build/elements/dropdown/index.d.cts +30 -0
- package/build/elements/dropdown/index.d.ts +30 -0
- package/build/elements/dropdown/index.js +871 -0
- package/build/elements/field/index.cjs +82 -0
- package/build/elements/field/index.d.cts +4 -0
- package/build/elements/field/index.d.ts +4 -0
- package/build/elements/field/index.js +78 -0
- package/build/elements/icons/animation/chevron.cjs +57 -0
- package/build/elements/icons/animation/chevron.d.cts +10 -0
- package/build/elements/icons/animation/chevron.d.ts +10 -0
- package/build/elements/icons/animation/chevron.js +53 -0
- package/build/elements/icons/animation/clear.cjs +74 -0
- package/build/elements/icons/animation/clear.d.cts +3 -0
- package/build/elements/icons/animation/clear.d.ts +3 -0
- package/build/elements/icons/animation/clear.js +70 -0
- package/build/elements/icons/animation/grid.cjs +77 -0
- package/build/elements/icons/animation/grid.d.cts +8 -0
- package/build/elements/icons/animation/grid.d.ts +8 -0
- package/build/elements/icons/animation/grid.js +73 -0
- package/build/elements/icons/animation/loading.cjs +68 -0
- package/build/elements/icons/animation/loading.d.cts +3 -0
- package/build/elements/icons/animation/loading.d.ts +3 -0
- package/build/elements/icons/animation/loading.js +64 -0
- package/build/elements/icons/animation/snap.cjs +133 -0
- package/build/elements/icons/animation/snap.d.cts +8 -0
- package/build/elements/icons/animation/snap.d.ts +8 -0
- package/build/elements/icons/animation/snap.js +129 -0
- package/build/elements/icons/index.cjs +40 -0
- package/build/elements/icons/index.d.cts +24 -0
- package/build/elements/icons/index.d.ts +24 -0
- package/build/elements/icons/index.js +24 -0
- package/build/elements/icons/interface/anchor-add.cjs +35 -0
- package/build/elements/icons/interface/anchor-add.d.cts +3 -0
- package/build/elements/icons/interface/anchor-add.d.ts +3 -0
- package/build/elements/icons/interface/anchor-add.js +31 -0
- package/build/elements/icons/interface/anchor-remove.cjs +34 -0
- package/build/elements/icons/interface/anchor-remove.d.cts +3 -0
- package/build/elements/icons/interface/anchor-remove.d.ts +3 -0
- package/build/elements/icons/interface/anchor-remove.js +30 -0
- package/build/elements/icons/interface/arrow-up.cjs +30 -0
- package/build/elements/icons/interface/arrow-up.d.cts +3 -0
- package/build/elements/icons/interface/arrow-up.d.ts +3 -0
- package/build/elements/icons/interface/arrow-up.js +26 -0
- package/build/elements/icons/interface/arrows-vertical.cjs +30 -0
- package/build/elements/icons/interface/arrows-vertical.d.cts +3 -0
- package/build/elements/icons/interface/arrows-vertical.d.ts +3 -0
- package/build/elements/icons/interface/arrows-vertical.js +26 -0
- package/build/elements/icons/interface/bezier-angle.cjs +33 -0
- package/build/elements/icons/interface/bezier-angle.d.cts +3 -0
- package/build/elements/icons/interface/bezier-angle.d.ts +3 -0
- package/build/elements/icons/interface/bezier-angle.js +29 -0
- package/build/elements/icons/interface/bezier-distribute.cjs +34 -0
- package/build/elements/icons/interface/bezier-distribute.d.cts +3 -0
- package/build/elements/icons/interface/bezier-distribute.d.ts +3 -0
- package/build/elements/icons/interface/bezier-distribute.js +30 -0
- package/build/elements/icons/interface/bezier-length.cjs +31 -0
- package/build/elements/icons/interface/bezier-length.d.cts +3 -0
- package/build/elements/icons/interface/bezier-length.d.ts +3 -0
- package/build/elements/icons/interface/bezier-length.js +27 -0
- package/build/elements/icons/interface/bezier-mirror.cjs +31 -0
- package/build/elements/icons/interface/bezier-mirror.d.cts +3 -0
- package/build/elements/icons/interface/bezier-mirror.d.ts +3 -0
- package/build/elements/icons/interface/bezier-mirror.js +27 -0
- package/build/elements/icons/interface/bezier.cjs +26 -0
- package/build/elements/icons/interface/bezier.d.cts +3 -0
- package/build/elements/icons/interface/bezier.d.ts +3 -0
- package/build/elements/icons/interface/bezier.js +22 -0
- package/build/elements/icons/interface/check.cjs +30 -0
- package/build/elements/icons/interface/check.d.cts +3 -0
- package/build/elements/icons/interface/check.d.ts +3 -0
- package/build/elements/icons/interface/check.js +26 -0
- package/build/elements/icons/interface/circle-arrow-left.cjs +30 -0
- package/build/elements/icons/interface/circle-arrow-left.d.cts +3 -0
- package/build/elements/icons/interface/circle-arrow-left.d.ts +3 -0
- package/build/elements/icons/interface/circle-arrow-left.js +26 -0
- package/build/elements/icons/interface/circle-arrow-right.cjs +30 -0
- package/build/elements/icons/interface/circle-arrow-right.d.cts +3 -0
- package/build/elements/icons/interface/circle-arrow-right.d.ts +3 -0
- package/build/elements/icons/interface/circle-arrow-right.js +26 -0
- package/build/elements/icons/interface/code.cjs +30 -0
- package/build/elements/icons/interface/code.d.cts +3 -0
- package/build/elements/icons/interface/code.d.ts +3 -0
- package/build/elements/icons/interface/code.js +26 -0
- package/build/elements/icons/interface/dots.cjs +32 -0
- package/build/elements/icons/interface/dots.d.cts +3 -0
- package/build/elements/icons/interface/dots.d.ts +3 -0
- package/build/elements/icons/interface/dots.js +28 -0
- package/build/elements/icons/interface/mention.cjs +30 -0
- package/build/elements/icons/interface/mention.d.cts +3 -0
- package/build/elements/icons/interface/mention.d.ts +3 -0
- package/build/elements/icons/interface/mention.js +26 -0
- package/build/elements/icons/interface/minus.cjs +30 -0
- package/build/elements/icons/interface/minus.d.cts +3 -0
- package/build/elements/icons/interface/minus.d.ts +3 -0
- package/build/elements/icons/interface/minus.js +26 -0
- package/build/elements/icons/interface/picker.cjs +34 -0
- package/build/elements/icons/interface/picker.d.cts +3 -0
- package/build/elements/icons/interface/picker.d.ts +3 -0
- package/build/elements/icons/interface/picker.js +30 -0
- package/build/elements/icons/interface/plus.cjs +30 -0
- package/build/elements/icons/interface/plus.d.cts +3 -0
- package/build/elements/icons/interface/plus.d.ts +3 -0
- package/build/elements/icons/interface/plus.js +26 -0
- package/build/elements/icons/interface/settings.cjs +30 -0
- package/build/elements/icons/interface/settings.d.cts +3 -0
- package/build/elements/icons/interface/settings.d.ts +3 -0
- package/build/elements/icons/interface/settings.js +26 -0
- package/build/elements/index.cjs +62 -0
- package/build/elements/index.d.cts +22 -0
- package/build/elements/index.d.ts +22 -0
- package/build/elements/index.js +22 -0
- package/build/elements/input/index.cjs +273 -0
- package/build/elements/input/index.d.cts +17 -0
- package/build/elements/input/index.d.ts +17 -0
- package/build/elements/input/index.js +269 -0
- package/build/elements/logo/index.cjs +732 -0
- package/build/elements/logo/index.d.cts +17 -0
- package/build/elements/logo/index.d.ts +17 -0
- package/build/elements/logo/index.js +728 -0
- package/build/elements/monitor/fps.cjs +432 -0
- package/build/elements/monitor/fps.d.cts +21 -0
- package/build/elements/monitor/fps.d.ts +21 -0
- package/build/elements/monitor/fps.js +428 -0
- package/build/elements/monitor/index.cjs +670 -0
- package/build/elements/monitor/index.d.cts +112 -0
- package/build/elements/monitor/index.d.ts +112 -0
- package/build/elements/monitor/index.js +666 -0
- package/build/elements/number/index.cjs +173 -0
- package/build/elements/number/index.d.cts +19 -0
- package/build/elements/number/index.d.ts +19 -0
- package/build/elements/number/index.js +169 -0
- package/build/elements/origin/index.cjs +169 -0
- package/build/elements/origin/index.d.cts +12 -0
- package/build/elements/origin/index.d.ts +12 -0
- package/build/elements/origin/index.js +165 -0
- package/build/elements/popover/index.cjs +209 -0
- package/build/elements/popover/index.d.cts +19 -0
- package/build/elements/popover/index.d.ts +19 -0
- package/build/elements/popover/index.js +205 -0
- package/build/elements/radio/index.cjs +301 -0
- package/build/elements/radio/index.d.cts +13 -0
- package/build/elements/radio/index.d.ts +13 -0
- package/build/elements/radio/index.js +283 -0
- package/build/elements/radio/input.cjs +329 -0
- package/build/elements/radio/input.d.cts +15 -0
- package/build/elements/radio/input.d.ts +15 -0
- package/build/elements/radio/input.js +325 -0
- package/build/elements/radio/option.cjs +15 -0
- package/build/elements/radio/option.d.cts +3 -0
- package/build/elements/radio/option.d.ts +3 -0
- package/build/elements/radio/option.js +11 -0
- package/build/elements/shared.cjs +66 -0
- package/build/elements/shared.d.cts +40 -0
- package/build/elements/shared.d.ts +40 -0
- package/build/elements/shared.js +59 -0
- package/build/elements/slider/index.cjs +232 -0
- package/build/elements/slider/index.d.cts +20 -0
- package/build/elements/slider/index.d.ts +20 -0
- package/build/elements/slider/index.js +228 -0
- package/build/elements/state/index.cjs +681 -0
- package/build/elements/state/index.d.cts +86 -0
- package/build/elements/state/index.d.ts +86 -0
- package/build/elements/state/index.js +677 -0
- package/build/elements/toggle/index.cjs +151 -0
- package/build/elements/toggle/index.d.cts +9 -0
- package/build/elements/toggle/index.d.ts +9 -0
- package/build/elements/toggle/index.js +147 -0
- package/build/elements/tooltip/index.cjs +187 -0
- package/build/elements/tooltip/index.d.cts +17 -0
- package/build/elements/tooltip/index.d.ts +17 -0
- package/build/elements/tooltip/index.js +183 -0
- package/build/index.cjs +40 -0
- package/build/index.d.cts +6 -0
- package/build/index.d.ts +6 -0
- package/build/index.js +12 -0
- package/build/init.cjs +325 -0
- package/build/init.d.cts +157 -0
- package/build/init.d.ts +157 -0
- package/build/init.js +289 -0
- package/build/internal/component-loaders.cjs +206 -0
- package/build/internal/component-loaders.d.cts +52 -0
- package/build/internal/component-loaders.d.ts +52 -0
- package/build/internal/component-loaders.js +167 -0
- package/build/internal/fonts.cjs +128 -0
- package/build/internal/fonts.d.cts +32 -0
- package/build/internal/fonts.d.ts +32 -0
- package/build/internal/fonts.js +123 -0
- package/build/internal/lazy-load.cjs +89 -0
- package/build/internal/lazy-load.d.cts +32 -0
- package/build/internal/lazy-load.d.ts +32 -0
- package/build/internal/lazy-load.js +86 -0
- package/build/internal/style-inject.cjs +236 -0
- package/build/internal/style-inject.d.cts +44 -0
- package/build/internal/style-inject.d.ts +44 -0
- package/build/internal/style-inject.js +226 -0
- package/build/register.cjs +36 -0
- package/build/register.d.cts +32 -0
- package/build/register.d.ts +32 -0
- package/build/register.js +34 -0
- package/build/theme/index.cjs +452 -0
- package/build/theme/index.d.cts +146 -0
- package/build/theme/index.d.ts +146 -0
- package/build/theme/index.js +423 -0
- package/build/theme/presets.cjs +54 -0
- package/build/theme/presets.d.cts +19 -0
- package/build/theme/presets.d.ts +19 -0
- package/build/theme/presets.js +51 -0
- package/build/theme/registry.cjs +204 -0
- package/build/theme/registry.d.cts +99 -0
- package/build/theme/registry.d.ts +99 -0
- package/build/theme/registry.js +194 -0
- package/build/theme/tokens.cjs +148 -0
- package/build/theme/tokens.d.cts +163 -0
- package/build/theme/tokens.d.ts +163 -0
- package/build/theme/tokens.js +145 -0
- package/build/utils/dismiss-controller.cjs +77 -0
- package/build/utils/dismiss-controller.d.cts +14 -0
- package/build/utils/dismiss-controller.d.ts +14 -0
- package/build/utils/dismiss-controller.js +73 -0
- package/build/utils/index.cjs +18 -0
- package/build/utils/index.d.cts +3 -0
- package/build/utils/index.d.ts +3 -0
- package/build/utils/index.js +3 -0
- package/build/utils/outside-click.cjs +82 -0
- package/build/utils/outside-click.d.cts +18 -0
- package/build/utils/outside-click.d.ts +18 -0
- package/build/utils/outside-click.js +74 -0
- package/build/utils/template-helpers.cjs +39 -0
- package/build/utils/template-helpers.d.cts +13 -0
- package/build/utils/template-helpers.d.ts +13 -0
- package/build/utils/template-helpers.js +28 -0
- package/package.json +96 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { html } from 'lit-html';
|
|
2
|
+
import { DEFAULT_HANDLE_LENGTH } from "./constants.js";
|
|
3
|
+
import { canvasControlsStyles } from "./styles.js";
|
|
4
|
+
import { EasingType } from "./types.js";
|
|
5
|
+
import { normalizeLinearPoints, normalizeVector, vectorLength } from "./utils.js";
|
|
6
|
+
import { Component } from '~/decorators/Component';
|
|
7
|
+
import { Prop } from '~/decorators/Prop';
|
|
8
|
+
import { dispatchControlEvent } from '~/elements/shared';
|
|
9
|
+
const HOST_HANDLER_MAP = {
|
|
10
|
+
'points-change': 'handlePointsChange',
|
|
11
|
+
'linear-point-focus': 'handleLinearPointFocus'
|
|
12
|
+
};
|
|
13
|
+
@Component({
|
|
14
|
+
tag: 'ease-curve-canvas-controls',
|
|
15
|
+
styles: canvasControlsStyles,
|
|
16
|
+
template() {
|
|
17
|
+
if (this.easingType !== EasingType.LINEAR || !Array.isArray(this.points)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const focusedIndex = this.focusedLinearIndex;
|
|
21
|
+
if (focusedIndex === null) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const points = this.points;
|
|
25
|
+
const selectedPoint = points[focusedIndex];
|
|
26
|
+
if (!selectedPoint) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const isInnerPoint = focusedIndex > 0 && focusedIndex < points.length - 1;
|
|
30
|
+
if (!isInnerPoint) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const hasInHandle = selectedPoint.cpInX !== undefined || selectedPoint.cpInY !== undefined;
|
|
34
|
+
const hasOutHandle = selectedPoint.cpOutX !== undefined || selectedPoint.cpOutY !== undefined;
|
|
35
|
+
const hasAnyHandle = hasInHandle || hasOutHandle;
|
|
36
|
+
return html `
|
|
37
|
+
<div class="overlay-controls">
|
|
38
|
+
<button
|
|
39
|
+
type="button"
|
|
40
|
+
class="overlay-button ${selectedPoint.isLinked ? 'active' : 'inactive'}"
|
|
41
|
+
@click=${this.handleToggleMirrorAngle}
|
|
42
|
+
>
|
|
43
|
+
<ease-icon-bezier-angle></ease-icon-bezier-angle>
|
|
44
|
+
</button>
|
|
45
|
+
<button
|
|
46
|
+
type="button"
|
|
47
|
+
class="overlay-button ${selectedPoint.mirrorLength !== false && selectedPoint.isLinked ? 'active' : 'inactive'}"
|
|
48
|
+
@click=${this.handleToggleMirrorLength}
|
|
49
|
+
?disabled=${!selectedPoint.isLinked}
|
|
50
|
+
>
|
|
51
|
+
<ease-icon-bezier-length></ease-icon-bezier-length>
|
|
52
|
+
</button>
|
|
53
|
+
${hasAnyHandle
|
|
54
|
+
? html `
|
|
55
|
+
<button
|
|
56
|
+
type="button"
|
|
57
|
+
class="overlay-button"
|
|
58
|
+
@click=${this.handleRemoveSmoothing}
|
|
59
|
+
>
|
|
60
|
+
<ease-icon-bezier></ease-icon-bezier>
|
|
61
|
+
</button>
|
|
62
|
+
`
|
|
63
|
+
: html `
|
|
64
|
+
<button
|
|
65
|
+
type="button"
|
|
66
|
+
class="overlay-button"
|
|
67
|
+
@click=${this.handleAddSmoothing}
|
|
68
|
+
>
|
|
69
|
+
<ease-icon-bezier-mirror></ease-icon-bezier-mirror>
|
|
70
|
+
</button>
|
|
71
|
+
`}
|
|
72
|
+
</div>
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
export class CanvasControls extends HTMLElement {
|
|
77
|
+
@Prop({ reflect: true })
|
|
78
|
+
accessor easingType;
|
|
79
|
+
@Prop({ type: Object, reflect: false })
|
|
80
|
+
accessor points;
|
|
81
|
+
@Prop({ type: Number, reflect: false, defaultValue: null })
|
|
82
|
+
accessor focusedLinearIndex = null;
|
|
83
|
+
#getEventTarget = () => {
|
|
84
|
+
const root = this.getRootNode();
|
|
85
|
+
if (root instanceof ShadowRoot && root.host instanceof HTMLElement) {
|
|
86
|
+
return root.host;
|
|
87
|
+
}
|
|
88
|
+
return this;
|
|
89
|
+
};
|
|
90
|
+
#getLinearPoints = () => {
|
|
91
|
+
if (!Array.isArray(this.points)) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
return this.points;
|
|
95
|
+
};
|
|
96
|
+
#notifyHost = (type, value, event) => {
|
|
97
|
+
const target = this.#getEventTarget();
|
|
98
|
+
const detail = { value, event };
|
|
99
|
+
dispatchControlEvent(target, type, detail);
|
|
100
|
+
};
|
|
101
|
+
#emitPoints = (points, event) => {
|
|
102
|
+
this.points = points;
|
|
103
|
+
this.#notifyHost('points-change', points, event);
|
|
104
|
+
};
|
|
105
|
+
handleToggleMirrorAngle = (event) => {
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
const points = this.#getLinearPoints();
|
|
108
|
+
if (!points) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const index = this.focusedLinearIndex;
|
|
112
|
+
if (index === null) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const point = points[index];
|
|
116
|
+
if (!point) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const updatedPoints = [...points];
|
|
120
|
+
const updatedPoint = { ...point };
|
|
121
|
+
updatedPoints[index] = updatedPoint;
|
|
122
|
+
const nextState = !updatedPoint.isLinked;
|
|
123
|
+
if (nextState) {
|
|
124
|
+
this.#ensureSmoothHandles(updatedPoint, index, points);
|
|
125
|
+
updatedPoint.mirrorLength = true;
|
|
126
|
+
this.#alignMirrorLength(updatedPoint);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
updatedPoint.mirrorLength = false;
|
|
130
|
+
}
|
|
131
|
+
updatedPoint.isLinked = nextState;
|
|
132
|
+
const normalizedPoints = normalizeLinearPoints(updatedPoints);
|
|
133
|
+
this.#emitPoints(normalizedPoints, event);
|
|
134
|
+
this.focusedLinearIndex = index;
|
|
135
|
+
this.#notifyHost('linear-point-focus', index, event);
|
|
136
|
+
};
|
|
137
|
+
handleToggleMirrorLength = (event) => {
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
const points = this.#getLinearPoints();
|
|
140
|
+
if (!points) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const index = this.focusedLinearIndex;
|
|
144
|
+
if (index === null) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const point = points[index];
|
|
148
|
+
if (!point || !point.isLinked) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const updatedPoints = [...points];
|
|
152
|
+
const updatedPoint = { ...point };
|
|
153
|
+
updatedPoints[index] = updatedPoint;
|
|
154
|
+
const nextState = updatedPoint.mirrorLength === false;
|
|
155
|
+
updatedPoint.mirrorLength = nextState;
|
|
156
|
+
if (nextState) {
|
|
157
|
+
this.#ensureSmoothHandles(updatedPoint, index, points);
|
|
158
|
+
this.#alignMirrorLength(updatedPoint);
|
|
159
|
+
}
|
|
160
|
+
const normalizedPoints = normalizeLinearPoints(updatedPoints);
|
|
161
|
+
this.#emitPoints(normalizedPoints, event);
|
|
162
|
+
this.focusedLinearIndex = index;
|
|
163
|
+
this.#notifyHost('linear-point-focus', index, event);
|
|
164
|
+
};
|
|
165
|
+
handleRemoveSmoothing = (event) => {
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
const points = this.#getLinearPoints();
|
|
168
|
+
if (!points) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const index = this.focusedLinearIndex;
|
|
172
|
+
if (index === null) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const existingPoint = points[index];
|
|
176
|
+
if (!existingPoint) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const updatedPoints = [...points];
|
|
180
|
+
const updatedPoint = { ...existingPoint };
|
|
181
|
+
updatedPoints[index] = updatedPoint;
|
|
182
|
+
delete updatedPoint.cpInX;
|
|
183
|
+
delete updatedPoint.cpInY;
|
|
184
|
+
delete updatedPoint.cpOutX;
|
|
185
|
+
delete updatedPoint.cpOutY;
|
|
186
|
+
delete updatedPoint.isLinked;
|
|
187
|
+
delete updatedPoint.mirrorLength;
|
|
188
|
+
const normalizedPoints = normalizeLinearPoints(updatedPoints);
|
|
189
|
+
this.#emitPoints(normalizedPoints, event);
|
|
190
|
+
this.focusedLinearIndex = index;
|
|
191
|
+
this.#notifyHost('linear-point-focus', index, event);
|
|
192
|
+
};
|
|
193
|
+
handleAddSmoothing = (event) => {
|
|
194
|
+
event.preventDefault();
|
|
195
|
+
const points = this.#getLinearPoints();
|
|
196
|
+
if (!points) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const index = this.focusedLinearIndex;
|
|
200
|
+
if (index === null) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const point = points[index];
|
|
204
|
+
if (!point) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const updatedPoints = [...points];
|
|
208
|
+
const updatedPoint = { ...point };
|
|
209
|
+
updatedPoints[index] = updatedPoint;
|
|
210
|
+
this.#ensureSmoothHandles(updatedPoint, index, points);
|
|
211
|
+
updatedPoint.isLinked = true;
|
|
212
|
+
updatedPoint.mirrorLength = true;
|
|
213
|
+
this.#alignMirrorLength(updatedPoint);
|
|
214
|
+
const normalizedPoints = normalizeLinearPoints(updatedPoints);
|
|
215
|
+
this.#emitPoints(normalizedPoints, event);
|
|
216
|
+
this.focusedLinearIndex = index;
|
|
217
|
+
this.#notifyHost('linear-point-focus', index, event);
|
|
218
|
+
};
|
|
219
|
+
#ensureSmoothHandles(point, index, points) {
|
|
220
|
+
const prev = points[index - 1];
|
|
221
|
+
const next = points[index + 1];
|
|
222
|
+
let refDx = point.cpOutX ?? -(point.cpInX ?? 0);
|
|
223
|
+
let refDy = point.cpOutY ?? -(point.cpInY ?? 0);
|
|
224
|
+
if (refDx === 0 && refDy === 0) {
|
|
225
|
+
let dirX = 0;
|
|
226
|
+
let dirY = 0;
|
|
227
|
+
if (prev && next) {
|
|
228
|
+
dirX = next.x - prev.x;
|
|
229
|
+
dirY = next.y - prev.y;
|
|
230
|
+
}
|
|
231
|
+
else if (next) {
|
|
232
|
+
dirX = next.x - point.x;
|
|
233
|
+
dirY = next.y - point.y;
|
|
234
|
+
}
|
|
235
|
+
else if (prev) {
|
|
236
|
+
dirX = point.x - prev.x;
|
|
237
|
+
dirY = point.y - prev.y;
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
dirX = 1;
|
|
241
|
+
dirY = 0;
|
|
242
|
+
}
|
|
243
|
+
const direction = normalizeVector(dirX, dirY);
|
|
244
|
+
const length = DEFAULT_HANDLE_LENGTH;
|
|
245
|
+
point.cpInX = -direction.dx * length;
|
|
246
|
+
point.cpInY = -direction.dy * length;
|
|
247
|
+
point.cpOutX = direction.dx * length;
|
|
248
|
+
point.cpOutY = direction.dy * length;
|
|
249
|
+
refDx = point.cpOutX;
|
|
250
|
+
refDy = point.cpOutY;
|
|
251
|
+
}
|
|
252
|
+
if (refDx === 0 && refDy === 0) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const normalized = normalizeVector(refDx, refDy);
|
|
256
|
+
const referenceLength = vectorLength(refDx, refDy);
|
|
257
|
+
const inLength = vectorLength(point.cpInX ?? 0, point.cpInY ?? 0) || referenceLength;
|
|
258
|
+
point.cpInX = -normalized.dx * inLength;
|
|
259
|
+
point.cpInY = -normalized.dy * inLength;
|
|
260
|
+
const outLength = vectorLength(point.cpOutX ?? 0, point.cpOutY ?? 0) || referenceLength;
|
|
261
|
+
point.cpOutX = normalized.dx * outLength;
|
|
262
|
+
point.cpOutY = normalized.dy * outLength;
|
|
263
|
+
}
|
|
264
|
+
#alignMirrorLength(point) {
|
|
265
|
+
if (!point.isLinked) {
|
|
266
|
+
point.mirrorLength = false;
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const outLength = vectorLength(point.cpOutX ?? 0, point.cpOutY ?? 0);
|
|
270
|
+
const inLength = vectorLength(point.cpInX ?? 0, point.cpInY ?? 0);
|
|
271
|
+
const targetLength = Math.max(outLength, inLength);
|
|
272
|
+
if (targetLength <= 0) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (outLength > 0) {
|
|
276
|
+
const outDirection = normalizeVector(point.cpOutX ?? 0, point.cpOutY ?? 0);
|
|
277
|
+
point.cpOutX = outDirection.dx * targetLength;
|
|
278
|
+
point.cpOutY = outDirection.dy * targetLength;
|
|
279
|
+
}
|
|
280
|
+
else if (inLength > 0) {
|
|
281
|
+
const inDirection = normalizeVector(point.cpInX ?? 0, point.cpInY ?? 0);
|
|
282
|
+
point.cpOutX = -inDirection.dx * targetLength;
|
|
283
|
+
point.cpOutY = -inDirection.dy * targetLength;
|
|
284
|
+
}
|
|
285
|
+
if (inLength > 0) {
|
|
286
|
+
const inDirection = normalizeVector(point.cpInX ?? 0, point.cpInY ?? 0);
|
|
287
|
+
point.cpInX = inDirection.dx * targetLength;
|
|
288
|
+
point.cpInY = inDirection.dy * targetLength;
|
|
289
|
+
}
|
|
290
|
+
else if (outLength > 0) {
|
|
291
|
+
const outDirection = normalizeVector(point.cpOutX ?? 0, point.cpOutY ?? 0);
|
|
292
|
+
point.cpInX = -outDirection.dx * targetLength;
|
|
293
|
+
point.cpInY = -outDirection.dy * targetLength;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|