@evermade/overflow-slider 3.3.1 → 4.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/.nvmrc +1 -1
- package/README.md +158 -33
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +645 -1
- package/dist/index.esm.js.map +1 -0
- package/dist/index.min.js +2 -1
- package/dist/index.min.js.map +1 -0
- package/dist/mixins.scss +14 -0
- package/dist/overflow-slider.css +1 -1
- package/dist/plugins/arrows/index.d.ts +26 -0
- package/dist/plugins/arrows/index.min.js +1 -1
- package/dist/plugins/autoplay/index.d.ts +41 -0
- package/dist/plugins/autoplay/index.esm.js +233 -0
- package/dist/plugins/autoplay/index.min.js +1 -0
- package/dist/plugins/classnames/index.d.ts +14 -0
- package/dist/plugins/classnames/index.esm.js +108 -0
- package/dist/plugins/classnames/index.min.js +1 -0
- package/dist/plugins/core/index.d.ts +76 -0
- package/dist/plugins/core/index.d2.ts +23 -0
- package/dist/plugins/dots/index.d.ts +16 -0
- package/dist/plugins/dots/index.min.js +1 -1
- package/dist/plugins/drag-scrolling/index.d.ts +9 -0
- package/dist/plugins/drag-scrolling/index.esm.js +2 -2
- package/dist/plugins/drag-scrolling/index.min.js +1 -1
- package/dist/plugins/fade/index.d.ts +16 -0
- package/dist/plugins/fade/index.min.js +1 -1
- package/dist/plugins/full-width/index.d.ts +11 -0
- package/dist/plugins/full-width/index.esm.js +37 -9
- package/dist/plugins/full-width/index.min.js +1 -1
- package/dist/plugins/infinite-scroll/index.d.ts +25 -0
- package/dist/plugins/infinite-scroll/index.esm.js +75 -0
- package/dist/plugins/infinite-scroll/index.min.js +1 -0
- package/dist/plugins/scroll-indicator/index.d.ts +14 -0
- package/dist/plugins/scroll-indicator/index.esm.js +3 -1
- package/dist/plugins/scroll-indicator/index.min.js +1 -1
- package/dist/plugins/skip-links/index.d.ts +17 -0
- package/dist/plugins/skip-links/index.esm.js +7 -1
- package/dist/plugins/skip-links/index.min.js +1 -1
- package/dist/plugins/thumbnails/index.d.ts +9 -0
- package/dist/plugins/thumbnails/index.min.js +1 -1
- package/dist/{core/utils.min.js → utils-Sxwcz8zp.js} +1 -1
- package/dist/{core/utils.esm.js → utils-ayDxlweP.js} +1 -1
- package/docs/assets/demo.css +156 -0
- package/docs/assets/demo.js +92 -8
- package/docs/dist/index.d.ts +1 -0
- package/docs/dist/index.esm.js +645 -1
- package/docs/dist/index.esm.js.map +1 -0
- package/docs/dist/index.min.js +2 -1
- package/docs/dist/index.min.js.map +1 -0
- package/docs/dist/mixins.scss +14 -0
- package/docs/dist/overflow-slider.css +1 -1
- package/docs/dist/plugins/arrows/index.d.ts +26 -0
- package/docs/dist/plugins/arrows/index.min.js +1 -1
- package/docs/dist/plugins/autoplay/index.d.ts +41 -0
- package/docs/dist/plugins/autoplay/index.esm.js +233 -0
- package/docs/dist/plugins/autoplay/index.min.js +1 -0
- package/docs/dist/plugins/classnames/index.d.ts +14 -0
- package/docs/dist/plugins/classnames/index.esm.js +108 -0
- package/docs/dist/plugins/classnames/index.min.js +1 -0
- package/docs/dist/plugins/core/index.d.ts +76 -0
- package/docs/dist/plugins/core/index.d2.ts +23 -0
- package/docs/dist/plugins/dots/index.d.ts +16 -0
- package/docs/dist/plugins/dots/index.min.js +1 -1
- package/docs/dist/plugins/drag-scrolling/index.d.ts +9 -0
- package/docs/dist/plugins/drag-scrolling/index.esm.js +2 -2
- package/docs/dist/plugins/drag-scrolling/index.min.js +1 -1
- package/docs/dist/plugins/fade/index.d.ts +16 -0
- package/docs/dist/plugins/fade/index.min.js +1 -1
- package/docs/dist/plugins/full-width/index.d.ts +11 -0
- package/docs/dist/plugins/full-width/index.esm.js +37 -9
- package/docs/dist/plugins/full-width/index.min.js +1 -1
- package/docs/dist/plugins/infinite-scroll/index.d.ts +25 -0
- package/docs/dist/plugins/infinite-scroll/index.esm.js +75 -0
- package/docs/dist/plugins/infinite-scroll/index.min.js +1 -0
- package/docs/dist/plugins/scroll-indicator/index.d.ts +14 -0
- package/docs/dist/plugins/scroll-indicator/index.esm.js +3 -1
- package/docs/dist/plugins/scroll-indicator/index.min.js +1 -1
- package/docs/dist/plugins/skip-links/index.d.ts +17 -0
- package/docs/dist/plugins/skip-links/index.esm.js +7 -1
- package/docs/dist/plugins/skip-links/index.min.js +1 -1
- package/docs/dist/plugins/thumbnails/index.d.ts +9 -0
- package/docs/dist/plugins/thumbnails/index.min.js +1 -1
- package/docs/dist/{core/utils.min.js → utils-Sxwcz8zp.js} +1 -1
- package/docs/dist/{core/utils.esm.js → utils-ayDxlweP.js} +1 -1
- package/docs/index-rtl.html +78 -2
- package/docs/index.html +86 -1
- package/package.json +50 -27
- package/rollup.config.js +90 -66
- package/src/core/details.ts +4 -0
- package/src/core/overflow-slider.ts +4 -2
- package/src/core/slider.ts +127 -62
- package/src/core/types.ts +30 -1
- package/src/mixins.scss +14 -0
- package/src/overflow-slider.scss +12 -10
- package/src/plugins/arrows/index.ts +2 -2
- package/src/plugins/autoplay/index.ts +276 -0
- package/src/plugins/autoplay/styles.scss +11 -0
- package/src/plugins/classnames/index.ts +147 -0
- package/src/plugins/dots/index.ts +2 -2
- package/src/plugins/drag-scrolling/index.ts +4 -4
- package/src/plugins/fade/index.ts +2 -2
- package/src/plugins/full-width/index.ts +43 -11
- package/src/plugins/scroll-indicator/index.ts +5 -3
- package/src/plugins/skip-links/index.ts +2 -2
- package/src/plugins/thumbnails/index.ts +2 -2
- package/tsconfig.json +4 -2
- package/changelog.md +0 -5
- package/dist/core/details.esm.js +0 -35
- package/dist/core/details.min.js +0 -1
- package/dist/core/overflow-slider.esm.js +0 -29
- package/dist/core/overflow-slider.min.js +0 -1
- package/dist/core/slider.esm.js +0 -499
- package/dist/core/slider.min.js +0 -1
- package/docs/dist/core/details.esm.js +0 -35
- package/docs/dist/core/details.min.js +0 -1
- package/docs/dist/core/overflow-slider.esm.js +0 -29
- package/docs/dist/core/overflow-slider.min.js +0 -1
- package/docs/dist/core/slider.esm.js +0 -499
- package/docs/dist/core/slider.min.js +0 -1
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
v20
|
package/README.md
CHANGED
|
@@ -95,57 +95,95 @@ const slider = new OverflowSlider(
|
|
|
95
95
|
You can import base styles from the library to get started. The base styles include basic styles for the slider and some plugins.
|
|
96
96
|
|
|
97
97
|
```scss
|
|
98
|
-
@
|
|
98
|
+
@use "@evermade/overflow-slider/style.css";
|
|
99
99
|
```
|
|
100
100
|
|
|
101
101
|
You can use the CSS variables to override some values easily.
|
|
102
102
|
|
|
103
103
|
Note that you can easily write styles from scratch if you want to. See source code from `src/overflow-slider.scss` for reference.
|
|
104
104
|
|
|
105
|
-
##
|
|
106
|
-
|
|
107
|
-
You control slides per view in CSS. Set gap between slides via `gap` to slider. Slide layout/size is controlled by `width` property. You can use others but `width` is the most stable.
|
|
105
|
+
## Mixins
|
|
108
106
|
|
|
109
|
-
|
|
107
|
+
If you are using SCSS, you can use these helpers.
|
|
110
108
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
```scss
|
|
110
|
+
@use "@evermade/overflow-slider/mixins";
|
|
111
|
+
```
|
|
114
112
|
|
|
115
|
-
|
|
113
|
+
### slide-width
|
|
116
114
|
|
|
117
|
-
|
|
115
|
+
```scss
|
|
116
|
+
@mixin os-slide-width($slidesPerView: 3, $gap: var(--slide-gap, 1rem), $containerWidth: var(--slider-container-width, 90vw)) {
|
|
117
|
+
width: calc( ( #{$containerWidth} / #{$slidesPerView} ) - calc( #{$slidesPerView} - 1 ) / #{$slidesPerView} * #{$gap});
|
|
118
|
+
}
|
|
119
|
+
```
|
|
118
120
|
|
|
119
|
-
|
|
121
|
+
Set slide width based on slides per view (more below)
|
|
120
122
|
|
|
121
|
-
|
|
123
|
+
### os-break-out-full-width
|
|
122
124
|
|
|
123
|
-
|
|
125
|
+
Make slider container full width via breaking out of the container that has max-width set.
|
|
124
126
|
|
|
125
127
|
```scss
|
|
126
|
-
@mixin
|
|
127
|
-
|
|
128
|
+
@mixin os-break-out-full-width {
|
|
129
|
+
position: relative;
|
|
130
|
+
left: 50%;
|
|
131
|
+
width: 100vw;
|
|
132
|
+
margin-left: -50vw;
|
|
128
133
|
}
|
|
129
134
|
```
|
|
130
135
|
|
|
131
|
-
|
|
136
|
+
## Slides per view
|
|
137
|
+
|
|
138
|
+
You control slides per view in CSS. Set gap between slides via `gap` to slider element. Note that you cannot use percentages (like 33.33%) for width because they are relative to the container and not the viewport.
|
|
139
|
+
|
|
140
|
+
### A) Slides per view approach
|
|
141
|
+
|
|
142
|
+
This is most practical approach and relies on some calculations. Setting target width for slider container is recommended as that makes the calculations more stable as otherwise container width can depend on slides and if slides then depend on container width that can lead some issues.
|
|
143
|
+
|
|
144
|
+
Setting target width can be done for example referencing another HTML element in page and copying its width:
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
const blockWrapper = document.querySelector( '.block-wrapper' );
|
|
148
|
+
OverflowSlider(
|
|
149
|
+
sliderContainer,
|
|
150
|
+
{
|
|
151
|
+
targetWidth: () => {
|
|
152
|
+
return (blockWrapper).offsetWidth;
|
|
153
|
+
},
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
This creates a `--slider-container-target-width` variable that is now stable.
|
|
159
|
+
|
|
160
|
+
Use mixin `os-slide-width`
|
|
132
161
|
|
|
133
162
|
```scss
|
|
134
163
|
.overflow-slider {
|
|
135
164
|
--gap: 1.5rem;
|
|
136
165
|
gap: var(--gap);
|
|
137
166
|
> * {
|
|
138
|
-
--slides-per-view:
|
|
139
|
-
@include
|
|
167
|
+
--slides-per-view: 1.5;
|
|
168
|
+
@include os-slide-width(
|
|
140
169
|
var(--slides-per-view),
|
|
141
170
|
var(--gap),
|
|
142
|
-
var(--slider-container-width)
|
|
171
|
+
var(--slider-container-target-width)
|
|
143
172
|
);
|
|
173
|
+
@meadia (min-width: 768px) {
|
|
174
|
+
--slides-per-view: 3;
|
|
175
|
+
}
|
|
144
176
|
}
|
|
145
177
|
}
|
|
146
178
|
```
|
|
147
179
|
|
|
148
|
-
|
|
180
|
+
### B) Fixed width
|
|
181
|
+
|
|
182
|
+
Set fixed width for slides: `width: 200px;`. Note you can freely change this with media queries.
|
|
183
|
+
|
|
184
|
+
### C) Relative width
|
|
185
|
+
|
|
186
|
+
Set relative width for slides: `width: 100vw;`. Note that you cannot use percentages because they are relative to the container and not the viewport.
|
|
149
187
|
|
|
150
188
|
## Plugins
|
|
151
189
|
|
|
@@ -289,6 +327,42 @@ const slider = new OverflowSlider(
|
|
|
289
327
|
);
|
|
290
328
|
```
|
|
291
329
|
|
|
330
|
+
### ClassNamesPlugin
|
|
331
|
+
|
|
332
|
+
Adds CSS classes to each slide based on its visibility inside the slider's target width (or the container width when no target width is supplied). Useful for animating only the slides that are currently in view.
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
import ClassNamesPlugin from '@evermade/overflow-slider/plugins/classnames';
|
|
336
|
+
|
|
337
|
+
const slider = new OverflowSlider(
|
|
338
|
+
document.querySelector( '.slider-container-here' ),
|
|
339
|
+
{},
|
|
340
|
+
[
|
|
341
|
+
ClassNamesPlugin({
|
|
342
|
+
freezeStateOnVisible: true,
|
|
343
|
+
classNames: {
|
|
344
|
+
visible: 'is-visible',
|
|
345
|
+
partlyVisible: 'is-partly-visible',
|
|
346
|
+
hidden: 'is-hidden',
|
|
347
|
+
},
|
|
348
|
+
}),
|
|
349
|
+
]
|
|
350
|
+
);
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
All options are optional.
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
type ClassnameOptions = {
|
|
357
|
+
classNames: {
|
|
358
|
+
visible: string;
|
|
359
|
+
partlyVisible: string;
|
|
360
|
+
hidden: string;
|
|
361
|
+
};
|
|
362
|
+
freezeStateOnVisible: boolean; // keep slides in "visible" state once they have been fully seen
|
|
363
|
+
};
|
|
364
|
+
```
|
|
365
|
+
|
|
292
366
|
All options are optional.
|
|
293
367
|
|
|
294
368
|
```ts
|
|
@@ -425,6 +499,46 @@ const thumbnailsSlider = new OverflowSlider(
|
|
|
425
499
|
);
|
|
426
500
|
```
|
|
427
501
|
|
|
502
|
+
### AutoplayPlugin
|
|
503
|
+
|
|
504
|
+
This plugin allows you to automatically scroll the slider. It can be used to create a hero slider that scrolls automatically.
|
|
505
|
+
|
|
506
|
+
This includes play/pause button and for users that prefer reduced motion, autoplay plugin will not execute.
|
|
507
|
+
|
|
508
|
+
```ts
|
|
509
|
+
import AutoplayPlugin from '@evermade/overflow-slider/plugins/autoplay';
|
|
510
|
+
const slider = new OverflowSlider(
|
|
511
|
+
document.querySelector( '.slider-container-here' ),
|
|
512
|
+
{},
|
|
513
|
+
[
|
|
514
|
+
AutoplayPlugin(), // add options here or don't
|
|
515
|
+
]
|
|
516
|
+
);
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
All options are optional.
|
|
520
|
+
|
|
521
|
+
```ts
|
|
522
|
+
export type AutoplayPluginOptions = {
|
|
523
|
+
delayInMs: number;
|
|
524
|
+
texts: {
|
|
525
|
+
play: string;
|
|
526
|
+
pause: string;
|
|
527
|
+
};
|
|
528
|
+
icons: {
|
|
529
|
+
play: string;
|
|
530
|
+
pause: string;
|
|
531
|
+
};
|
|
532
|
+
classNames: {
|
|
533
|
+
autoplayButton: string;
|
|
534
|
+
};
|
|
535
|
+
container: HTMLElement | null;
|
|
536
|
+
movementType: 'view' | 'slide';
|
|
537
|
+
stopOnHover: boolean;
|
|
538
|
+
loop: boolean;
|
|
539
|
+
};
|
|
540
|
+
```
|
|
541
|
+
|
|
428
542
|
## Known issues
|
|
429
543
|
|
|
430
544
|
### CSS grids and Overflow Slider
|
|
@@ -439,24 +553,35 @@ If you are using `scroll-snap-type` CSS property, you might encounter some bugs
|
|
|
439
553
|
|
|
440
554
|
### Vertical scrolling
|
|
441
555
|
|
|
442
|
-
The library is designed to work with horizontal scrolling. Vertical scrolling is not supported
|
|
443
|
-
|
|
444
|
-
### Looping slides
|
|
556
|
+
The library is designed to work with horizontal scrolling. Vertical scrolling is not supported at the moment. Maybe some day but it's much rarer use case.
|
|
445
557
|
|
|
446
|
-
|
|
558
|
+
### Infinite scroll
|
|
447
559
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
Auto-play is not supported at the moment but can probably be implemented as a plugin. It is not very accessible and should be avoided if possible.
|
|
451
|
-
|
|
452
|
-
## To-do
|
|
453
|
-
|
|
454
|
-
* Maybe split styles to separate files for plugins (but keep offering bundle as well)
|
|
455
|
-
* Maybe add plugin that adds class for visible slides
|
|
456
|
-
* Document all plugins and their parameters here
|
|
560
|
+
Infinite scroll is not supported and likely never will be. It is not accessible and causes really complex problems as with overflow we are bound to more "physics" than transform based sliders and there's no escape of the physics (like visible slides need to represent DOM order).
|
|
457
561
|
|
|
458
562
|
## Changelog
|
|
459
563
|
|
|
564
|
+
### 4.1.0
|
|
565
|
+
|
|
566
|
+
* Add: ClassNamesPlugin to add classes to visible/partly visible/hidden slides.
|
|
567
|
+
* Add: targetWidth property to core level (backwards compatible with FullWidthPlugin implementation)
|
|
568
|
+
* Fix: Scroll snapping for FullWidthPlugin
|
|
569
|
+
* Fix: Possible issues where plugin changed some details and that was not applied for first render
|
|
570
|
+
* Fix: Rendering issue where transition on slides could prevent calculations initially from working
|
|
571
|
+
|
|
572
|
+
### 4.0.0
|
|
573
|
+
|
|
574
|
+
* Add: AutoPlayPlugin to allow auto-playing slides
|
|
575
|
+
* Add: Mixins that can be imported to SCSS projects
|
|
576
|
+
* Add: CSS variable: `--slider-container-height`
|
|
577
|
+
* Add: CSS variable: `--slider-x-offset`
|
|
578
|
+
* Add: Option `cssVariableContainer` to expose CSS variables for example higher container
|
|
579
|
+
* Add: `canMoveToSlide` method to check if slider can move to a specific slide (does it exist, is it already in view)
|
|
580
|
+
* Add: `targetWidth` to slider options as relying on `--slider-container-target-width` can be more solid to calculate fractional slide widths on (at least when there is only few slides)
|
|
581
|
+
* Fix: Export TypeScript types properly from core and plugins to be available automatically
|
|
582
|
+
* Fix: ScrollIndicatorPlugin click to scroll bar didn't always detect click position correctly
|
|
583
|
+
* Fix: snapToClosestSlide method edge cases on DragScrollingPlugin sometimes not snapping on right slide
|
|
584
|
+
|
|
460
585
|
### 3.3.1
|
|
461
586
|
|
|
462
587
|
* Fix: FullWidthPlugin margin calculation not being run if there's too few slides for overflow and you resize screen without container width changing
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as OverflowSlider } from './plugins/core/index.d2.ts';
|