@hyalo/angular 0.1.0 → 0.3.1
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/CHANGELOG.md +95 -41
- package/README.md +46 -32
- package/fesm2022/hyalo-angular-accordion.mjs +6 -6
- package/fesm2022/hyalo-angular-accordion.mjs.map +1 -1
- package/fesm2022/hyalo-angular-alert.mjs +171 -0
- package/fesm2022/hyalo-angular-alert.mjs.map +1 -0
- package/fesm2022/hyalo-angular-aspect-ratio.mjs +64 -0
- package/fesm2022/hyalo-angular-aspect-ratio.mjs.map +1 -0
- package/fesm2022/hyalo-angular-avatar.mjs +169 -0
- package/fesm2022/hyalo-angular-avatar.mjs.map +1 -0
- package/fesm2022/hyalo-angular-badge.mjs +268 -0
- package/fesm2022/hyalo-angular-badge.mjs.map +1 -0
- package/fesm2022/hyalo-angular-bento.mjs +132 -0
- package/fesm2022/hyalo-angular-bento.mjs.map +1 -0
- package/fesm2022/hyalo-angular-blocks.mjs +985 -0
- package/fesm2022/hyalo-angular-blocks.mjs.map +1 -0
- package/fesm2022/hyalo-angular-border-beam.mjs +73 -0
- package/fesm2022/hyalo-angular-border-beam.mjs.map +1 -0
- package/fesm2022/hyalo-angular-breadcrumb.mjs +77 -0
- package/fesm2022/hyalo-angular-breadcrumb.mjs.map +1 -0
- package/fesm2022/hyalo-angular-button-group.mjs +90 -0
- package/fesm2022/hyalo-angular-button-group.mjs.map +1 -0
- package/fesm2022/hyalo-angular-button.mjs +4 -3
- package/fesm2022/hyalo-angular-button.mjs.map +1 -1
- package/fesm2022/hyalo-angular-card.mjs +2 -2
- package/fesm2022/hyalo-angular-card.mjs.map +1 -1
- package/fesm2022/hyalo-angular-carousel.mjs +709 -0
- package/fesm2022/hyalo-angular-carousel.mjs.map +1 -0
- package/fesm2022/hyalo-angular-chapter-nav.mjs +336 -0
- package/fesm2022/hyalo-angular-chapter-nav.mjs.map +1 -0
- package/fesm2022/hyalo-angular-chart-engine-DSJop6He.mjs +5 -0
- package/fesm2022/hyalo-angular-chart-engine-DSJop6He.mjs.map +1 -0
- package/fesm2022/hyalo-angular-chart.mjs +391 -0
- package/fesm2022/hyalo-angular-chart.mjs.map +1 -0
- package/fesm2022/hyalo-angular-choice.mjs +2 -1
- package/fesm2022/hyalo-angular-choice.mjs.map +1 -1
- package/fesm2022/hyalo-angular-code-block-highlight-B20d5C76.mjs +40 -0
- package/fesm2022/hyalo-angular-code-block-highlight-B20d5C76.mjs.map +1 -0
- package/fesm2022/hyalo-angular-code-block.mjs +161 -0
- package/fesm2022/hyalo-angular-code-block.mjs.map +1 -0
- package/fesm2022/hyalo-angular-command.mjs +193 -0
- package/fesm2022/hyalo-angular-command.mjs.map +1 -0
- package/fesm2022/hyalo-angular-copy.mjs +138 -0
- package/fesm2022/hyalo-angular-copy.mjs.map +1 -0
- package/fesm2022/hyalo-angular-core.mjs +424 -0
- package/fesm2022/hyalo-angular-core.mjs.map +1 -0
- package/fesm2022/hyalo-angular-description-list.mjs +57 -0
- package/fesm2022/hyalo-angular-description-list.mjs.map +1 -0
- package/fesm2022/hyalo-angular-dialog.mjs +51 -22
- package/fesm2022/hyalo-angular-dialog.mjs.map +1 -1
- package/fesm2022/hyalo-angular-divider.mjs +66 -0
- package/fesm2022/hyalo-angular-divider.mjs.map +1 -0
- package/fesm2022/hyalo-angular-empty-state.mjs +123 -0
- package/fesm2022/hyalo-angular-empty-state.mjs.map +1 -0
- package/fesm2022/hyalo-angular-field.mjs +41 -9
- package/fesm2022/hyalo-angular-field.mjs.map +1 -1
- package/fesm2022/hyalo-angular-filter.mjs +309 -0
- package/fesm2022/hyalo-angular-filter.mjs.map +1 -0
- package/fesm2022/hyalo-angular-hotspot.mjs +225 -0
- package/fesm2022/hyalo-angular-hotspot.mjs.map +1 -0
- package/fesm2022/hyalo-angular-hover-card.mjs +233 -0
- package/fesm2022/hyalo-angular-hover-card.mjs.map +1 -0
- package/fesm2022/hyalo-angular-icon.mjs +42 -0
- package/fesm2022/hyalo-angular-icon.mjs.map +1 -1
- package/fesm2022/hyalo-angular-image-compare.mjs +168 -0
- package/fesm2022/hyalo-angular-image-compare.mjs.map +1 -0
- package/fesm2022/hyalo-angular-interaction.mjs +32 -41
- package/fesm2022/hyalo-angular-interaction.mjs.map +1 -1
- package/fesm2022/hyalo-angular-kbd.mjs +41 -0
- package/fesm2022/hyalo-angular-kbd.mjs.map +1 -0
- package/fesm2022/hyalo-angular-lightbox.mjs +228 -0
- package/fesm2022/hyalo-angular-lightbox.mjs.map +1 -0
- package/fesm2022/hyalo-angular-link.mjs +42 -0
- package/fesm2022/hyalo-angular-link.mjs.map +1 -0
- package/fesm2022/hyalo-angular-list.mjs +131 -0
- package/fesm2022/hyalo-angular-list.mjs.map +1 -0
- package/fesm2022/hyalo-angular-marquee.mjs +197 -0
- package/fesm2022/hyalo-angular-marquee.mjs.map +1 -0
- package/fesm2022/hyalo-angular-menu.mjs +423 -0
- package/fesm2022/hyalo-angular-menu.mjs.map +1 -0
- package/fesm2022/hyalo-angular-mesh.mjs +126 -0
- package/fesm2022/hyalo-angular-mesh.mjs.map +1 -0
- package/fesm2022/hyalo-angular-motion.mjs +620 -0
- package/fesm2022/hyalo-angular-motion.mjs.map +1 -0
- package/fesm2022/hyalo-angular-navbar.mjs +1 -1
- package/fesm2022/hyalo-angular-navbar.mjs.map +1 -1
- package/fesm2022/hyalo-angular-navigation-menu.mjs +222 -0
- package/fesm2022/hyalo-angular-navigation-menu.mjs.map +1 -0
- package/fesm2022/hyalo-angular-number-ticker.mjs +174 -0
- package/fesm2022/hyalo-angular-number-ticker.mjs.map +1 -0
- package/fesm2022/hyalo-angular-overlay.mjs +71 -2
- package/fesm2022/hyalo-angular-overlay.mjs.map +1 -1
- package/fesm2022/hyalo-angular-pagination.mjs +187 -0
- package/fesm2022/hyalo-angular-pagination.mjs.map +1 -0
- package/fesm2022/hyalo-angular-popover.mjs +34 -5
- package/fesm2022/hyalo-angular-popover.mjs.map +1 -1
- package/fesm2022/hyalo-angular-progress.mjs +209 -0
- package/fesm2022/hyalo-angular-progress.mjs.map +1 -0
- package/fesm2022/hyalo-angular-progressive-blur.mjs +73 -0
- package/fesm2022/hyalo-angular-progressive-blur.mjs.map +1 -0
- package/fesm2022/hyalo-angular-refraction-renderer-5ZA-kfsA.mjs +186 -0
- package/fesm2022/hyalo-angular-refraction-renderer-5ZA-kfsA.mjs.map +1 -0
- package/fesm2022/hyalo-angular-refraction.mjs +178 -0
- package/fesm2022/hyalo-angular-refraction.mjs.map +1 -0
- package/fesm2022/hyalo-angular-scroll-area.mjs +93 -0
- package/fesm2022/hyalo-angular-scroll-area.mjs.map +1 -0
- package/fesm2022/hyalo-angular-scroll-to-top.mjs +127 -0
- package/fesm2022/hyalo-angular-scroll-to-top.mjs.map +1 -0
- package/fesm2022/hyalo-angular-segmented.mjs +1 -1
- package/fesm2022/hyalo-angular-segmented.mjs.map +1 -1
- package/fesm2022/hyalo-angular-select.mjs +112 -15
- package/fesm2022/hyalo-angular-select.mjs.map +1 -1
- package/fesm2022/hyalo-angular-sidebar.mjs +241 -0
- package/fesm2022/hyalo-angular-sidebar.mjs.map +1 -0
- package/fesm2022/hyalo-angular-skeleton.mjs +131 -0
- package/fesm2022/hyalo-angular-skeleton.mjs.map +1 -0
- package/fesm2022/hyalo-angular-sparkline.mjs +110 -0
- package/fesm2022/hyalo-angular-sparkline.mjs.map +1 -0
- package/fesm2022/hyalo-angular-split-text.mjs +126 -0
- package/fesm2022/hyalo-angular-split-text.mjs.map +1 -0
- package/fesm2022/hyalo-angular-stat.mjs +193 -0
- package/fesm2022/hyalo-angular-stat.mjs.map +1 -0
- package/fesm2022/hyalo-angular-stepper.mjs +254 -0
- package/fesm2022/hyalo-angular-stepper.mjs.map +1 -0
- package/fesm2022/hyalo-angular-table.mjs +335 -0
- package/fesm2022/hyalo-angular-table.mjs.map +1 -0
- package/fesm2022/hyalo-angular-tabs.mjs +1 -1
- package/fesm2022/hyalo-angular-tabs.mjs.map +1 -1
- package/fesm2022/hyalo-angular-theme.mjs +1 -1
- package/fesm2022/hyalo-angular-theme.mjs.map +1 -1
- package/fesm2022/hyalo-angular-timeline.mjs +157 -0
- package/fesm2022/hyalo-angular-timeline.mjs.map +1 -0
- package/fesm2022/hyalo-angular-toast.mjs +2 -1
- package/fesm2022/hyalo-angular-toast.mjs.map +1 -1
- package/fesm2022/hyalo-angular.mjs +2 -473
- package/package.json +198 -2
- package/styles/parts/field.css +44 -36
- package/styles/parts/glass.css +2 -0
- package/styles/parts/motion.css +19 -0
- package/styles/parts/typography.css +17 -0
- package/types/hyalo-angular-accordion.d.ts +1 -1
- package/types/hyalo-angular-alert.d.ts +47 -0
- package/types/hyalo-angular-aspect-ratio.d.ts +13 -0
- package/types/hyalo-angular-avatar.d.ts +39 -0
- package/types/hyalo-angular-badge.d.ts +82 -0
- package/types/hyalo-angular-bento.d.ts +25 -0
- package/types/hyalo-angular-blocks.d.ts +272 -0
- package/types/hyalo-angular-border-beam.d.ts +15 -0
- package/types/hyalo-angular-breadcrumb.d.ts +22 -0
- package/types/hyalo-angular-button-group.d.ts +19 -0
- package/types/hyalo-angular-button.d.ts +4 -3
- package/types/hyalo-angular-card.d.ts +1 -1
- package/types/hyalo-angular-carousel.d.ts +147 -0
- package/types/hyalo-angular-chapter-nav.d.ts +79 -0
- package/types/hyalo-angular-chart.d.ts +90 -0
- package/types/hyalo-angular-code-block.d.ts +46 -0
- package/types/hyalo-angular-command.d.ts +41 -0
- package/types/hyalo-angular-copy.d.ts +39 -0
- package/types/hyalo-angular-core.d.ts +210 -0
- package/types/hyalo-angular-description-list.d.ts +16 -0
- package/types/hyalo-angular-dialog.d.ts +2 -1
- package/types/hyalo-angular-divider.d.ts +12 -0
- package/types/hyalo-angular-empty-state.d.ts +30 -0
- package/types/hyalo-angular-field.d.ts +10 -4
- package/types/hyalo-angular-filter.d.ts +122 -0
- package/types/hyalo-angular-hotspot.d.ts +70 -0
- package/types/hyalo-angular-hover-card.d.ts +47 -0
- package/types/hyalo-angular-image-compare.d.ts +55 -0
- package/types/hyalo-angular-kbd.d.ts +5 -0
- package/types/hyalo-angular-lightbox.d.ts +67 -0
- package/types/hyalo-angular-link.d.ts +5 -0
- package/types/hyalo-angular-list.d.ts +30 -0
- package/types/hyalo-angular-marquee.d.ts +48 -0
- package/types/hyalo-angular-menu.d.ts +105 -0
- package/types/hyalo-angular-mesh.d.ts +36 -0
- package/types/hyalo-angular-motion.d.ts +218 -0
- package/types/hyalo-angular-navigation-menu.d.ts +47 -0
- package/types/hyalo-angular-number-ticker.d.ts +52 -0
- package/types/hyalo-angular-overlay.d.ts +9 -0
- package/types/hyalo-angular-pagination.d.ts +59 -0
- package/types/hyalo-angular-popover.d.ts +10 -0
- package/types/hyalo-angular-progress.d.ts +46 -0
- package/types/hyalo-angular-progressive-blur.d.ts +14 -0
- package/types/hyalo-angular-refraction.d.ts +46 -0
- package/types/hyalo-angular-scroll-area.d.ts +18 -0
- package/types/hyalo-angular-scroll-to-top.d.ts +31 -0
- package/types/hyalo-angular-segmented.d.ts +1 -1
- package/types/hyalo-angular-select.d.ts +49 -3
- package/types/hyalo-angular-sidebar.d.ts +57 -0
- package/types/hyalo-angular-skeleton.d.ts +34 -0
- package/types/hyalo-angular-sparkline.d.ts +19 -0
- package/types/hyalo-angular-split-text.d.ts +24 -0
- package/types/hyalo-angular-stat.d.ts +56 -0
- package/types/hyalo-angular-stepper.d.ts +63 -0
- package/types/hyalo-angular-table.d.ts +125 -0
- package/types/hyalo-angular-timeline.d.ts +36 -0
- package/types/hyalo-angular.d.ts +2 -345
- package/fesm2022/hyalo-angular.mjs.map +0 -1
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { DOCUMENT, DestroyRef, Directive, ElementRef, Injectable, Injector, afterNextRender, computed, effect, inject, input, numberAttribute, signal } from "@angular/core";
|
|
3
|
+
import { HY_CONFIG, HyFidelity, ɵinjectIsBrowser, ɵmatchesMedia } from "@hyalo/angular/core";
|
|
4
|
+
const MOTION = {
|
|
5
|
+
settle: {
|
|
6
|
+
duration: .44,
|
|
7
|
+
ease: "power3.out",
|
|
8
|
+
css: "cubic-bezier(0.215, 0.61, 0.355, 1)"
|
|
9
|
+
},
|
|
10
|
+
pop: {
|
|
11
|
+
duration: .5,
|
|
12
|
+
ease: "back.out(1.5)",
|
|
13
|
+
css: "cubic-bezier(0.34, 1.56, 0.64, 1)"
|
|
14
|
+
},
|
|
15
|
+
quick: {
|
|
16
|
+
duration: .22,
|
|
17
|
+
ease: "power2.out",
|
|
18
|
+
css: "cubic-bezier(0.25, 0.46, 0.45, 0.94)"
|
|
19
|
+
},
|
|
20
|
+
scene: {
|
|
21
|
+
duration: .9,
|
|
22
|
+
ease: "expo.out",
|
|
23
|
+
css: "cubic-bezier(0.16, 1, 0.3, 1)"
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var HyMotion = class HyMotion {
|
|
27
|
+
config = inject(HY_CONFIG);
|
|
28
|
+
fidelity = inject(HyFidelity);
|
|
29
|
+
document = inject(DOCUMENT);
|
|
30
|
+
isBrowser = ɵinjectIsBrowser();
|
|
31
|
+
_reduced = signal(false, ...ngDevMode ? [{ debugName: "_reduced" }] : /* istanbul ignore next */ []);
|
|
32
|
+
gsapPromise;
|
|
33
|
+
reduced = this._reduced.asReadonly();
|
|
34
|
+
enabled = computed(() => !this._reduced() && this.fidelity.tier() !== "low", ...ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []);
|
|
35
|
+
constructor() {
|
|
36
|
+
if (!this.isBrowser || typeof matchMedia !== "function") return;
|
|
37
|
+
const query = matchMedia("(prefers-reduced-motion: reduce)");
|
|
38
|
+
const update = () => this._reduced.set(query.matches || this.document.documentElement.getAttribute("data-hy-motion") === "reduced");
|
|
39
|
+
update();
|
|
40
|
+
query.addEventListener("change", update);
|
|
41
|
+
inject(DestroyRef).onDestroy(() => query.removeEventListener("change", update));
|
|
42
|
+
}
|
|
43
|
+
setReduced(reduced) {
|
|
44
|
+
const root = this.document.documentElement;
|
|
45
|
+
if (reduced === null) {
|
|
46
|
+
root.removeAttribute("data-hy-motion");
|
|
47
|
+
this._reduced.set(ɵmatchesMedia("(prefers-reduced-motion: reduce)"));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
root.setAttribute("data-hy-motion", reduced ? "reduced" : "full");
|
|
51
|
+
this._reduced.set(reduced || ɵmatchesMedia("(prefers-reduced-motion: reduce)"));
|
|
52
|
+
}
|
|
53
|
+
gsap() {
|
|
54
|
+
const loader = this.config.gsap;
|
|
55
|
+
if (!this.isBrowser || !loader) return Promise.resolve(null);
|
|
56
|
+
this.gsapPromise ??= loader().catch(() => null);
|
|
57
|
+
return this.gsapPromise;
|
|
58
|
+
}
|
|
59
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
60
|
+
minVersion: "12.0.0",
|
|
61
|
+
version: "22.2.3",
|
|
62
|
+
ngImport: i0,
|
|
63
|
+
type: HyMotion,
|
|
64
|
+
deps: [],
|
|
65
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
66
|
+
});
|
|
67
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
68
|
+
minVersion: "12.0.0",
|
|
69
|
+
version: "22.2.3",
|
|
70
|
+
ngImport: i0,
|
|
71
|
+
type: HyMotion,
|
|
72
|
+
providedIn: "root"
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
76
|
+
minVersion: "12.0.0",
|
|
77
|
+
version: "22.2.3",
|
|
78
|
+
ngImport: i0,
|
|
79
|
+
type: HyMotion,
|
|
80
|
+
decorators: [{
|
|
81
|
+
type: Injectable,
|
|
82
|
+
args: [{ providedIn: "root" }]
|
|
83
|
+
}],
|
|
84
|
+
ctorParameters: () => []
|
|
85
|
+
});
|
|
86
|
+
const SPRINGS = {
|
|
87
|
+
settle: {
|
|
88
|
+
damping: 1,
|
|
89
|
+
response: .4
|
|
90
|
+
},
|
|
91
|
+
momentum: {
|
|
92
|
+
damping: .8,
|
|
93
|
+
response: .3
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const STEP = 1 / 240;
|
|
97
|
+
const MIN_RESPONSE = 1 / 60;
|
|
98
|
+
const MAX_STEPS = 240;
|
|
99
|
+
function assertFinite(value, name) {
|
|
100
|
+
if (!Number.isFinite(value)) throw new RangeError(`HySpring: ${name} must be finite.`);
|
|
101
|
+
}
|
|
102
|
+
const REST_DELTA = .1;
|
|
103
|
+
const REST_VELOCITY = 2;
|
|
104
|
+
var HySpring = class {
|
|
105
|
+
onUpdate;
|
|
106
|
+
value;
|
|
107
|
+
velocity = 0;
|
|
108
|
+
target = 0;
|
|
109
|
+
config = SPRINGS.settle;
|
|
110
|
+
onRest = null;
|
|
111
|
+
frame = 0;
|
|
112
|
+
last = 0;
|
|
113
|
+
constructor(initial, onUpdate) {
|
|
114
|
+
this.onUpdate = onUpdate;
|
|
115
|
+
assertFinite(initial, "initial value");
|
|
116
|
+
this.value = initial;
|
|
117
|
+
}
|
|
118
|
+
get running() {
|
|
119
|
+
return this.frame !== 0;
|
|
120
|
+
}
|
|
121
|
+
to(target, options = {}) {
|
|
122
|
+
const damping = options.damping ?? SPRINGS.settle.damping;
|
|
123
|
+
const response = options.response ?? SPRINGS.settle.response;
|
|
124
|
+
const velocity = options.velocity ?? this.velocity;
|
|
125
|
+
assertFinite(target, "target");
|
|
126
|
+
assertFinite(this.value, "current value");
|
|
127
|
+
assertFinite(velocity, "velocity");
|
|
128
|
+
if (!Number.isFinite(damping) || damping <= 0) throw new RangeError("HySpring: damping must be finite and greater than zero.");
|
|
129
|
+
if (!Number.isFinite(response) || response < MIN_RESPONSE) throw new RangeError("HySpring: response must be finite and at least 1/60 second.");
|
|
130
|
+
this.target = target;
|
|
131
|
+
this.config = {
|
|
132
|
+
damping,
|
|
133
|
+
response
|
|
134
|
+
};
|
|
135
|
+
this.velocity = velocity;
|
|
136
|
+
this.onRest = options.onRest ?? null;
|
|
137
|
+
if (this.frame) return;
|
|
138
|
+
this.last = -1;
|
|
139
|
+
this.frame = requestAnimationFrame(this.tick);
|
|
140
|
+
}
|
|
141
|
+
set(value) {
|
|
142
|
+
assertFinite(value, "value");
|
|
143
|
+
this.stop();
|
|
144
|
+
this.value = value;
|
|
145
|
+
this.velocity = 0;
|
|
146
|
+
this.onUpdate(value);
|
|
147
|
+
}
|
|
148
|
+
stop() {
|
|
149
|
+
cancelAnimationFrame(this.frame);
|
|
150
|
+
this.frame = 0;
|
|
151
|
+
this.onRest = null;
|
|
152
|
+
}
|
|
153
|
+
tick = (now) => {
|
|
154
|
+
const dt = this.last < 0 ? 1 / 60 : Math.max(0, Math.min((now - this.last) / 1e3, 1 / 15));
|
|
155
|
+
this.last = Math.max(now, this.last);
|
|
156
|
+
const stiffness = (2 * Math.PI / this.config.response) ** 2;
|
|
157
|
+
const friction = 4 * Math.PI * this.config.damping / this.config.response;
|
|
158
|
+
const steps = Math.max(1, Math.min(MAX_STEPS, Math.ceil(dt / Math.min(STEP, this.config.response / 60))));
|
|
159
|
+
const h = dt / steps;
|
|
160
|
+
for (let i = 0; i < steps; i++) {
|
|
161
|
+
this.velocity += (-stiffness * (this.value - this.target) - friction * this.velocity) * h;
|
|
162
|
+
this.value += this.velocity * h;
|
|
163
|
+
}
|
|
164
|
+
if (!Number.isFinite(this.value) || !Number.isFinite(this.velocity) || Math.abs(this.velocity) < REST_VELOCITY && Math.abs(this.value - this.target) < REST_DELTA) {
|
|
165
|
+
this.value = this.target;
|
|
166
|
+
this.velocity = 0;
|
|
167
|
+
this.frame = 0;
|
|
168
|
+
const done = this.onRest;
|
|
169
|
+
this.onRest = null;
|
|
170
|
+
this.onUpdate(this.value);
|
|
171
|
+
done?.();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
this.onUpdate(this.value);
|
|
175
|
+
this.frame = requestAnimationFrame(this.tick);
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
function project(velocity, decelerationRate = .998) {
|
|
179
|
+
return velocity / 1e3 * decelerationRate / (1 - decelerationRate);
|
|
180
|
+
}
|
|
181
|
+
function rubberband(overshoot, dimension, constant = .55) {
|
|
182
|
+
if (dimension <= 0) return 0;
|
|
183
|
+
const x = Math.abs(overshoot);
|
|
184
|
+
return Math.sign(overshoot) * (x * dimension * constant) / (dimension + constant * x);
|
|
185
|
+
}
|
|
186
|
+
var HyVelocityTracker = class {
|
|
187
|
+
samples = [];
|
|
188
|
+
add(value, time = performance.now()) {
|
|
189
|
+
this.samples.push({
|
|
190
|
+
t: time,
|
|
191
|
+
v: value
|
|
192
|
+
});
|
|
193
|
+
while (this.samples.length > 2 && time - (this.samples[0]?.t ?? time) > 100) this.samples.shift();
|
|
194
|
+
}
|
|
195
|
+
reset() {
|
|
196
|
+
this.samples = [];
|
|
197
|
+
}
|
|
198
|
+
velocity(now = performance.now()) {
|
|
199
|
+
const recent = this.samples.filter((s) => now - s.t <= 100);
|
|
200
|
+
const first = recent[0];
|
|
201
|
+
const last = recent[recent.length - 1];
|
|
202
|
+
if (!first || !last || last.t === first.t) return 0;
|
|
203
|
+
return (last.v - first.v) / (last.t - first.t) * 1e3;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
function injectHyVisibility() {
|
|
207
|
+
const host = inject(ElementRef).nativeElement;
|
|
208
|
+
const destroy = inject(DestroyRef);
|
|
209
|
+
const visible = signal(false, ...ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []);
|
|
210
|
+
afterNextRender(() => {
|
|
211
|
+
const doc = host.ownerDocument;
|
|
212
|
+
let intersects = typeof IntersectionObserver !== "function";
|
|
213
|
+
const update = () => visible.set(intersects && doc.visibilityState !== "hidden");
|
|
214
|
+
const observer = typeof IntersectionObserver === "function" ? new IntersectionObserver((entries) => {
|
|
215
|
+
intersects = entries.some((entry) => entry.isIntersecting);
|
|
216
|
+
update();
|
|
217
|
+
}) : null;
|
|
218
|
+
observer?.observe(host);
|
|
219
|
+
update();
|
|
220
|
+
doc.addEventListener("visibilitychange", update);
|
|
221
|
+
destroy.onDestroy(() => {
|
|
222
|
+
observer?.disconnect();
|
|
223
|
+
doc.removeEventListener("visibilitychange", update);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
return visible.asReadonly();
|
|
227
|
+
}
|
|
228
|
+
var HySceneLight = class HySceneLight {
|
|
229
|
+
document = inject(DOCUMENT);
|
|
230
|
+
motion = inject(HyMotion);
|
|
231
|
+
entries = /* @__PURE__ */ new Map();
|
|
232
|
+
observers = /* @__PURE__ */ new Map();
|
|
233
|
+
resize;
|
|
234
|
+
abort;
|
|
235
|
+
event;
|
|
236
|
+
frame = 0;
|
|
237
|
+
dirty = true;
|
|
238
|
+
constructor() {
|
|
239
|
+
effect(() => {
|
|
240
|
+
if (!this.motion.enabled()) this.reset();
|
|
241
|
+
});
|
|
242
|
+
inject(DestroyRef).onDestroy(() => {
|
|
243
|
+
this.reset();
|
|
244
|
+
this.abort?.abort();
|
|
245
|
+
this.resize?.disconnect();
|
|
246
|
+
this.observers.forEach((o) => o.disconnect());
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
register(host, handlers, scene = false, root = null) {
|
|
250
|
+
if (typeof IntersectionObserver !== "function" || !this.document.defaultView?.matchMedia("(hover: hover) and (pointer: fine)").matches) return () => handlers.destroy?.();
|
|
251
|
+
this.start();
|
|
252
|
+
const entry = {
|
|
253
|
+
host,
|
|
254
|
+
handlers,
|
|
255
|
+
scene,
|
|
256
|
+
active: false,
|
|
257
|
+
intersecting: false
|
|
258
|
+
};
|
|
259
|
+
const group = this.entries.get(host) ?? [];
|
|
260
|
+
group.push(entry);
|
|
261
|
+
this.entries.set(host, group);
|
|
262
|
+
let observer = this.observers.get(root);
|
|
263
|
+
if (!observer) {
|
|
264
|
+
observer = new IntersectionObserver((changes) => {
|
|
265
|
+
for (const change of changes) for (const item of this.entries.get(change.target) ?? []) {
|
|
266
|
+
item.intersecting = change.isIntersecting;
|
|
267
|
+
item.rect = void 0;
|
|
268
|
+
if (!item.intersecting) this.leave(item);
|
|
269
|
+
}
|
|
270
|
+
this.schedule();
|
|
271
|
+
}, { root });
|
|
272
|
+
this.observers.set(root, observer);
|
|
273
|
+
}
|
|
274
|
+
observer.observe(host);
|
|
275
|
+
this.resize?.observe(host);
|
|
276
|
+
return () => {
|
|
277
|
+
this.leave(entry);
|
|
278
|
+
handlers.destroy?.();
|
|
279
|
+
const remaining = (this.entries.get(host) ?? []).filter((item) => item !== entry);
|
|
280
|
+
if (remaining.length) this.entries.set(host, remaining);
|
|
281
|
+
else {
|
|
282
|
+
this.entries.delete(host);
|
|
283
|
+
this.observers.forEach((o) => o.unobserve(host));
|
|
284
|
+
this.resize?.unobserve(host);
|
|
285
|
+
}
|
|
286
|
+
if (!this.entries.size) {
|
|
287
|
+
this.reset();
|
|
288
|
+
this.abort?.abort();
|
|
289
|
+
this.abort = void 0;
|
|
290
|
+
this.resize?.disconnect();
|
|
291
|
+
this.resize = void 0;
|
|
292
|
+
this.observers.forEach((o) => o.disconnect());
|
|
293
|
+
this.observers.clear();
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
start() {
|
|
298
|
+
if (this.abort) return;
|
|
299
|
+
const options = {
|
|
300
|
+
passive: true,
|
|
301
|
+
capture: true,
|
|
302
|
+
signal: (this.abort = new AbortController()).signal
|
|
303
|
+
};
|
|
304
|
+
this.document.addEventListener("pointermove", (event) => {
|
|
305
|
+
if (event.pointerType === "touch") return;
|
|
306
|
+
this.event = event;
|
|
307
|
+
this.schedule();
|
|
308
|
+
}, options);
|
|
309
|
+
this.document.addEventListener("pointerout", (event) => {
|
|
310
|
+
if (!event.relatedTarget) this.reset();
|
|
311
|
+
}, options);
|
|
312
|
+
this.document.addEventListener("pointercancel", () => this.reset(), options);
|
|
313
|
+
this.document.addEventListener("scroll", () => {
|
|
314
|
+
this.dirty = true;
|
|
315
|
+
this.schedule();
|
|
316
|
+
}, options);
|
|
317
|
+
this.document.defaultView?.addEventListener("resize", () => {
|
|
318
|
+
this.dirty = true;
|
|
319
|
+
this.schedule();
|
|
320
|
+
}, options);
|
|
321
|
+
this.document.addEventListener("visibilitychange", () => {
|
|
322
|
+
if (this.document.hidden) this.reset();
|
|
323
|
+
}, options);
|
|
324
|
+
this.resize = typeof ResizeObserver === "function" ? new ResizeObserver(() => {
|
|
325
|
+
this.dirty = true;
|
|
326
|
+
this.schedule();
|
|
327
|
+
}) : void 0;
|
|
328
|
+
}
|
|
329
|
+
schedule() {
|
|
330
|
+
if (!this.frame && this.event && this.motion.enabled() && !this.document.hidden) this.frame = requestAnimationFrame(() => this.draw());
|
|
331
|
+
}
|
|
332
|
+
draw() {
|
|
333
|
+
this.frame = 0;
|
|
334
|
+
const event = this.event;
|
|
335
|
+
if (!event || !this.motion.enabled() || this.document.hidden) return;
|
|
336
|
+
const work = [];
|
|
337
|
+
const inactive = [];
|
|
338
|
+
for (const group of this.entries.values()) for (const entry of group) {
|
|
339
|
+
if (!entry.intersecting || !entry.host.isConnected || work.length >= 64) {
|
|
340
|
+
inactive.push(entry);
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
if (this.dirty || !entry.rect) entry.rect = entry.host.getBoundingClientRect();
|
|
344
|
+
const rect = entry.rect;
|
|
345
|
+
const inside = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
346
|
+
work.push({
|
|
347
|
+
entry,
|
|
348
|
+
rect,
|
|
349
|
+
inside
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
this.dirty = false;
|
|
353
|
+
for (const entry of inactive) this.leave(entry);
|
|
354
|
+
for (const { entry, rect, inside } of work) {
|
|
355
|
+
if (!inside && !entry.scene) {
|
|
356
|
+
this.leave(entry);
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
if (!rect.width || !rect.height) continue;
|
|
360
|
+
if (!entry.active) {
|
|
361
|
+
entry.active = true;
|
|
362
|
+
entry.handlers.enter?.(event, rect);
|
|
363
|
+
}
|
|
364
|
+
entry.handlers.move(event, rect);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
leave(entry) {
|
|
368
|
+
if (entry.active) {
|
|
369
|
+
entry.active = false;
|
|
370
|
+
entry.handlers.leave?.();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
reset() {
|
|
374
|
+
if (this.frame) cancelAnimationFrame(this.frame);
|
|
375
|
+
this.frame = 0;
|
|
376
|
+
this.event = void 0;
|
|
377
|
+
for (const group of this.entries.values()) for (const entry of group) this.leave(entry);
|
|
378
|
+
}
|
|
379
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
380
|
+
minVersion: "12.0.0",
|
|
381
|
+
version: "22.2.3",
|
|
382
|
+
ngImport: i0,
|
|
383
|
+
type: HySceneLight,
|
|
384
|
+
deps: [],
|
|
385
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
386
|
+
});
|
|
387
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
388
|
+
minVersion: "12.0.0",
|
|
389
|
+
version: "22.2.3",
|
|
390
|
+
ngImport: i0,
|
|
391
|
+
type: HySceneLight,
|
|
392
|
+
providedIn: "root"
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
396
|
+
minVersion: "12.0.0",
|
|
397
|
+
version: "22.2.3",
|
|
398
|
+
ngImport: i0,
|
|
399
|
+
type: HySceneLight,
|
|
400
|
+
decorators: [{
|
|
401
|
+
type: Injectable,
|
|
402
|
+
args: [{ providedIn: "root" }]
|
|
403
|
+
}],
|
|
404
|
+
ctorParameters: () => []
|
|
405
|
+
});
|
|
406
|
+
var HySceneLightDirective = class HySceneLightDirective {
|
|
407
|
+
constructor() {
|
|
408
|
+
const host = inject(ElementRef).nativeElement;
|
|
409
|
+
const scene = inject(HySceneLight), destroy = inject(DestroyRef);
|
|
410
|
+
afterNextRender(() => {
|
|
411
|
+
let lastX = "", lastY = "";
|
|
412
|
+
const unregister = scene.register(host, {
|
|
413
|
+
move: (event, rect) => {
|
|
414
|
+
const x = `${((event.clientX - rect.left) / rect.width * 100).toFixed(1)}%`;
|
|
415
|
+
const y = `${((event.clientY - rect.top) / rect.height * 100).toFixed(1)}%`;
|
|
416
|
+
if (x !== lastX) host.style.setProperty("--hy-px", lastX = x);
|
|
417
|
+
if (y !== lastY) host.style.setProperty("--hy-py", lastY = y);
|
|
418
|
+
host.style.setProperty("--hy-glow", "0.18");
|
|
419
|
+
},
|
|
420
|
+
leave: () => host.style.setProperty("--hy-glow", "0")
|
|
421
|
+
}, true);
|
|
422
|
+
destroy.onDestroy(unregister);
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
426
|
+
minVersion: "12.0.0",
|
|
427
|
+
version: "22.2.3",
|
|
428
|
+
ngImport: i0,
|
|
429
|
+
type: HySceneLightDirective,
|
|
430
|
+
deps: [],
|
|
431
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
432
|
+
});
|
|
433
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
434
|
+
minVersion: "14.0.0",
|
|
435
|
+
version: "22.2.3",
|
|
436
|
+
type: HySceneLightDirective,
|
|
437
|
+
isStandalone: true,
|
|
438
|
+
selector: "[hySceneLight]",
|
|
439
|
+
ngImport: i0
|
|
440
|
+
});
|
|
441
|
+
};
|
|
442
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
443
|
+
minVersion: "12.0.0",
|
|
444
|
+
version: "22.2.3",
|
|
445
|
+
ngImport: i0,
|
|
446
|
+
type: HySceneLightDirective,
|
|
447
|
+
decorators: [{
|
|
448
|
+
type: Directive,
|
|
449
|
+
args: [{ selector: "[hySceneLight]" }]
|
|
450
|
+
}],
|
|
451
|
+
ctorParameters: () => []
|
|
452
|
+
});
|
|
453
|
+
var HyFlip = class HyFlip {
|
|
454
|
+
host = inject(ElementRef).nativeElement;
|
|
455
|
+
motion = inject(HyMotion);
|
|
456
|
+
injector = inject(Injector);
|
|
457
|
+
destroy = inject(DestroyRef);
|
|
458
|
+
animation;
|
|
459
|
+
generation = 0;
|
|
460
|
+
constructor() {
|
|
461
|
+
effect(() => {
|
|
462
|
+
if (!this.motion.enabled()) this.animation?.cancel();
|
|
463
|
+
});
|
|
464
|
+
this.destroy.onDestroy(() => {
|
|
465
|
+
this.generation++;
|
|
466
|
+
this.animation?.cancel();
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
run(change) {
|
|
470
|
+
const generation = ++this.generation;
|
|
471
|
+
this.animation?.cancel();
|
|
472
|
+
const before = this.host.getBoundingClientRect();
|
|
473
|
+
change();
|
|
474
|
+
if (!this.motion.enabled() || typeof this.host.animate !== "function") return;
|
|
475
|
+
afterNextRender(() => {
|
|
476
|
+
if (this.destroy.destroyed || generation !== this.generation || !this.motion.enabled()) return;
|
|
477
|
+
const after = this.host.getBoundingClientRect();
|
|
478
|
+
if (!after.width || !after.height) return;
|
|
479
|
+
this.animation = this.host.animate([{
|
|
480
|
+
transform: `translate(${before.left - after.left}px, ${before.top - after.top}px) scale(${before.width / after.width}, ${before.height / after.height})`,
|
|
481
|
+
transformOrigin: "top left"
|
|
482
|
+
}, {
|
|
483
|
+
transform: "none",
|
|
484
|
+
transformOrigin: "top left"
|
|
485
|
+
}], {
|
|
486
|
+
duration: MOTION.quick.duration * 1e3,
|
|
487
|
+
easing: MOTION.settle.css,
|
|
488
|
+
composite: "add"
|
|
489
|
+
});
|
|
490
|
+
}, { injector: this.injector });
|
|
491
|
+
}
|
|
492
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
493
|
+
minVersion: "12.0.0",
|
|
494
|
+
version: "22.2.3",
|
|
495
|
+
ngImport: i0,
|
|
496
|
+
type: HyFlip,
|
|
497
|
+
deps: [],
|
|
498
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
499
|
+
});
|
|
500
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
501
|
+
minVersion: "14.0.0",
|
|
502
|
+
version: "22.2.3",
|
|
503
|
+
type: HyFlip,
|
|
504
|
+
isStandalone: true,
|
|
505
|
+
selector: "[hyFlip]",
|
|
506
|
+
exportAs: ["hyFlip"],
|
|
507
|
+
ngImport: i0
|
|
508
|
+
});
|
|
509
|
+
};
|
|
510
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
511
|
+
minVersion: "12.0.0",
|
|
512
|
+
version: "22.2.3",
|
|
513
|
+
ngImport: i0,
|
|
514
|
+
type: HyFlip,
|
|
515
|
+
decorators: [{
|
|
516
|
+
type: Directive,
|
|
517
|
+
args: [{
|
|
518
|
+
selector: "[hyFlip]",
|
|
519
|
+
exportAs: "hyFlip"
|
|
520
|
+
}]
|
|
521
|
+
}],
|
|
522
|
+
ctorParameters: () => []
|
|
523
|
+
});
|
|
524
|
+
var HyStagger = class HyStagger {
|
|
525
|
+
hyStagger = input(50, {
|
|
526
|
+
...ngDevMode ? { debugName: "hyStagger" } : /* istanbul ignore next */ {},
|
|
527
|
+
transform: (value) => numberAttribute(value, 50)
|
|
528
|
+
});
|
|
529
|
+
host = inject(ElementRef).nativeElement;
|
|
530
|
+
visible = injectHyVisibility();
|
|
531
|
+
motion = inject(HyMotion);
|
|
532
|
+
seen = /* @__PURE__ */ new WeakSet();
|
|
533
|
+
animations = /* @__PURE__ */ new Set();
|
|
534
|
+
constructor() {
|
|
535
|
+
const destroy = inject(DestroyRef);
|
|
536
|
+
const animate = () => {
|
|
537
|
+
let index = 0;
|
|
538
|
+
for (const child of Array.from(this.host.children)) {
|
|
539
|
+
if (this.seen.has(child)) continue;
|
|
540
|
+
this.seen.add(child);
|
|
541
|
+
if (!this.motion.enabled() || typeof child.animate !== "function") continue;
|
|
542
|
+
const animation = child.animate([{
|
|
543
|
+
opacity: 0,
|
|
544
|
+
transform: "translateY(8px)"
|
|
545
|
+
}, {
|
|
546
|
+
opacity: 1,
|
|
547
|
+
transform: "none"
|
|
548
|
+
}], {
|
|
549
|
+
duration: MOTION.quick.duration * 1e3,
|
|
550
|
+
delay: Math.min(300, index++ * Math.max(0, Math.min(80, this.hyStagger()))),
|
|
551
|
+
easing: MOTION.settle.css,
|
|
552
|
+
fill: "backwards",
|
|
553
|
+
composite: "add"
|
|
554
|
+
});
|
|
555
|
+
this.animations.add(animation);
|
|
556
|
+
animation.finished.then(() => this.animations.delete(animation), () => this.animations.delete(animation));
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
effect(() => {
|
|
560
|
+
if (!this.motion.enabled() || !this.visible()) {
|
|
561
|
+
this.animations.forEach((a) => a.cancel());
|
|
562
|
+
this.animations.clear();
|
|
563
|
+
}
|
|
564
|
+
if (this.visible()) animate();
|
|
565
|
+
});
|
|
566
|
+
afterNextRender(() => {
|
|
567
|
+
const observer = new MutationObserver(() => {
|
|
568
|
+
if (this.visible()) animate();
|
|
569
|
+
});
|
|
570
|
+
observer.observe(this.host, { childList: true });
|
|
571
|
+
destroy.onDestroy(() => observer.disconnect());
|
|
572
|
+
});
|
|
573
|
+
destroy.onDestroy(() => this.animations.forEach((a) => a.cancel()));
|
|
574
|
+
}
|
|
575
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
576
|
+
minVersion: "12.0.0",
|
|
577
|
+
version: "22.2.3",
|
|
578
|
+
ngImport: i0,
|
|
579
|
+
type: HyStagger,
|
|
580
|
+
deps: [],
|
|
581
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
582
|
+
});
|
|
583
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
584
|
+
minVersion: "17.1.0",
|
|
585
|
+
version: "22.2.3",
|
|
586
|
+
type: HyStagger,
|
|
587
|
+
isStandalone: true,
|
|
588
|
+
selector: "[hyStagger]",
|
|
589
|
+
inputs: { hyStagger: {
|
|
590
|
+
classPropertyName: "hyStagger",
|
|
591
|
+
publicName: "hyStagger",
|
|
592
|
+
isSignal: true,
|
|
593
|
+
isRequired: false,
|
|
594
|
+
transformFunction: null
|
|
595
|
+
} },
|
|
596
|
+
ngImport: i0
|
|
597
|
+
});
|
|
598
|
+
};
|
|
599
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
600
|
+
minVersion: "12.0.0",
|
|
601
|
+
version: "22.2.3",
|
|
602
|
+
ngImport: i0,
|
|
603
|
+
type: HyStagger,
|
|
604
|
+
decorators: [{
|
|
605
|
+
type: Directive,
|
|
606
|
+
args: [{ selector: "[hyStagger]" }]
|
|
607
|
+
}],
|
|
608
|
+
ctorParameters: () => [],
|
|
609
|
+
propDecorators: { hyStagger: [{
|
|
610
|
+
type: i0.Input,
|
|
611
|
+
args: [{
|
|
612
|
+
isSignal: true,
|
|
613
|
+
alias: "hyStagger",
|
|
614
|
+
required: false
|
|
615
|
+
}]
|
|
616
|
+
}] }
|
|
617
|
+
});
|
|
618
|
+
export { HyFlip, HyMotion, HySceneLight, HySceneLightDirective, HySpring, HyStagger, HyVelocityTracker, MOTION, SPRINGS, injectHyVisibility, project, rubberband };
|
|
619
|
+
|
|
620
|
+
//# sourceMappingURL=hyalo-angular-motion.mjs.map
|