@evermade/overflow-slider 3.3.1 → 4.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/.nvmrc +1 -1
- package/README.md +115 -29
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +609 -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/core/index.d.ts +75 -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 +14 -3
- 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 +115 -0
- package/docs/assets/demo.js +68 -0
- package/docs/dist/index.d.ts +1 -0
- package/docs/dist/index.esm.js +609 -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/core/index.d.ts +23 -0
- package/docs/dist/plugins/core/index.d2.ts +75 -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 +14 -3
- 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 +77 -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 +91 -64
- package/src/core/types.ts +29 -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/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 +17 -5
- package/src/plugins/infinite-scroll/index.ts +109 -0
- 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
|
-
|
|
110
|
-
|
|
111
|
-
Set fixed width for slides: `width: 200px;`. Note you can freely change this with media queries.
|
|
107
|
+
If you are using SCSS, you can use these helpers.
|
|
112
108
|
|
|
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
|
|
|
@@ -425,6 +463,46 @@ const thumbnailsSlider = new OverflowSlider(
|
|
|
425
463
|
);
|
|
426
464
|
```
|
|
427
465
|
|
|
466
|
+
### AutoplayPlugin
|
|
467
|
+
|
|
468
|
+
This plugin allows you to automatically scroll the slider. It can be used to create a hero slider that scrolls automatically.
|
|
469
|
+
|
|
470
|
+
This includes play/pause button and for users that prefer reduced motion, autoplay plugin will not execute.
|
|
471
|
+
|
|
472
|
+
```ts
|
|
473
|
+
import AutoplayPlugin from '@evermade/overflow-slider/plugins/autoplay';
|
|
474
|
+
const slider = new OverflowSlider(
|
|
475
|
+
document.querySelector( '.slider-container-here' ),
|
|
476
|
+
{},
|
|
477
|
+
[
|
|
478
|
+
AutoplayPlugin(), // add options here or don't
|
|
479
|
+
]
|
|
480
|
+
);
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
All options are optional.
|
|
484
|
+
|
|
485
|
+
```ts
|
|
486
|
+
export type AutoplayPluginOptions = {
|
|
487
|
+
delayInMs: number;
|
|
488
|
+
texts: {
|
|
489
|
+
play: string;
|
|
490
|
+
pause: string;
|
|
491
|
+
};
|
|
492
|
+
icons: {
|
|
493
|
+
play: string;
|
|
494
|
+
pause: string;
|
|
495
|
+
};
|
|
496
|
+
classNames: {
|
|
497
|
+
autoplayButton: string;
|
|
498
|
+
};
|
|
499
|
+
container: HTMLElement | null;
|
|
500
|
+
movementType: 'view' | 'slide';
|
|
501
|
+
stopOnHover: boolean;
|
|
502
|
+
loop: boolean;
|
|
503
|
+
};
|
|
504
|
+
```
|
|
505
|
+
|
|
428
506
|
## Known issues
|
|
429
507
|
|
|
430
508
|
### CSS grids and Overflow Slider
|
|
@@ -439,24 +517,32 @@ If you are using `scroll-snap-type` CSS property, you might encounter some bugs
|
|
|
439
517
|
|
|
440
518
|
### Vertical scrolling
|
|
441
519
|
|
|
442
|
-
The library is designed to work with horizontal scrolling. Vertical scrolling is not supported
|
|
520
|
+
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.
|
|
443
521
|
|
|
444
|
-
###
|
|
522
|
+
### Infinite scroll
|
|
445
523
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
### Auto-play
|
|
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.
|
|
524
|
+
Infinite scroll is not supported and likely never will be. It is a feature that is not very common and it is not very accessible.
|
|
451
525
|
|
|
452
526
|
## To-do
|
|
453
527
|
|
|
454
|
-
* Maybe split styles to separate files for plugins (but keep offering bundle as well)
|
|
455
528
|
* Maybe add plugin that adds class for visible slides
|
|
456
|
-
*
|
|
529
|
+
* Experiment on infinite scroll
|
|
457
530
|
|
|
458
531
|
## Changelog
|
|
459
532
|
|
|
533
|
+
### 4.0.0
|
|
534
|
+
|
|
535
|
+
* Add: AutoPlayPlugin to allow auto-playing slides
|
|
536
|
+
* Add: Mixins that can be imported to SCSS projects
|
|
537
|
+
* Add: CSS variable: `--slider-container-height`
|
|
538
|
+
* Add: CSS variable: `--slider-x-offset`
|
|
539
|
+
* Add: Option `cssVariableContainer` to expose CSS variables for example higher container
|
|
540
|
+
* Add: `canMoveToSlide` method to check if slider can move to a specific slide (does it exist, is it already in view)
|
|
541
|
+
* 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)
|
|
542
|
+
* Fix: Export TypeScript types properly from core and plugins to be available automatically
|
|
543
|
+
* Fix: ScrollIndicatorPlugin click to scroll bar didn't always detect click position correctly
|
|
544
|
+
* Fix: snapToClosestSlide method edge cases on DragScrollingPlugin sometimes not snapping on right slide
|
|
545
|
+
|
|
460
546
|
### 3.3.1
|
|
461
547
|
|
|
462
548
|
* 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';
|