@italia/sticky 0.1.0-alpha.2 → 1.0.0-alpha.11
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 +1 -1
- package/custom-elements.json +219 -7
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/it-sticky.d.ts +18 -1
- package/dist/src/it-sticky.d.ts.map +1 -1
- package/dist/src/it-sticky.js +4 -1348
- package/dist/src/it-sticky.js.map +1 -1
- package/dist/src/sticky-controller.d.ts +86 -4
- package/dist/src/sticky-controller.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
package/custom-elements.json
CHANGED
|
@@ -14,6 +14,38 @@
|
|
|
14
14
|
"name": "ItSticky",
|
|
15
15
|
"module": "./it-sticky.js"
|
|
16
16
|
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"kind": "js",
|
|
20
|
+
"name": "StickyController",
|
|
21
|
+
"declaration": {
|
|
22
|
+
"name": "StickyController",
|
|
23
|
+
"module": "./sticky-controller.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"kind": "js",
|
|
28
|
+
"name": "StickyConfig",
|
|
29
|
+
"declaration": {
|
|
30
|
+
"name": "StickyConfig",
|
|
31
|
+
"module": "./sticky-controller.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"kind": "js",
|
|
36
|
+
"name": "StickyElement",
|
|
37
|
+
"declaration": {
|
|
38
|
+
"name": "StickyElement",
|
|
39
|
+
"module": "./sticky-controller.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"kind": "js",
|
|
44
|
+
"name": "StickyOptions",
|
|
45
|
+
"declaration": {
|
|
46
|
+
"name": "StickyOptions",
|
|
47
|
+
"module": "./sticky-controller.js"
|
|
48
|
+
}
|
|
17
49
|
}
|
|
18
50
|
]
|
|
19
51
|
},
|
|
@@ -65,9 +97,44 @@
|
|
|
65
97
|
"attribute": "stackable",
|
|
66
98
|
"reflects": true
|
|
67
99
|
},
|
|
100
|
+
{
|
|
101
|
+
"kind": "field",
|
|
102
|
+
"name": "triggerOffset",
|
|
103
|
+
"type": {
|
|
104
|
+
"text": "StickyOptions['triggerOffset'] | undefined"
|
|
105
|
+
},
|
|
106
|
+
"default": "0",
|
|
107
|
+
"description": "Extra pixels to scroll past the element's natural position before sticky activates.\nUseful when you want sticky to kick in only after a preceding element (e.g. a header) has scrolled away.",
|
|
108
|
+
"attribute": "trigger-offset",
|
|
109
|
+
"reflects": true
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"kind": "field",
|
|
113
|
+
"name": "triggerSelector",
|
|
114
|
+
"type": {
|
|
115
|
+
"text": "StickyOptions['triggerSelector'] | undefined"
|
|
116
|
+
},
|
|
117
|
+
"description": "CSS selector of an element whose height is used as the trigger offset.\nWhen provided, takes precedence over `trigger-offset`.",
|
|
118
|
+
"attribute": "trigger-selector",
|
|
119
|
+
"reflects": true
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"kind": "field",
|
|
123
|
+
"name": "position",
|
|
124
|
+
"type": {
|
|
125
|
+
"text": "'top' | 'bottom' | undefined"
|
|
126
|
+
},
|
|
127
|
+
"default": "'top'",
|
|
128
|
+
"description": "Which viewport edge to stick to. Use `'bottom'` together with `position-type=\"fixed\"` for a persistent bottom bar.",
|
|
129
|
+
"attribute": "position",
|
|
130
|
+
"reflects": true
|
|
131
|
+
},
|
|
68
132
|
{
|
|
69
133
|
"kind": "field",
|
|
70
134
|
"name": "_stickyController",
|
|
135
|
+
"type": {
|
|
136
|
+
"text": "StickyController"
|
|
137
|
+
},
|
|
71
138
|
"privacy": "public",
|
|
72
139
|
"default": "new StickyController(this, this)"
|
|
73
140
|
}
|
|
@@ -103,6 +170,32 @@
|
|
|
103
170
|
},
|
|
104
171
|
"default": "false",
|
|
105
172
|
"fieldName": "stackable"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"name": "trigger-offset",
|
|
176
|
+
"type": {
|
|
177
|
+
"text": "StickyOptions['triggerOffset'] | undefined"
|
|
178
|
+
},
|
|
179
|
+
"default": "0",
|
|
180
|
+
"description": "Extra pixels to scroll past the element's natural position before sticky activates.\nUseful when you want sticky to kick in only after a preceding element (e.g. a header) has scrolled away.",
|
|
181
|
+
"fieldName": "triggerOffset"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"name": "trigger-selector",
|
|
185
|
+
"type": {
|
|
186
|
+
"text": "StickyOptions['triggerSelector'] | undefined"
|
|
187
|
+
},
|
|
188
|
+
"description": "CSS selector of an element whose height is used as the trigger offset.\nWhen provided, takes precedence over `trigger-offset`.",
|
|
189
|
+
"fieldName": "triggerSelector"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "position",
|
|
193
|
+
"type": {
|
|
194
|
+
"text": "'top' | 'bottom' | undefined"
|
|
195
|
+
},
|
|
196
|
+
"default": "'top'",
|
|
197
|
+
"description": "Which viewport edge to stick to. Use `'bottom'` together with `position-type=\"fixed\"` for a persistent bottom bar.",
|
|
198
|
+
"fieldName": "position"
|
|
106
199
|
}
|
|
107
200
|
],
|
|
108
201
|
"superclass": {
|
|
@@ -150,6 +243,12 @@
|
|
|
150
243
|
"privacy": "public",
|
|
151
244
|
"default": "0"
|
|
152
245
|
},
|
|
246
|
+
{
|
|
247
|
+
"kind": "field",
|
|
248
|
+
"name": "windowUpdateHandler",
|
|
249
|
+
"privacy": "private",
|
|
250
|
+
"readonly": true
|
|
251
|
+
},
|
|
153
252
|
{
|
|
154
253
|
"kind": "method",
|
|
155
254
|
"name": "setVisualOrder",
|
|
@@ -208,6 +307,15 @@
|
|
|
208
307
|
"privacy": "private",
|
|
209
308
|
"default": "0"
|
|
210
309
|
},
|
|
310
|
+
{
|
|
311
|
+
"kind": "field",
|
|
312
|
+
"name": "reservedHeight",
|
|
313
|
+
"type": {
|
|
314
|
+
"text": "number"
|
|
315
|
+
},
|
|
316
|
+
"privacy": "private",
|
|
317
|
+
"default": "0"
|
|
318
|
+
},
|
|
211
319
|
{
|
|
212
320
|
"kind": "field",
|
|
213
321
|
"name": "hostElement",
|
|
@@ -242,6 +350,16 @@
|
|
|
242
350
|
},
|
|
243
351
|
"privacy": "private"
|
|
244
352
|
},
|
|
353
|
+
{
|
|
354
|
+
"kind": "field",
|
|
355
|
+
"name": "isBottom",
|
|
356
|
+
"type": {
|
|
357
|
+
"text": "boolean"
|
|
358
|
+
},
|
|
359
|
+
"privacy": "private",
|
|
360
|
+
"description": "Whether this controller is managing a bottom-edge element.",
|
|
361
|
+
"readonly": true
|
|
362
|
+
},
|
|
245
363
|
{
|
|
246
364
|
"kind": "method",
|
|
247
365
|
"name": "hostConnected"
|
|
@@ -259,6 +377,11 @@
|
|
|
259
377
|
"name": "computeLimit",
|
|
260
378
|
"privacy": "protected"
|
|
261
379
|
},
|
|
380
|
+
{
|
|
381
|
+
"kind": "method",
|
|
382
|
+
"name": "measureHeight",
|
|
383
|
+
"privacy": "protected"
|
|
384
|
+
},
|
|
262
385
|
{
|
|
263
386
|
"kind": "method",
|
|
264
387
|
"name": "isBeforeInDOM",
|
|
@@ -285,13 +408,22 @@
|
|
|
285
408
|
},
|
|
286
409
|
{
|
|
287
410
|
"kind": "method",
|
|
288
|
-
"name": "
|
|
289
|
-
"privacy": "
|
|
411
|
+
"name": "walkElements",
|
|
412
|
+
"privacy": "private",
|
|
290
413
|
"return": {
|
|
291
414
|
"type": {
|
|
292
|
-
"text": "
|
|
415
|
+
"text": "StickyElement[]"
|
|
293
416
|
}
|
|
294
|
-
}
|
|
417
|
+
},
|
|
418
|
+
"parameters": [
|
|
419
|
+
{
|
|
420
|
+
"name": "predicate",
|
|
421
|
+
"type": {
|
|
422
|
+
"text": "(el: HTMLElement) => boolean"
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
],
|
|
426
|
+
"description": "Walks the DOM from `document.body` using a TreeWalker and collects every\nelement for which `predicate` returns true.\n\nCompared to `querySelectorAll` this avoids allocating a static NodeList,\nallows arbitrary JS predicates (not just CSS selectors), and is the\nidiomatic API for programmatic DOM traversal."
|
|
295
427
|
},
|
|
296
428
|
{
|
|
297
429
|
"kind": "method",
|
|
@@ -307,12 +439,53 @@
|
|
|
307
439
|
"kind": "method",
|
|
308
440
|
"name": "computeOffset",
|
|
309
441
|
"privacy": "protected",
|
|
442
|
+
"return": {
|
|
443
|
+
"type": {
|
|
444
|
+
"text": "number"
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
"description": "Computes the top offset for top-edge stackable stickies.\n\nVisual order: active fixed-top first (activation order), then\nnon-fixed in DOM order. Returns the cumulative height of all elements\nwith a lower visual order than this one."
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
"kind": "method",
|
|
451
|
+
"name": "getExtraTriggerOffset",
|
|
452
|
+
"privacy": "protected",
|
|
310
453
|
"return": {
|
|
311
454
|
"type": {
|
|
312
455
|
"text": "number"
|
|
313
456
|
}
|
|
314
457
|
}
|
|
315
458
|
},
|
|
459
|
+
{
|
|
460
|
+
"kind": "method",
|
|
461
|
+
"name": "getFixedContainingBlockFor",
|
|
462
|
+
"privacy": "private",
|
|
463
|
+
"return": {
|
|
464
|
+
"type": {
|
|
465
|
+
"text": "Element | null"
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
"parameters": [
|
|
469
|
+
{
|
|
470
|
+
"name": "el",
|
|
471
|
+
"type": {
|
|
472
|
+
"text": "Element"
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
],
|
|
476
|
+
"description": "Returns the nearest ancestor element that creates a CSS fixed-position\ncontaining block (i.e. has a non-none `transform`, `filter`, or\n`perspective`), or `null` when the viewport is the containing block.\n\nTwo bottom-fixed elements that share the same containing block should\nstack against each other; elements in different containing blocks\n(e.g. separate Storybook story previews) are fully independent."
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"kind": "method",
|
|
480
|
+
"name": "computeBottomOffset",
|
|
481
|
+
"privacy": "protected",
|
|
482
|
+
"return": {
|
|
483
|
+
"type": {
|
|
484
|
+
"text": "number"
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
"description": "Computes the bottom offset for bottom-edge stackable stickies.\n\nOnly elements that share the same CSS fixed containing block are counted —\nthis prevents elements in separate story previews (or any transformed\ncontainers) from stacking against each other."
|
|
488
|
+
},
|
|
316
489
|
{
|
|
317
490
|
"kind": "method",
|
|
318
491
|
"name": "getClasses",
|
|
@@ -356,8 +529,15 @@
|
|
|
356
529
|
},
|
|
357
530
|
{
|
|
358
531
|
"kind": "method",
|
|
359
|
-
"name": "
|
|
360
|
-
"privacy": "private"
|
|
532
|
+
"name": "updateAllActiveFixedTopPositions",
|
|
533
|
+
"privacy": "private",
|
|
534
|
+
"description": "Restacks all active top-fixed stickies from the top of their respective\ncontaining block downward.\n\nSymmetric with `updateAllActiveFixedBottomPositions`: elements grouped by\nCSS containing block so that stickies in separate containers (e.g. different\nStorybook previews) each start at `top: 0` independently."
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
"kind": "method",
|
|
538
|
+
"name": "updateAllActiveFixedBottomPositions",
|
|
539
|
+
"privacy": "private",
|
|
540
|
+
"description": "Restacks all active bottom-fixed stickies from the bottom of their\nrespective containing block upward.\n\nElements are grouped by their CSS fixed containing block so that\nstickies in separate containers (e.g. different Storybook previews)\neach start at `bottom: 0` and don't affect one another."
|
|
361
541
|
}
|
|
362
542
|
]
|
|
363
543
|
}
|
|
@@ -432,6 +612,14 @@
|
|
|
432
612
|
"text": "StoryObj"
|
|
433
613
|
},
|
|
434
614
|
"default": "{ parameters: { heading: 'Sticky impilabili con resize', description: ` Questo esempio mostra più componenti it-sticky con attributo stackable e la gestione dei resize del suo contenitore (ie media query). Utilizza il selettore per modificare la larghezza del contenitore: al variare della dimensione, gli elementi interni cambiano altezza grazie alle container query e rimangono comunque correttamente impilati uno sopra l’altro durante lo scroll. `, }, render: () => html` <div id=\"wrapper\" style=\"container-type: inline-size; height:100%; transition: width 0.3s; padding:1rem;\"> <div style=\"padding: 1rem;\"> CSS per il ridimensionamento del contenuto: <pre style=\"background: #333; color: #eee; padding: 1rem; border-radius: 8px; overflow-x: auto;\"> .resizable-content { height: 40px; transition: height 0.3s; } /* Container queries */ @container (max-width: 1200px) { .resizable-content { height: 40px; } } @container (max-width: 1000px) { .resizable-content { height: 60px; } } @container (max-width: 800px) { .resizable-content { height: 80px; } } @container (max-width: 500px) { .resizable-content { height: 100px; } } </pre > </div> <it-sticky stackable sticky-class-name=\"l-0\" class=\"mb-4 p-2 bg-light border\" padding-top=\"16\" position-type=\"fixed\" > <label for=\"size\">Seleziona la larghezza del contenuto:</label> <select id=\"size\" name=\"size\" @change=${(e: Event) => { const target = e.target as HTMLSelectElement; // trova la .container definita nel decorator (il blocco grigio) const outerContainer = document.querySelector('.container') as HTMLElement | null; if (outerContainer) { outerContainer.style.width = `${target.value}px`; // forza reflow per render immediato delle container query outerContainer.getBoundingClientRect(); } else { // fallback: imposta il wrapper locale const wrapper = document.getElementById('wrapper') as HTMLDivElement | null; if (wrapper) { wrapper.style.width = `${target.value}px`; wrapper.getBoundingClientRect(); } } }} > <option value=\"1200\">1200px</option> <option value=\"1000\">1000px</option> <option value=\"800\">800px</option> <option value=\"600\">600px</option> <option value=\"400\">400px</option> </select> </it-sticky> <it-sticky class=\"bg-primary p-2 text-white w-100\" stackable> <div class=\"resizable-content\">Sticky Stackable 1</div> </it-sticky> <div style=\"height: 500px;\"></div> <it-sticky class=\"bg-success p-2 text-white w-100\" stackable> <div class=\"resizable-content\">Sticky Stackable 2</div> </it-sticky> <div style=\"height: 500px;\"></div> <it-sticky class=\"bg-warning p-2 text-white w-100\" stackable position-type=\"fixed\" sticky-class-name=\"l-0\"> <div class=\"resizable-content\">Another Stackable Sticky 3</div> </it-sticky> <it-sticky class=\"bg-danger p-2 text-white w-100\" stackable padding-top=\"50\"> <div class=\"resizable-content\">Sticky Stackable padded 1</div> </it-sticky> <div style=\"height: 500px;\"></div> <it-sticky class=\"bg-dark p-2 text-white w-100\" stackable padding-top=\"100\"> <div class=\"resizable-content\">Sticky Stackable padded 3</div> </it-sticky> <div style=\"height: 500px;\"></div> <style> .resizable-content { height: 40px; transition: height 0.3s; } /* Container queries */ @container (max-width: 1200px) { .resizable-content { height: 40px; } } @container (max-width: 1000px) { .resizable-content { height: 60px; } } @container (max-width: 800px) { .resizable-content { height: 80px; } } @container (max-width: 500px) { .resizable-content { height: 100px; } } </style> </div> `, }"
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
"kind": "variable",
|
|
618
|
+
"name": "FixedBottomSticky",
|
|
619
|
+
"type": {
|
|
620
|
+
"text": "StoryObj"
|
|
621
|
+
},
|
|
622
|
+
"default": "{ parameters: { heading: 'Esempio it-sticky: position bottom fixed', description: \"La barra in fondo è fissa dal caricamento della pagina — nessuno scroll necessario. Aggiungendo l'attributo stackable è possibile impilarne più d'una verso l'alto.\", }, render: () => html` <div style=\"height: 400px; display: flex; align-items: center; justify-content: center;\"> <p style=\"text-align:center; color:#666;\"> La barra è agganciata al bordo inferiore del viewport.<br /> Prova a ridimensionare la finestra del browser. </p> </div> <it-sticky position=\"bottom\" position-type=\"fixed\" stackable class=\"bg-primary text-white p-3 w-100\"> <div class=\"w-100 text-center\">Barra fissa in fondo — primo livello</div> </it-sticky> <it-sticky position=\"bottom\" position-type=\"fixed\" stackable class=\"bg-success text-white p-2 w-100\"> <div class=\"w-100 text-center\">Barra fissa in fondo — secondo livello (impilata)</div> </it-sticky> `, }"
|
|
435
623
|
}
|
|
436
624
|
],
|
|
437
625
|
"exports": [
|
|
@@ -490,6 +678,14 @@
|
|
|
490
678
|
"name": "StackableStickyResize",
|
|
491
679
|
"module": "stories/it-sticky-examples.stories.ts"
|
|
492
680
|
}
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
"kind": "js",
|
|
684
|
+
"name": "FixedBottomSticky",
|
|
685
|
+
"declaration": {
|
|
686
|
+
"name": "FixedBottomSticky",
|
|
687
|
+
"module": "stories/it-sticky-examples.stories.ts"
|
|
688
|
+
}
|
|
493
689
|
}
|
|
494
690
|
]
|
|
495
691
|
},
|
|
@@ -503,7 +699,7 @@
|
|
|
503
699
|
"type": {
|
|
504
700
|
"text": "Meta"
|
|
505
701
|
},
|
|
506
|
-
"default": "{ title: 'Componenti/Sticky', component: 'it-sticky', tags: ['autodocs'], args: { stackable: false, paddingTop: 0, stickyClassName: undefined, positionType: undefined, }, parameters: { docs: { description: { component: `<Description>Rende un elemento della pagina costantemente visibile allo scorrere della pagina.</Description> Talvolta è necessario che uno o più elementi della pagina restino sempre visibili anche quando essa viene fatta scorrere. Questo comportamento viene comunemente definito “sticky”. <br> Il componente <code><it-sticky></code> consente di mantenere visibile un elemento della pagina durante lo scroll, applicando automaticamente il comportamento “sticky”. <br> Per utilizzarlo, basta racchiudere il contenuto da fissare all’interno del tag <code><it-sticky></code>. Il componente gestisce in autonomia anche casi avanzati, come elementi impilabili o con padding e classi personalizzate, attraverso specifiche proprietà. <br> È disponibile una <a href=\"iframe.html?globals=&id=esempi-sticky--single-sticky&viewMode=story\" target=\"_blank\" rel=\"noopener\"> pagina di esempio </a> dedicata a questa funzionalità per comprenderne appieno significato ed utilizzo. `, }, }, }, argTypes: { stackable: { control: 'boolean', description: \"Attiva/disattiva la possibilità di rendere l'elemento impilabile su altri elementi sticky presenti in pagina\", table: { defaultValue: { summary: false } }, }, paddingTop: { control: 'number', description: \"Indica la distanza dall'elemento in sticky dal margine superiore\", table: { defaultValue: { summary: 0 } }, }, stickyClassName: { control: 'text', description: \"Classi CSS da applicare all'elemento quando viene attivata la funzionalità sticky\", table: { defaultValue: { summary: '' } }, }, positionType: { control: { type: 'select' }, options: ['sticky', 'fixed'], description: 'Indica il valore della proprietà CSS `position`. I valori ammessi sono `sticky` o `fixed`', table: { defaultValue: { summary: 'sticky' } }, }, }, render: (args) => renderSticky(args), }"
|
|
702
|
+
"default": "{ title: 'Componenti/Sticky', component: 'it-sticky', tags: ['autodocs', 'a11y-ok', 'web-component'], args: { stackable: false, paddingTop: 0, stickyClassName: undefined, positionType: undefined, triggerOffset: undefined, triggerSelector: undefined, position: undefined, }, parameters: { docs: { description: { component: `<Description>Rende un elemento della pagina costantemente visibile allo scorrere della pagina.</Description> Talvolta è necessario che uno o più elementi della pagina restino sempre visibili anche quando essa viene fatta scorrere. Questo comportamento viene comunemente definito “sticky”. <br> Il componente <code><it-sticky></code> consente di mantenere visibile un elemento della pagina durante lo scroll, applicando automaticamente il comportamento “sticky”. <br> Per utilizzarlo, basta racchiudere il contenuto da fissare all’interno del tag <code><it-sticky></code>. Il componente gestisce in autonomia anche casi avanzati, come elementi impilabili o con padding e classi personalizzate, attraverso specifiche proprietà. <br> È disponibile una <a href=\"iframe.html?globals=&id=esempi-sticky--single-sticky&viewMode=story\" target=\"_blank\" rel=\"noopener\"> pagina di esempio </a> dedicata a questa funzionalità per comprenderne appieno significato ed utilizzo. `, }, }, }, argTypes: { stackable: { control: 'boolean', description: \"Attiva/disattiva la possibilità di rendere l'elemento impilabile su altri elementi sticky presenti in pagina\", table: { defaultValue: { summary: false } }, }, paddingTop: { name: 'padding-top', control: 'number', description: \"Indica la distanza dall'elemento in sticky dal margine superiore\", table: { defaultValue: { summary: 0 } }, }, stickyClassName: { name: 'sticky-class-name', control: 'text', description: \"Classi CSS da applicare all'elemento quando viene attivata la funzionalità sticky\", table: { defaultValue: { summary: '' } }, }, positionType: { name: 'position-type', control: { type: 'select' }, options: ['sticky', 'fixed'], description: 'Indica il valore della proprietà CSS `position`. I valori ammessi sono `sticky` o `fixed`', table: { defaultValue: { summary: 'sticky' } }, }, triggerOffset: { name: 'trigger-offset', control: 'number', description: \"Definisce un offset in pixel tra l'elemento e il margine superiore per ritardare l'attivazione dello sticky\", table: { defaultValue: { summary: undefined } }, }, triggerSelector: { name: 'trigger-selector', control: 'text', description: 'Selettore CSS di un elemento della pagina da usare come soglia di attivazione dello sticky', table: { defaultValue: { summary: undefined } }, }, position: { control: { type: 'select' }, options: ['top', 'bottom'], description: \"Indica il bordo del viewport a cui agganciare l'elemento. Usa `'bottom'` con `position-type=\\\"fixed\\\"` per una barra persistente in fondo alla pagina.\", table: { defaultValue: { summary: 'top' } }, }, }, render: (args) => renderSticky(args), }"
|
|
507
703
|
},
|
|
508
704
|
{
|
|
509
705
|
"kind": "variable",
|
|
@@ -552,6 +748,14 @@
|
|
|
552
748
|
"text": "Story"
|
|
553
749
|
},
|
|
554
750
|
"default": "{ name: 'Eventi Custom', parameters: { viewMode: 'docs', docs: { canvas: { hidden: true, sourceState: 'none' }, description: { story: ` Il componente <code>it-sticky</code> emette eventi custom per notificare quando un elemento diventa sticky o smette di esserlo: - <strong>it-sticky-on</strong>: Emesso quando l'elemento diventa sticky - <strong>it-sticky-off</strong>: Emesso quando l'elemento smette di essere sticky ##### Proprietà degli eventi: Entrambi gli eventi hanno le seguenti proprietà: - <code>bubbles: true</code> - L'evento si propaga attraverso il DOM - <code>composed: true</code> - L'evento attraversa i confini del Shadow DOM - <code>cancelable: true</code> - L'evento può essere cancellato - <code>detail: { id: string }</code> - Contiene l'ID dell'elemento sticky ##### Esempio di utilizzo: \\`\\`\\`javascript const stickyElement = document.querySelector('it-sticky'); // Ascolta quando diventa sticky stickyElement.addEventListener('it-sticky-on', (event) => { console.log('Elemento diventato sticky:', event.detail.id); // Aggiungi logica personalizzata }); // Ascolta quando smette di essere sticky stickyElement.addEventListener('it-sticky-off', (event) => { console.log('Elemento non più sticky:', event.detail.id); // Aggiungi logica personalizzata }); \\`\\`\\` \\`\\`\\` `, }, }, }, }"
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
"kind": "variable",
|
|
754
|
+
"name": "FixedBottom",
|
|
755
|
+
"type": {
|
|
756
|
+
"text": "Story"
|
|
757
|
+
},
|
|
758
|
+
"default": "{ name: 'Position fixed bottom', parameters: { docs: { description: { story: ` Usando <code>position=\"bottom\"</code> insieme a <code>position-type=\"fixed\"</code> l'elemento viene agganciato al bordo inferiore del viewport immediatamente al caricamento — senza attendere lo scroll. Questo è il comportamento usato internamente da <code>it-bottom-nav</code>. <br> È disponibile una <a href=\"iframe.html?globals=&id=esempi-sticky--fixed-bottom-sticky&viewMode=story\" target=\"_blank\" rel=\"noopener\"> pagina di esempio </a> dedicata a questa funzionalità. `, }, source: { code: `<it-sticky position=\"bottom\" position-type=\"fixed\">\\n <div class=\"bg-primary text-white p-3\">Barra fissa in fondo</div>\\n</it-sticky>`, }, }, }, }"
|
|
555
759
|
}
|
|
556
760
|
],
|
|
557
761
|
"exports": [
|
|
@@ -610,6 +814,14 @@
|
|
|
610
814
|
"name": "CustomEvents",
|
|
611
815
|
"module": "stories/it-sticky.stories.ts"
|
|
612
816
|
}
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
"kind": "js",
|
|
820
|
+
"name": "FixedBottom",
|
|
821
|
+
"declaration": {
|
|
822
|
+
"name": "FixedBottom",
|
|
823
|
+
"module": "stories/it-sticky.stories.ts"
|
|
824
|
+
}
|
|
613
825
|
}
|
|
614
826
|
]
|
|
615
827
|
}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/src/index.js
CHANGED
package/dist/src/it-sticky.d.ts
CHANGED
|
@@ -5,8 +5,25 @@ export declare class ItSticky extends BaseComponent {
|
|
|
5
5
|
stickyClassName?: StickyOptions['stickyClassName'];
|
|
6
6
|
positionType?: StickyOptions['positionType'];
|
|
7
7
|
stackable?: StickyOptions['stackable'];
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Extra pixels to scroll past the element's natural position before sticky activates.
|
|
10
|
+
* Useful when you want sticky to kick in only after a preceding element (e.g. a header) has scrolled away.
|
|
11
|
+
*/
|
|
12
|
+
triggerOffset?: StickyOptions['triggerOffset'];
|
|
13
|
+
/**
|
|
14
|
+
* CSS selector of an element whose height is used as the trigger offset.
|
|
15
|
+
* When provided, takes precedence over `trigger-offset`.
|
|
16
|
+
*/
|
|
17
|
+
triggerSelector?: StickyOptions['triggerSelector'];
|
|
18
|
+
/** Which viewport edge to stick to. Use `'bottom'` together with `position-type="fixed"` for a persistent bottom bar. */
|
|
19
|
+
position?: 'top' | 'bottom';
|
|
20
|
+
_stickyController: StickyController;
|
|
9
21
|
protected updated(): void;
|
|
10
22
|
createRenderRoot(): this;
|
|
11
23
|
}
|
|
24
|
+
declare global {
|
|
25
|
+
interface HTMLElementTagNameMap {
|
|
26
|
+
'it-sticky': ItSticky;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
12
29
|
//# sourceMappingURL=it-sticky.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"it-sticky.d.ts","sourceRoot":"","sources":["../../src/it-sticky.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEzE,
|
|
1
|
+
{"version":3,"file":"it-sticky.d.ts","sourceRoot":"","sources":["../../src/it-sticky.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEzE,qBAAa,QAAS,SAAQ,aAAa;IACc,UAAU,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAK;IAEvC,eAAe,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAEvD,YAAY,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAY;IAErE,SAAS,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAS;IAE3F;;;OAGG;IAEH,aAAa,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,CAAK;IAEnD;;;OAGG;IACyD,eAAe,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAE/G,yHAAyH;IAC5F,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAS;IAE1D,iBAAiB,EAAE,gBAAgB,CAAoC;cAE3D,OAAO,IAAI,IAAI;IAclC,gBAAgB;CAGjB;AAMD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
|