@manufosela/card-rain-section 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 manufosela
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # @manufosela/card-rain-section
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@manufosela/card-rain-section)](https://www.npmjs.com/package/@manufosela/card-rain-section)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Scroll-driven card rain animation section web component built with [Lit 3](https://lit.dev/).
7
+
8
+ Cards fall (or zoom) into view as the user scrolls through the page. Supports two animation modes, mobile-friendly trigger animations, and respects `prefers-reduced-motion` for accessibility.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @manufosela/card-rain-section
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```javascript
19
+ import '@manufosela/card-rain-section';
20
+ ```
21
+
22
+ ```html
23
+ <card-rain-section scroll-height="300">
24
+ <span slot="title">Our<br>Services</span>
25
+
26
+ <div slot="card">
27
+ <h3>Design</h3>
28
+ <p>Beautiful interfaces that delight users.</p>
29
+ </div>
30
+
31
+ <div slot="card">
32
+ <h3>Development</h3>
33
+ <p>Modern web applications built for scale.</p>
34
+ </div>
35
+
36
+ <div slot="card">
37
+ <h3>Strategy</h3>
38
+ <p>Data-driven decisions for measurable results.</p>
39
+ </div>
40
+
41
+ <button slot="actions">Learn More</button>
42
+ </card-rain-section>
43
+ ```
44
+
45
+ ## Attributes
46
+
47
+ | Attribute | Type | Default | Description |
48
+ |-----------|------|---------|-------------|
49
+ | `scroll-height` | Number | `300` | Height of the scroll area in viewport units |
50
+ | `fall-mode` | String | `'drop'` | Animation mode: `"drop"` or `"zoom"` |
51
+ | `mobile-breakpoint` | Number | `768` | Viewport width threshold for mobile layout (px) |
52
+
53
+ ## Slots
54
+
55
+ | Slot | Description |
56
+ |------|-------------|
57
+ | `title` | Title content displayed behind the cards (parsed as innerHTML) |
58
+ | `card` | Card elements that animate into view (multiple allowed) |
59
+ | `actions` | Action buttons displayed at the bottom of the section |
60
+
61
+ ## CSS Custom Properties
62
+
63
+ | Property | Default | Description |
64
+ |----------|---------|-------------|
65
+ | `--crs-bg` | `#1a1618` | Background color of the canvas area |
66
+ | `--crs-card-bg` | `var(--accent-gold, #bfa15f)` | Card background color |
67
+ | `--crs-card-radius` | `16px` | Card border radius |
68
+ | `--crs-card-width` | `440px` | Card width |
69
+ | `--crs-card-padding` | `48px` | Card inner padding |
70
+ | `--crs-title-size` | `10rem` | Title font size |
71
+ | `--crs-title-color` | `rgba(255, 255, 255, 1)` | Title text color |
72
+
73
+ ## Animation Modes
74
+
75
+ ### Drop (default)
76
+
77
+ Cards fall from above the viewport and settle into place with slight rotations and offsets. Each card scales up slightly as it lands.
78
+
79
+ ```html
80
+ <card-rain-section fall-mode="drop">
81
+ ...
82
+ </card-rain-section>
83
+ ```
84
+
85
+ ### Zoom
86
+
87
+ Cards scale down from a large size with a blur-to-sharp transition effect, creating a dramatic zoom-in appearance.
88
+
89
+ ```html
90
+ <card-rain-section fall-mode="zoom">
91
+ ...
92
+ </card-rain-section>
93
+ ```
94
+
95
+ ## Custom Styles
96
+
97
+ ```html
98
+ <card-rain-section style="
99
+ --crs-bg: #0a192f;
100
+ --crs-card-bg: #112240;
101
+ --crs-card-radius: 4px;
102
+ --crs-title-color: rgba(100, 255, 218, 0.8);
103
+ --crs-title-size: 8rem;
104
+ ">
105
+ ...
106
+ </card-rain-section>
107
+ ```
108
+
109
+ ## Accessibility
110
+
111
+ - The component respects `prefers-reduced-motion: reduce` by disabling all animations and displaying cards in a static vertical layout.
112
+ - On mobile viewports, cards use a simpler trigger-based animation when they scroll into view.
113
+ - The scroller region has `role="region"` with an `aria-label` for assistive technologies.
114
+
115
+ ## License
116
+
117
+ MIT
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@manufosela/card-rain-section",
3
+ "version": "1.0.0",
4
+ "description": "Scroll-driven card rain animation section with drop and zoom modes",
5
+ "license": "MIT",
6
+ "author": "manufosela",
7
+ "type": "module",
8
+ "main": "./src/card-rain-section.js",
9
+ "module": "./src/card-rain-section.js",
10
+ "types": "./src/card-rain-section.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./src/card-rain-section.d.ts",
14
+ "import": "./src/card-rain-section.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "src"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/manufosela/ui-components",
23
+ "directory": "packages/card-rain-section"
24
+ },
25
+ "keywords": [
26
+ "web-components",
27
+ "lit",
28
+ "card-rain",
29
+ "scroll-animation",
30
+ "parallax"
31
+ ],
32
+ "homepage": "https://github.com/manufosela/ui-components/tree/main/packages/card-rain-section#readme",
33
+ "bugs": {
34
+ "url": "https://github.com/manufosela/ui-components/issues"
35
+ },
36
+ "dependencies": {
37
+ "lit": "^3.2.1"
38
+ },
39
+ "customElements": "custom-elements.json",
40
+ "scripts": {
41
+ "start": "web-dev-server --node-resolve --open demo/ --watch",
42
+ "test": "web-test-runner",
43
+ "test:watch": "web-test-runner --watch",
44
+ "test:coverage": "web-test-runner --coverage",
45
+ "build:types": "tsc --declaration --declarationMap --emitDeclarationOnly --allowJs --checkJs --outDir ./src ./src/card-rain-section.js"
46
+ }
47
+ }
@@ -0,0 +1,568 @@
1
+ import { LitElement, html, css } from 'lit';
2
+
3
+ const POSES = [
4
+ { x: -5, y: 0, rotate: -6 },
5
+ { x: 8, y: 2, rotate: 4 },
6
+ { x: -3, y: -1, rotate: -2 },
7
+ { x: 6, y: 3, rotate: 7 },
8
+ { x: -8, y: 1, rotate: -5 },
9
+ ];
10
+
11
+ /**
12
+ * Scroll-driven card rain animation section.
13
+ *
14
+ * Cards fall (or zoom) into view as the user scrolls through the page.
15
+ * Supports two animation modes: "drop" (cards fall from above) and "zoom"
16
+ * (cards scale down from a large size with a blur effect). The component
17
+ * adapts to mobile viewports with a simpler trigger-based animation and
18
+ * respects `prefers-reduced-motion` for accessibility.
19
+ *
20
+ * @element card-rain-section
21
+ *
22
+ * @attr {Number} scroll-height - Height of the scroll area in viewport units (default: 300)
23
+ * @attr {Number} mobile-breakpoint - Viewport width threshold for mobile layout in pixels (default: 768)
24
+ * @attr {String} fall-mode - Animation mode: "drop" or "zoom" (default: "drop")
25
+ *
26
+ * @cssprop [--crs-bg=#1a1618] - Background color of the canvas area
27
+ * @cssprop [--crs-card-bg=var(--accent-gold, #bfa15f)] - Card background color
28
+ * @cssprop [--crs-card-radius=16px] - Card border radius
29
+ * @cssprop [--crs-card-width=440px] - Card width
30
+ * @cssprop [--crs-card-padding=48px] - Card inner padding
31
+ * @cssprop [--crs-title-size=10rem] - Title font size
32
+ * @cssprop [--crs-title-color=rgba(255, 255, 255, 1)] - Title text color
33
+ *
34
+ * @slot title - Title content displayed behind the cards (parsed as innerHTML)
35
+ * @slot card - Card elements that animate into view (multiple allowed)
36
+ * @slot actions - Action buttons displayed at the bottom of the section
37
+ */
38
+ export class CardRainSection extends LitElement {
39
+ static properties = {
40
+ scrollHeight: { type: Number, attribute: 'scroll-height' },
41
+ mobileBreakpoint: { type: Number, attribute: 'mobile-breakpoint' },
42
+ fallMode: { type: String, attribute: 'fall-mode' },
43
+ _isMobile: { type: Boolean, state: true },
44
+ _reducedMotion: { type: Boolean, state: true },
45
+ _mobileTriggered: { type: Boolean, state: true },
46
+ _cardCount: { type: Number, state: true },
47
+ };
48
+
49
+ static styles = css`
50
+ :host {
51
+ display: block;
52
+ position: relative;
53
+ --crs-bg: #1a1618;
54
+ --crs-card-bg: var(--accent-gold, #bfa15f);
55
+ --crs-card-radius: 16px;
56
+ --crs-card-width: 440px;
57
+ --crs-card-padding: 48px;
58
+ --crs-title-size: 10rem;
59
+ --crs-title-color: rgba(255, 255, 255, 1);
60
+ }
61
+
62
+ .scroller {
63
+ position: relative;
64
+ }
65
+
66
+ .canvas {
67
+ position: sticky;
68
+ top: 0;
69
+ height: 100vh;
70
+ overflow: hidden;
71
+ background-color: var(--crs-bg);
72
+ display: flex;
73
+ align-items: center;
74
+ justify-content: center;
75
+ }
76
+
77
+ .title-text {
78
+ position: absolute;
79
+ font-size: var(--crs-title-size);
80
+ font-weight: 700;
81
+ color: var(--crs-title-color);
82
+ text-align: center;
83
+ z-index: 1;
84
+ pointer-events: none;
85
+ will-change: opacity;
86
+ line-height: 1.2;
87
+ }
88
+
89
+ .card {
90
+ position: absolute;
91
+ background-color: var(--crs-card-bg);
92
+ color: #fff;
93
+ padding: var(--crs-card-padding);
94
+ border-radius: var(--crs-card-radius);
95
+ width: var(--crs-card-width);
96
+ text-align: left;
97
+ box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
98
+ z-index: 2;
99
+ will-change: transform, opacity;
100
+ opacity: 0;
101
+ transform: translateY(-120vh);
102
+ }
103
+
104
+ .actions-layer {
105
+ position: absolute;
106
+ bottom: 100px;
107
+ left: 50%;
108
+ transform: translateX(-50%);
109
+ z-index: 10;
110
+ will-change: opacity;
111
+ opacity: 0;
112
+ }
113
+
114
+ /* Slotted content styles */
115
+ ::slotted([slot='title']) {
116
+ display: none !important;
117
+ }
118
+
119
+ .card ::slotted(*) {
120
+ color: #fff;
121
+ }
122
+
123
+ /* Mobile */
124
+ :host([data-mobile]) .scroller {
125
+ height: auto !important;
126
+ }
127
+
128
+ :host([data-mobile]) .canvas {
129
+ position: relative;
130
+ min-height: auto;
131
+ flex-direction: column;
132
+ padding: 80px 0 60px;
133
+ gap: 0;
134
+ }
135
+
136
+ :host([data-mobile]) .title-text {
137
+ position: relative;
138
+ font-size: 10vw;
139
+ margin-bottom: 40px;
140
+ }
141
+
142
+ :host([data-mobile]) .card {
143
+ position: relative;
144
+ width: 90%;
145
+ margin: 0 auto 20px;
146
+ opacity: 0;
147
+ transform: translateY(40px);
148
+ }
149
+
150
+ :host([data-mobile]) .actions-layer {
151
+ position: relative;
152
+ bottom: auto;
153
+ left: auto;
154
+ transform: none;
155
+ text-align: center;
156
+ margin-top: 40px;
157
+ opacity: 0;
158
+ }
159
+
160
+ /* Mobile triggered animations */
161
+ @keyframes cardDrop {
162
+ from {
163
+ opacity: 0;
164
+ transform: translateY(40px) rotate(var(--card-rotate, 0deg));
165
+ }
166
+ to {
167
+ opacity: 1;
168
+ transform: translateY(0) rotate(var(--card-rotate, 0deg));
169
+ }
170
+ }
171
+
172
+ @keyframes cardZoom {
173
+ from {
174
+ opacity: 0;
175
+ transform: scale(2.5) rotate(0deg);
176
+ }
177
+ to {
178
+ opacity: 1;
179
+ transform: scale(1) rotate(var(--card-rotate, 0deg));
180
+ }
181
+ }
182
+
183
+ @keyframes fadeInUp {
184
+ from {
185
+ opacity: 0;
186
+ transform: translateY(20px);
187
+ }
188
+ to {
189
+ opacity: 1;
190
+ transform: translateY(0);
191
+ }
192
+ }
193
+
194
+ :host([data-mobile][mobile-triggered]) .card {
195
+ animation-duration: 0.5s;
196
+ animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1);
197
+ animation-fill-mode: forwards;
198
+ }
199
+
200
+ :host([data-mobile][mobile-triggered]) .actions-layer {
201
+ animation: fadeInUp 0.4s ease-out forwards;
202
+ }
203
+
204
+ /* Reduced motion */
205
+ @media (prefers-reduced-motion: reduce) {
206
+ .scroller {
207
+ height: auto !important;
208
+ }
209
+
210
+ .canvas {
211
+ position: relative;
212
+ min-height: auto;
213
+ flex-direction: column;
214
+ padding: 80px 0 60px;
215
+ }
216
+
217
+ .title-text {
218
+ position: relative;
219
+ opacity: 0.3 !important;
220
+ margin-bottom: 40px;
221
+ }
222
+
223
+ .card {
224
+ position: relative !important;
225
+ width: 90% !important;
226
+ max-width: var(--crs-card-width);
227
+ margin: 0 auto 20px !important;
228
+ opacity: 1 !important;
229
+ transform: none !important;
230
+ box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4) !important;
231
+ }
232
+
233
+ .actions-layer {
234
+ position: relative !important;
235
+ bottom: auto !important;
236
+ left: auto !important;
237
+ transform: none !important;
238
+ text-align: center;
239
+ margin-top: 40px;
240
+ opacity: 1 !important;
241
+ }
242
+
243
+ :host([data-mobile][mobile-triggered]) .card,
244
+ :host([data-mobile][mobile-triggered]) .actions-layer {
245
+ animation: none !important;
246
+ }
247
+ }
248
+ `;
249
+
250
+ constructor() {
251
+ super();
252
+ this.scrollHeight = 300;
253
+ this.mobileBreakpoint = 768;
254
+ this.fallMode = 'drop';
255
+ this._isMobile = false;
256
+ this._reducedMotion = false;
257
+ this._mobileTriggered = false;
258
+ this._cardCount = 0;
259
+
260
+ this._currentProgress = 0;
261
+ this._targetProgress = 0;
262
+ this._rafId = null;
263
+ this._scrollHandler = null;
264
+ this._resizeHandler = null;
265
+ this._cardElements = [];
266
+ this._titleText = '';
267
+ }
268
+
269
+ connectedCallback() {
270
+ super.connectedCallback();
271
+ this._reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
272
+ this._checkMobile();
273
+
274
+ this._resizeHandler = this._onResize.bind(this);
275
+ window.addEventListener('resize', this._resizeHandler, { passive: true });
276
+ }
277
+
278
+ disconnectedCallback() {
279
+ super.disconnectedCallback();
280
+ this._cleanup();
281
+ if (this._resizeHandler) {
282
+ window.removeEventListener('resize', this._resizeHandler);
283
+ }
284
+ }
285
+
286
+ firstUpdated() {
287
+ this._processSlots();
288
+ this._setupAnimation();
289
+ }
290
+
291
+ _processSlots() {
292
+ const titleSlot = this.querySelector('[slot="title"]');
293
+ if (titleSlot) {
294
+ this._titleText = titleSlot.innerHTML;
295
+ }
296
+
297
+ const cards = this.querySelectorAll('[slot="card"]');
298
+ this._cardCount = cards.length;
299
+
300
+ cards.forEach((card, i) => {
301
+ card.setAttribute('slot', `card-${i}`);
302
+ });
303
+
304
+ this.requestUpdate();
305
+ }
306
+
307
+ _checkMobile() {
308
+ const wasMobile = this._isMobile;
309
+ this._isMobile = window.innerWidth <= this.mobileBreakpoint;
310
+
311
+ if (this._isMobile) {
312
+ this.setAttribute('data-mobile', '');
313
+ } else {
314
+ this.removeAttribute('data-mobile');
315
+ }
316
+
317
+ if (wasMobile !== this._isMobile && this.hasUpdated) {
318
+ this._cleanup();
319
+ this._mobileTriggered = false;
320
+ this.removeAttribute('mobile-triggered');
321
+ this._resetCardStyles();
322
+ this._setupAnimation();
323
+ }
324
+ }
325
+
326
+ _onResize() {
327
+ this._checkMobile();
328
+ }
329
+
330
+ _cleanup() {
331
+ if (this._rafId) {
332
+ cancelAnimationFrame(this._rafId);
333
+ this._rafId = null;
334
+ }
335
+ if (this._scrollHandler) {
336
+ window.removeEventListener('scroll', this._scrollHandler);
337
+ this._scrollHandler = null;
338
+ }
339
+ }
340
+
341
+ _resetCardStyles() {
342
+ const cards = this.shadowRoot.querySelectorAll('.card');
343
+ const title = this.shadowRoot.querySelector('.title-text');
344
+ const actions = this.shadowRoot.querySelector('.actions-layer');
345
+
346
+ cards.forEach((card) => {
347
+ card.style.cssText = '';
348
+ });
349
+ if (title) title.style.cssText = '';
350
+ if (actions) actions.style.cssText = '';
351
+ }
352
+
353
+ _setupAnimation() {
354
+ if (this._reducedMotion) return;
355
+
356
+ if (this._isMobile) {
357
+ this._setupMobileAnimation();
358
+ } else {
359
+ this._setupDesktopAnimation();
360
+ }
361
+ }
362
+
363
+ _setupDesktopAnimation() {
364
+ this._currentProgress = 0;
365
+ this._targetProgress = 0;
366
+ this._scrollHandler = this._onScroll.bind(this);
367
+ window.addEventListener('scroll', this._scrollHandler, { passive: true });
368
+ this._startRafLoop();
369
+ }
370
+
371
+ _setupMobileAnimation() {
372
+ const canvas = this.shadowRoot.querySelector('.canvas');
373
+ if (!canvas) return;
374
+
375
+ this._scrollHandler = () => {
376
+ if (this._mobileTriggered) return;
377
+ const rect = canvas.getBoundingClientRect();
378
+ const visible = rect.top < window.innerHeight * 0.85;
379
+
380
+ if (visible) {
381
+ this._mobileTriggered = true;
382
+ this.setAttribute('mobile-triggered', '');
383
+ this._applyMobileDelays();
384
+ window.removeEventListener('scroll', this._scrollHandler);
385
+ this._scrollHandler = null;
386
+ }
387
+ };
388
+
389
+ window.addEventListener('scroll', this._scrollHandler, { passive: true });
390
+ }
391
+
392
+ _applyMobileDelays() {
393
+ const animName = this.fallMode === 'zoom' ? 'cardZoom' : 'cardDrop';
394
+ const cards = this.shadowRoot.querySelectorAll('.card');
395
+ cards.forEach((card, i) => {
396
+ const pose = POSES[i % POSES.length];
397
+ card.style.setProperty('--card-rotate', `${pose.rotate}deg`);
398
+ card.style.animationName = animName;
399
+ card.style.animationDelay = `${i * 0.2}s`;
400
+ });
401
+
402
+ const actions = this.shadowRoot.querySelector('.actions-layer');
403
+ if (actions) {
404
+ actions.style.animationDelay = `${this._cardCount * 0.2 + 0.1}s`;
405
+ }
406
+ }
407
+
408
+ _onScroll() {
409
+ const scroller = this.shadowRoot.querySelector('.scroller');
410
+ if (!scroller) return;
411
+
412
+ const rect = scroller.getBoundingClientRect();
413
+ const scrollableHeight = scroller.offsetHeight - window.innerHeight;
414
+
415
+ if (scrollableHeight <= 0) {
416
+ this._targetProgress = 0;
417
+ return;
418
+ }
419
+
420
+ const scrolled = -rect.top;
421
+ this._targetProgress = Math.max(0, Math.min(1, scrolled / scrollableHeight));
422
+ }
423
+
424
+ _startRafLoop() {
425
+ const lerpFactor = 0.08;
426
+
427
+ const loop = () => {
428
+ this._currentProgress += (this._targetProgress - this._currentProgress) * lerpFactor;
429
+
430
+ if (Math.abs(this._currentProgress - this._targetProgress) < 0.0001) {
431
+ this._currentProgress = this._targetProgress;
432
+ }
433
+
434
+ this._applyDesktopTransforms(this._currentProgress);
435
+ this._rafId = requestAnimationFrame(loop);
436
+ };
437
+
438
+ this._rafId = requestAnimationFrame(loop);
439
+ }
440
+
441
+ _easeOutCubic(t) {
442
+ return 1 - Math.pow(1 - t, 3);
443
+ }
444
+
445
+ _getSubProgress(progress, start, end) {
446
+ if (progress <= start) return 0;
447
+ if (progress >= end) return 1;
448
+ return (progress - start) / (end - start);
449
+ }
450
+
451
+ _applyDesktopTransforms(progress) {
452
+ const title = this.shadowRoot.querySelector('.title-text');
453
+ const cards = this.shadowRoot.querySelectorAll('.card');
454
+ const actions = this.shadowRoot.querySelector('.actions-layer');
455
+ const count = cards.length;
456
+
457
+ if (!count) return;
458
+
459
+ // Title opacity: 1 -> 0.3
460
+ if (title) {
461
+ const titleOpacity = 1 - 0.7 * progress;
462
+ title.style.opacity = titleOpacity;
463
+ }
464
+
465
+ // Each card gets an equal slice of the progress range
466
+ cards.forEach((card, i) => {
467
+ const start = i / count;
468
+ const end = (i + 1) / count;
469
+ const sub = this._easeOutCubic(this._getSubProgress(progress, start, end));
470
+ const pose = POSES[i % POSES.length];
471
+
472
+ const result =
473
+ this.fallMode === 'zoom' ? this._calcZoomCard(sub, pose) : this._calcDropCard(sub, pose);
474
+
475
+ card.style.opacity = result.opacity;
476
+ card.style.transform = result.transform;
477
+ card.style.boxShadow = result.boxShadow;
478
+ card.style.filter = result.filter || '';
479
+ });
480
+
481
+ // Actions fade in when progress > 0.9
482
+ if (actions) {
483
+ const actionsSub = this._getSubProgress(progress, 0.9, 1);
484
+ actions.style.opacity = actionsSub;
485
+ }
486
+ }
487
+
488
+ _calcDropCard(sub, pose) {
489
+ const translateY = -120 * (1 - sub) + pose.y * sub;
490
+ const translateX = pose.x * sub;
491
+ const rotate = pose.rotate * sub;
492
+
493
+ const opacitySub = this._getSubProgress(sub, 0, 0.3);
494
+ const opacity = Math.min(1, opacitySub / 0.3);
495
+
496
+ const scale = 0.8 + 0.2 * sub;
497
+
498
+ const shadowBlur = 15 + 35 * sub;
499
+ const shadowY = 4 + 16 * sub;
500
+ const shadowAlpha = 0.1 + 0.3 * sub;
501
+
502
+ return {
503
+ opacity,
504
+ transform: `translate(${translateX}vw, ${translateY}vh) rotate(${rotate}deg) scale(${scale})`,
505
+ boxShadow: `0 ${shadowY}px ${shadowBlur}px rgba(0, 0, 0, ${shadowAlpha})`,
506
+ };
507
+ }
508
+
509
+ _calcZoomCard(sub, pose) {
510
+ const scale = 3.5 - 2.5 * sub;
511
+ const translateX = pose.x * sub;
512
+ const translateY = pose.y * sub;
513
+ const rotate = pose.rotate * sub;
514
+
515
+ const opacitySub = this._getSubProgress(sub, 0, 0.2);
516
+ const opacity = Math.min(1, opacitySub / 0.2);
517
+
518
+ const shadowBlur = 15 + 35 * sub;
519
+ const shadowY = 4 + 16 * sub;
520
+ const shadowAlpha = 0.1 + 0.3 * sub;
521
+
522
+ const blurSub = this._getSubProgress(sub, 0, 0.4);
523
+ const blur = 4 * (1 - Math.min(1, blurSub / 0.4));
524
+
525
+ return {
526
+ opacity,
527
+ transform: `translate(${translateX}vw, ${translateY}vh) rotate(${rotate}deg) scale(${scale})`,
528
+ boxShadow: `0 ${shadowY}px ${shadowBlur}px rgba(0, 0, 0, ${shadowAlpha})`,
529
+ filter: blur > 0.01 ? `blur(${blur}px)` : '',
530
+ };
531
+ }
532
+
533
+ render() {
534
+ const scrollerHeight =
535
+ this._reducedMotion || this._isMobile ? 'auto' : `${this.scrollHeight}vh`;
536
+
537
+ const cardTemplates = [];
538
+ for (let i = 0; i < this._cardCount; i++) {
539
+ cardTemplates.push(html`
540
+ <div class="card">
541
+ <slot name="card-${i}"></slot>
542
+ </div>
543
+ `);
544
+ }
545
+
546
+ return html`
547
+ <div
548
+ class="scroller"
549
+ style="height: ${scrollerHeight}"
550
+ role="region"
551
+ aria-label="Tarjetas animadas con scroll"
552
+ >
553
+ <div class="canvas">
554
+ <div class="title-text" .innerHTML="${this._titleText}"></div>
555
+ ${cardTemplates}
556
+ <div class="actions-layer">
557
+ <slot name="actions"></slot>
558
+ </div>
559
+ </div>
560
+ </div>
561
+
562
+ <!-- Hidden slot for title source -->
563
+ <slot name="title" style="display:none"></slot>
564
+ `;
565
+ }
566
+ }
567
+
568
+ customElements.define('card-rain-section', CardRainSection);