solid-slider 1.3.19 → 1.3.21
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 +152 -5
- package/dist/adaptiveHeight/index.common.js +2 -2
- package/dist/adaptiveHeight/index.common.js.map +1 -1
- package/dist/adaptiveHeight/index.module.js +2 -2
- package/dist/adaptiveHeight/index.module.js.map +1 -1
- package/dist/adaptiveWidth/index.common.js +2 -2
- package/dist/adaptiveWidth/index.common.js.map +1 -1
- package/dist/adaptiveWidth/index.module.js +2 -2
- package/dist/adaptiveWidth/index.module.js.map +1 -1
- package/dist/autoplay/autoplay.d.ts +7 -7
- package/dist/autoplay/autoplay.jsx +7 -7
- package/dist/autoplay/index.common.js +14 -24
- package/dist/autoplay/index.common.js.map +1 -1
- package/dist/autoplay/index.module.js +14 -24
- package/dist/autoplay/index.module.js.map +1 -1
- package/dist/index/components.d.ts +74 -9
- package/dist/index/components.jsx +156 -9
- package/dist/index/index.common.js +291 -230
- package/dist/index/index.common.js.map +1 -1
- package/dist/index/index.module.js +292 -233
- package/dist/index/index.module.js.map +1 -1
- package/dist/index/primitive.d.ts +11 -11
- package/dist/index/{primitive.js → primitive.jsx} +18 -16
- package/dist/slider.css +21 -0
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
<p>
|
|
2
|
+
<img width="100%" src="https://assets.solidjs.com/banner?type=Solid%20Slider&background=tiles&project=%20" alt="Solid Slider">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
|
|
1
6
|
# Solid Slider
|
|
2
7
|
|
|
3
8
|
[](https://bundlephobia.com/package/solid-slider)
|
|
@@ -71,7 +76,7 @@ const MyComponent = () => {
|
|
|
71
76
|
</Slider>
|
|
72
77
|
<SliderButton prev>Previous</SliderButton>
|
|
73
78
|
<SliderButton next>Next</SliderButton>
|
|
74
|
-
|
|
79
|
+
</SliderProvider>
|
|
75
80
|
);
|
|
76
81
|
};
|
|
77
82
|
```
|
|
@@ -212,6 +217,145 @@ const [slider] = createSlider(
|
|
|
212
217
|
);
|
|
213
218
|
```
|
|
214
219
|
|
|
220
|
+
## Helper Components
|
|
221
|
+
|
|
222
|
+
### Navigation Dots
|
|
223
|
+
|
|
224
|
+
You can add navigation dots to your slider using the `SliderDots` component. The component automatically generates clickable dots for each slide and highlights the active slide.
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
import { SliderProvider, Slider, SliderDots } from "solid-slider";
|
|
228
|
+
|
|
229
|
+
const MyComponent = () => {
|
|
230
|
+
return (
|
|
231
|
+
<SliderProvider>
|
|
232
|
+
<Slider options={{ loop: true }}>
|
|
233
|
+
<div>Slide 1</div>
|
|
234
|
+
<div>Slide 2</div>
|
|
235
|
+
<div>Slide 3</div>
|
|
236
|
+
</Slider>
|
|
237
|
+
<SliderDots />
|
|
238
|
+
</SliderProvider>
|
|
239
|
+
);
|
|
240
|
+
};
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**Customization:**
|
|
244
|
+
|
|
245
|
+
You can customize the dots styling using `class`, `classList`, `dotClass`, and `dotClassList` props:
|
|
246
|
+
|
|
247
|
+
```tsx
|
|
248
|
+
<SliderDots
|
|
249
|
+
class="my-dots-container"
|
|
250
|
+
dotClass="my-dot"
|
|
251
|
+
dotClassList={{ "my-active-dot": true }}
|
|
252
|
+
/>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**Props:**
|
|
256
|
+
- `class` - CSS class for the dots container
|
|
257
|
+
- `classList` - Conditional classes for the dots container
|
|
258
|
+
- `dotClass` - CSS class for individual dot buttons
|
|
259
|
+
- `dotClassList` - Conditional classes for individual dot buttons
|
|
260
|
+
|
|
261
|
+
**Default Classes:**
|
|
262
|
+
- Container: `.slider-dots`
|
|
263
|
+
- Individual dots: `.slider-dot`
|
|
264
|
+
- Active dot: `.slider-dot.active`
|
|
265
|
+
|
|
266
|
+
**Styling Example:**
|
|
267
|
+
|
|
268
|
+
```css
|
|
269
|
+
.slider-dots {
|
|
270
|
+
display: flex;
|
|
271
|
+
justify-content: center;
|
|
272
|
+
gap: 8px;
|
|
273
|
+
margin-top: 20px;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.slider-dot {
|
|
277
|
+
width: 12px;
|
|
278
|
+
height: 12px;
|
|
279
|
+
border-radius: 50%;
|
|
280
|
+
background: #ddd;
|
|
281
|
+
border: none;
|
|
282
|
+
cursor: pointer;
|
|
283
|
+
transition: background 0.3s;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.slider-dot:hover {
|
|
287
|
+
background: #aaa;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.slider-dot.active {
|
|
291
|
+
background: #333;
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Thumbnail Navigation
|
|
296
|
+
|
|
297
|
+
Create a synchronized thumbnail navigation using the `SliderThumbnails` component. This creates a second slider that stays in sync with the main slider, allowing users to click thumbnails to navigate.
|
|
298
|
+
|
|
299
|
+
```tsx
|
|
300
|
+
import { SliderProvider, Slider, SliderThumbnails } from "solid-slider";
|
|
301
|
+
import { For } from "solid-js";
|
|
302
|
+
|
|
303
|
+
const MyComponent = () => {
|
|
304
|
+
const images = [
|
|
305
|
+
{ full: "/slide1.jpg", thumb: "/thumb1.jpg" },
|
|
306
|
+
{ full: "/slide2.jpg", thumb: "/thumb2.jpg" },
|
|
307
|
+
{ full: "/slide3.jpg", thumb: "/thumb3.jpg" },
|
|
308
|
+
];
|
|
309
|
+
|
|
310
|
+
return (
|
|
311
|
+
<SliderProvider>
|
|
312
|
+
<Slider options={{ loop: true }}>
|
|
313
|
+
<For each={images}>
|
|
314
|
+
{(img) => (
|
|
315
|
+
<div>
|
|
316
|
+
<img src={img.full} alt="Slide" />
|
|
317
|
+
</div>
|
|
318
|
+
)}
|
|
319
|
+
</For>
|
|
320
|
+
</Slider>
|
|
321
|
+
<SliderThumbnails options={{ slides: { perView: 4, spacing: 10 } }}>
|
|
322
|
+
<For each={images}>
|
|
323
|
+
{(img) => (
|
|
324
|
+
<div class="thumbnail-slide">
|
|
325
|
+
<img src={img.thumb} alt="Thumbnail" />
|
|
326
|
+
</div>
|
|
327
|
+
)}
|
|
328
|
+
</For>
|
|
329
|
+
</SliderThumbnails>
|
|
330
|
+
</SliderProvider>
|
|
331
|
+
);
|
|
332
|
+
};
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
**Important:** When using dynamic content with `SliderThumbnails`, use SolidJS's `<For>` component instead of `.map()` to ensure proper reactivity.
|
|
336
|
+
|
|
337
|
+
**Props:**
|
|
338
|
+
- `options` - KeenSlider options for the thumbnail slider (e.g., slides per view, spacing)
|
|
339
|
+
- `plugins` - Array of KeenSlider plugins to apply to the thumbnail slider
|
|
340
|
+
- `activeClass` - Custom CSS class name for the active thumbnail (default: `"active"`)
|
|
341
|
+
|
|
342
|
+
**Features:**
|
|
343
|
+
- Automatically syncs with the main slider
|
|
344
|
+
- Adds `active` class to the current thumbnail
|
|
345
|
+
- Click any thumbnail to navigate to that slide
|
|
346
|
+
- Supports all KeenSlider options for customization
|
|
347
|
+
|
|
348
|
+
**Styling Example:**
|
|
349
|
+
|
|
350
|
+
```css
|
|
351
|
+
.thumbnail-slide:hover {
|
|
352
|
+
opacity: 0.8;
|
|
353
|
+
}
|
|
354
|
+
.thumbnail-slide.active {
|
|
355
|
+
opacity: 1;
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
215
359
|
## SolidStart & Server-Side Rendering
|
|
216
360
|
|
|
217
361
|
So you want to use Solid Slider with [SolidStart](https://start.solidjs.com/). No problem but be mindful of how you use it and how server-side rendering impacts the experience. Remember that by default SolidStart enables SSR meaning that your pages are initially rendered on the server. The server has no context of the dimensions of your browser so it cannot calculate how the slider will appear once it's rendered in the browser.
|
|
@@ -232,8 +376,8 @@ Thie library exports it's own CSS which is the basic Keen-Slider implementation
|
|
|
232
376
|
|
|
233
377
|
- [x] Create [adaptiveHeight](https://codesandbox.io/s/github/rcbyr/keen-slider-sandboxes/tree/v6/misc/adaptive-height/react?file=/src/App.js:191-403) plugin
|
|
234
378
|
- [x] Create [adaptiveWidth](https://github.com/joeygrable94/solid-slider) plugin
|
|
235
|
-
- [
|
|
236
|
-
- [
|
|
379
|
+
- [x] Add Dots components (to display a row of dots below the slider)
|
|
380
|
+
- [x] Add slider thumbnail navigation
|
|
237
381
|
- [ ] Add slider loader
|
|
238
382
|
- [ ] Build [timepicker](https://keen-slider.io/examples#timepicker) component
|
|
239
383
|
- [ ] Create [Scroll Wheel](https://keen-slider.io/examples#scroll-wheel-controls) component
|
|
@@ -248,7 +392,7 @@ Thie library exports it's own CSS which is the basic Keen-Slider implementation
|
|
|
248
392
|
- 1.2.9 - Updated timer primitive and patched issue with current slide setting from initial options.
|
|
249
393
|
- 1.3.1 - Introduced Slider, SliderProvider and SliderButton for ease.
|
|
250
394
|
- 1.3.2 - Patched issue with initial slide not setting current signal.
|
|
251
|
-
- 1.3.5 - Updated to latest
|
|
395
|
+
- 1.3.5 - Updated to latest Solid version.
|
|
252
396
|
- 1.3.7 - Fixed TS issues updated to latest KeenSlider.
|
|
253
397
|
- 1.3.8 - Updated to Solid 1.5
|
|
254
398
|
- 1.3.9 - Fixed Keen URLs, type issues and truthy error with autoplay (thanks [ishanAhuja](https://www.github.com/ishanAhuja) and [ahhshm](https://www.github.com/ahhshm))
|
|
@@ -258,8 +402,11 @@ Thie library exports it's own CSS which is the basic Keen-Slider implementation
|
|
|
258
402
|
- 1.3.14 - Patched npm packaging issue (thanks [joeygrable94 ](https://www.github.com/joeygrable94))
|
|
259
403
|
- 1.3.15 - Updated to Solid 1.7.11
|
|
260
404
|
- 1.3.16 - Updated dependencies and move Solid from dependency to peer
|
|
261
|
-
- 1.3.17 - Added
|
|
405
|
+
- 1.3.17 - Added types definition to exports (thanks [ChristophP](https://github.com/ChristophP))
|
|
262
406
|
- 1.3.18 - Adjusted documentation and minor source cleanup
|
|
407
|
+
- 1.3.19 - Attempt to fix export paths
|
|
408
|
+
- 1.3.20 - Package maintenance (bumping versions) and added new dot and thumbnail navigation components
|
|
409
|
+
- 1.3.21 - Patched type for SliderDots (thanks [Violettica](https://github.com/Violettica)), improved additional types.
|
|
263
410
|
|
|
264
411
|
## Keen Options API
|
|
265
412
|
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* const [create] = createSlider({}, [adaptiveHeight]);
|
|
9
9
|
* ```
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
return
|
|
11
|
+
const adaptiveHeight = () => {
|
|
12
|
+
return slider => {
|
|
13
13
|
function updateHeight() {
|
|
14
14
|
slider.container.style.height = slider.slides[slider.track.details.rel].offsetHeight + "px";
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.common.js","sources":["../../src/plugins/adaptiveHeight.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive height is a plugin that adjusts the height of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveHeight]);\n * ```\n */\nexport const adaptiveHeight = () => {\n return (slider: KeenSliderInstance) => {\n function updateHeight() {\n slider.container.style.height =\n slider.slides[slider.track.details.rel].offsetHeight + \"px\";\n }\n slider.on(\"created\", updateHeight);\n slider.on(\"slideChanged\", updateHeight);\n };\n};\n"],"names":["adaptiveHeight","slider","updateHeight","container","style","height","slides","track","details","rel","offsetHeight","on"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"index.common.js","sources":["../../src/plugins/adaptiveHeight.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive height is a plugin that adjusts the height of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveHeight]);\n * ```\n */\nexport const adaptiveHeight = () => {\n return (slider: KeenSliderInstance) => {\n function updateHeight() {\n slider.container.style.height =\n slider.slides[slider.track.details.rel].offsetHeight + \"px\";\n }\n slider.on(\"created\", updateHeight);\n slider.on(\"slideChanged\", updateHeight);\n };\n};\n"],"names":["adaptiveHeight","slider","updateHeight","container","style","height","slides","track","details","rel","offsetHeight","on"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,GAAGA,MAAM;AAClC,EAAA,OAAQC,MAA0B,IAAK;IACrC,SAASC,YAAYA,GAAG;MACtBD,MAAM,CAACE,SAAS,CAACC,KAAK,CAACC,MAAM,GAC3BJ,MAAM,CAACK,MAAM,CAACL,MAAM,CAACM,KAAK,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,YAAY,GAAG,IAAI;AAC/D,IAAA;AACAT,IAAAA,MAAM,CAACU,EAAE,CAAC,SAAS,EAAET,YAAY,CAAC;AAClCD,IAAAA,MAAM,CAACU,EAAE,CAAC,cAAc,EAAET,YAAY,CAAC;EACzC,CAAC;AACH;;;;"}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* const [create] = createSlider({}, [adaptiveHeight]);
|
|
7
7
|
* ```
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
return
|
|
9
|
+
const adaptiveHeight = () => {
|
|
10
|
+
return slider => {
|
|
11
11
|
function updateHeight() {
|
|
12
12
|
slider.container.style.height = slider.slides[slider.track.details.rel].offsetHeight + "px";
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.js","sources":["../../src/plugins/adaptiveHeight.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive height is a plugin that adjusts the height of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveHeight]);\n * ```\n */\nexport const adaptiveHeight = () => {\n return (slider: KeenSliderInstance) => {\n function updateHeight() {\n slider.container.style.height =\n slider.slides[slider.track.details.rel].offsetHeight + \"px\";\n }\n slider.on(\"created\", updateHeight);\n slider.on(\"slideChanged\", updateHeight);\n };\n};\n"],"names":["adaptiveHeight","slider","updateHeight","container","style","height","slides","track","details","rel","offsetHeight","on"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"index.module.js","sources":["../../src/plugins/adaptiveHeight.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive height is a plugin that adjusts the height of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveHeight]);\n * ```\n */\nexport const adaptiveHeight = () => {\n return (slider: KeenSliderInstance) => {\n function updateHeight() {\n slider.container.style.height =\n slider.slides[slider.track.details.rel].offsetHeight + \"px\";\n }\n slider.on(\"created\", updateHeight);\n slider.on(\"slideChanged\", updateHeight);\n };\n};\n"],"names":["adaptiveHeight","slider","updateHeight","container","style","height","slides","track","details","rel","offsetHeight","on"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,GAAGA,MAAM;AAClC,EAAA,OAAQC,MAA0B,IAAK;IACrC,SAASC,YAAYA,GAAG;MACtBD,MAAM,CAACE,SAAS,CAACC,KAAK,CAACC,MAAM,GAC3BJ,MAAM,CAACK,MAAM,CAACL,MAAM,CAACM,KAAK,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,YAAY,GAAG,IAAI;AAC/D,IAAA;AACAT,IAAAA,MAAM,CAACU,EAAE,CAAC,SAAS,EAAET,YAAY,CAAC;AAClCD,IAAAA,MAAM,CAACU,EAAE,CAAC,cAAc,EAAET,YAAY,CAAC;EACzC,CAAC;AACH;;;;"}
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* const [create] = createSlider({}, [adaptiveWidth]);
|
|
9
9
|
* ```
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
return
|
|
11
|
+
const adaptiveWidth = () => {
|
|
12
|
+
return slider => {
|
|
13
13
|
function updateWidth() {
|
|
14
14
|
slider.container.style.width = slider.slides[slider.track.details.rel].offsetWidth + "px";
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.common.js","sources":["../../src/plugins/adaptiveWidth.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive width is a plugin that adjusts the width of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveWidth]);\n * ```\n */\nexport const adaptiveWidth = () => {\n return (slider: KeenSliderInstance) => {\n function updateWidth() {\n slider.container.style.width =\n slider.slides[slider.track.details.rel].offsetWidth + \"px\";\n }\n slider.on(\"created\", updateWidth);\n slider.on(\"slideChanged\", updateWidth);\n };\n};\n"],"names":["adaptiveWidth","slider","updateWidth","container","style","width","slides","track","details","rel","offsetWidth","on"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"index.common.js","sources":["../../src/plugins/adaptiveWidth.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive width is a plugin that adjusts the width of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveWidth]);\n * ```\n */\nexport const adaptiveWidth = () => {\n return (slider: KeenSliderInstance) => {\n function updateWidth() {\n slider.container.style.width =\n slider.slides[slider.track.details.rel].offsetWidth + \"px\";\n }\n slider.on(\"created\", updateWidth);\n slider.on(\"slideChanged\", updateWidth);\n };\n};\n"],"names":["adaptiveWidth","slider","updateWidth","container","style","width","slides","track","details","rel","offsetWidth","on"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GAAGA,MAAM;AACjC,EAAA,OAAQC,MAA0B,IAAK;IACrC,SAASC,WAAWA,GAAG;MACrBD,MAAM,CAACE,SAAS,CAACC,KAAK,CAACC,KAAK,GAC1BJ,MAAM,CAACK,MAAM,CAACL,MAAM,CAACM,KAAK,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,WAAW,GAAG,IAAI;AAC9D,IAAA;AACAT,IAAAA,MAAM,CAACU,EAAE,CAAC,SAAS,EAAET,WAAW,CAAC;AACjCD,IAAAA,MAAM,CAACU,EAAE,CAAC,cAAc,EAAET,WAAW,CAAC;EACxC,CAAC;AACH;;;;"}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* const [create] = createSlider({}, [adaptiveWidth]);
|
|
7
7
|
* ```
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
return
|
|
9
|
+
const adaptiveWidth = () => {
|
|
10
|
+
return slider => {
|
|
11
11
|
function updateWidth() {
|
|
12
12
|
slider.container.style.width = slider.slides[slider.track.details.rel].offsetWidth + "px";
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.js","sources":["../../src/plugins/adaptiveWidth.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive width is a plugin that adjusts the width of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveWidth]);\n * ```\n */\nexport const adaptiveWidth = () => {\n return (slider: KeenSliderInstance) => {\n function updateWidth() {\n slider.container.style.width =\n slider.slides[slider.track.details.rel].offsetWidth + \"px\";\n }\n slider.on(\"created\", updateWidth);\n slider.on(\"slideChanged\", updateWidth);\n };\n};\n"],"names":["adaptiveWidth","slider","updateWidth","container","style","width","slides","track","details","rel","offsetWidth","on"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"index.module.js","sources":["../../src/plugins/adaptiveWidth.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive width is a plugin that adjusts the width of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveWidth]);\n * ```\n */\nexport const adaptiveWidth = () => {\n return (slider: KeenSliderInstance) => {\n function updateWidth() {\n slider.container.style.width =\n slider.slides[slider.track.details.rel].offsetWidth + \"px\";\n }\n slider.on(\"created\", updateWidth);\n slider.on(\"slideChanged\", updateWidth);\n };\n};\n"],"names":["adaptiveWidth","slider","updateWidth","container","style","width","slides","track","details","rel","offsetWidth","on"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GAAGA,MAAM;AACjC,EAAA,OAAQC,MAA0B,IAAK;IACrC,SAASC,WAAWA,GAAG;MACrBD,MAAM,CAACE,SAAS,CAACC,KAAK,CAACC,KAAK,GAC1BJ,MAAM,CAACK,MAAM,CAACL,MAAM,CAACM,KAAK,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,WAAW,GAAG,IAAI;AAC9D,IAAA;AACAT,IAAAA,MAAM,CAACU,EAAE,CAAC,SAAS,EAAET,WAAW,CAAC;AACjCD,IAAAA,MAAM,CAACU,EAAE,CAAC,cAAc,EAAET,WAAW,CAAC;EACxC,CAAC;AACH;;;;"}
|
|
@@ -3,13 +3,13 @@ import { Accessor } from "solid-js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Provides an autoplay plugin.
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
6
|
+
* @param interval - Interval in milliseconds for switching slides
|
|
7
|
+
* @param options - Options to customize the autoplay
|
|
8
|
+
* @param options.pause - A pause signal to control the autoplay
|
|
9
|
+
* @param options.pauseOnDrag - Denotes of the autoplay should pause on drag.
|
|
10
|
+
* @param options.animation - Allows for control of duration and easing.
|
|
11
|
+
* @param options.duration - Duration for transitioning the slide.
|
|
12
|
+
* @param options.easing - Easing function for the transition animation.
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```ts
|
|
@@ -3,13 +3,13 @@ import { createEffect } from "solid-js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Provides an autoplay plugin.
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
6
|
+
* @param interval - Interval in milliseconds for switching slides
|
|
7
|
+
* @param options - Options to customize the autoplay
|
|
8
|
+
* @param options.pause - A pause signal to control the autoplay
|
|
9
|
+
* @param options.pauseOnDrag - Denotes of the autoplay should pause on drag.
|
|
10
|
+
* @param options.animation - Allows for control of duration and easing.
|
|
11
|
+
* @param options.duration - Duration for transitioning the slide.
|
|
12
|
+
* @param options.easing - Easing function for the transition animation.
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```ts
|
|
@@ -6,40 +6,30 @@ var solidJs = require('solid-js');
|
|
|
6
6
|
/**
|
|
7
7
|
* Provides an autoplay plugin.
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
9
|
+
* @param interval - Interval in milliseconds for switching slides
|
|
10
|
+
* @param options - Options to customize the autoplay
|
|
11
|
+
* @param options.pause - A pause signal to control the autoplay
|
|
12
|
+
* @param options.pauseOnDrag - Denotes of the autoplay should pause on drag.
|
|
13
|
+
* @param options.animation - Allows for control of duration and easing.
|
|
14
|
+
* @param options.duration - Duration for transitioning the slide.
|
|
15
|
+
* @param options.easing - Easing function for the transition animation.
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```ts
|
|
19
19
|
* const [create] = createSlider({}, [autoplay]);
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var start = function start() {
|
|
28
|
-
dispose = timer.makeTimer(function () {
|
|
29
|
-
return slider.moveToIdx(slider.track.details.position + 1, true, options.animation);
|
|
30
|
-
}, interval, setInterval);
|
|
22
|
+
const autoplay = (interval = 1000, options) => {
|
|
23
|
+
return slider => {
|
|
24
|
+
let dispose;
|
|
25
|
+
const start = () => {
|
|
26
|
+
dispose = timer.makeTimer(() => slider.moveToIdx(slider.track.details.position + 1, true, options.animation), interval, setInterval);
|
|
31
27
|
};
|
|
32
28
|
// Pause the slider on drag
|
|
33
29
|
if (options.pauseOnDrag !== false) {
|
|
34
|
-
slider.on("dragStarted",
|
|
35
|
-
var _dispose;
|
|
36
|
-
return (_dispose = dispose) === null || _dispose === void 0 ? void 0 : _dispose();
|
|
37
|
-
});
|
|
30
|
+
slider.on("dragStarted", () => dispose?.());
|
|
38
31
|
}
|
|
39
|
-
solidJs.createEffect(
|
|
40
|
-
var _dispose2;
|
|
41
|
-
return !options.pause || options.pause() === false ? start() : (_dispose2 = dispose) === null || _dispose2 === void 0 ? void 0 : _dispose2();
|
|
42
|
-
});
|
|
32
|
+
solidJs.createEffect(() => !options.pause || options.pause() === false ? start() : dispose?.());
|
|
43
33
|
};
|
|
44
34
|
};
|
|
45
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.common.js","sources":["../../src/plugins/autoplay.tsx"],"sourcesContent":["import { makeTimer } from \"@solid-primitives/timer\";\nimport { KeenSliderInstance } from \"keen-slider\";\nimport { Accessor, createEffect } from \"solid-js\";\n\n/**\n * Provides an autoplay plugin.\n *\n * @param
|
|
1
|
+
{"version":3,"file":"index.common.js","sources":["../../src/plugins/autoplay.tsx"],"sourcesContent":["import { makeTimer } from \"@solid-primitives/timer\";\nimport { KeenSliderInstance } from \"keen-slider\";\nimport { Accessor, createEffect } from \"solid-js\";\n\n/**\n * Provides an autoplay plugin.\n *\n * @param interval - Interval in milliseconds for switching slides\n * @param options - Options to customize the autoplay\n * @param options.pause - A pause signal to control the autoplay\n * @param options.pauseOnDrag - Denotes of the autoplay should pause on drag.\n * @param options.animation - Allows for control of duration and easing.\n * @param options.duration - Duration for transitioning the slide.\n * @param options.easing - Easing function for the transition animation.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [autoplay]);\n * ```\n */\nexport const autoplay = (\n interval: number = 1000,\n options: {\n pause?: Accessor<boolean>;\n pauseOnDrag?: boolean;\n animation?: {\n duration?: number;\n easing?: (t: number) => number;\n };\n },\n) => {\n return (slider: KeenSliderInstance) => {\n let dispose: Function;\n const start = () => {\n dispose = makeTimer(\n () =>\n slider.moveToIdx(\n slider.track.details.position + 1,\n true,\n options.animation,\n ),\n interval,\n setInterval,\n );\n };\n // Pause the slider on drag\n if (options.pauseOnDrag !== false) {\n slider.on(\"dragStarted\", () => dispose?.());\n }\n createEffect(() =>\n !options.pause || options.pause() === false ? start() : dispose?.(),\n );\n };\n};\n"],"names":["autoplay","interval","options","slider","dispose","start","makeTimer","moveToIdx","track","details","position","animation","setInterval","pauseOnDrag","on","createEffect","pause"],"mappings":";;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAGA,CACtBC,QAAgB,GAAG,IAAI,EACvBC,OAOC,KACE;AACH,EAAA,OAAQC,MAA0B,IAAK;AACrC,IAAA,IAAIC,OAAiB;IACrB,MAAMC,KAAK,GAAGA,MAAM;AAClBD,MAAAA,OAAO,GAAGE,eAAS,CACjB,MACEH,MAAM,CAACI,SAAS,CACdJ,MAAM,CAACK,KAAK,CAACC,OAAO,CAACC,QAAQ,GAAG,CAAC,EACjC,IAAI,EACJR,OAAO,CAACS,SACV,CAAC,EACHV,QAAQ,EACRW,WACF,CAAC;IACH,CAAC;AACD;AACA,IAAA,IAAIV,OAAO,CAACW,WAAW,KAAK,KAAK,EAAE;MACjCV,MAAM,CAACW,EAAE,CAAC,aAAa,EAAE,MAAMV,OAAO,IAAI,CAAC;AAC7C,IAAA;IACAW,oBAAY,CAAC,MACX,CAACb,OAAO,CAACc,KAAK,IAAId,OAAO,CAACc,KAAK,EAAE,KAAK,KAAK,GAAGX,KAAK,EAAE,GAAGD,OAAO,IACjE,CAAC;EACH,CAAC;AACH;;;;"}
|
|
@@ -4,40 +4,30 @@ import { createEffect } from 'solid-js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Provides an autoplay plugin.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
7
|
+
* @param interval - Interval in milliseconds for switching slides
|
|
8
|
+
* @param options - Options to customize the autoplay
|
|
9
|
+
* @param options.pause - A pause signal to control the autoplay
|
|
10
|
+
* @param options.pauseOnDrag - Denotes of the autoplay should pause on drag.
|
|
11
|
+
* @param options.animation - Allows for control of duration and easing.
|
|
12
|
+
* @param options.duration - Duration for transitioning the slide.
|
|
13
|
+
* @param options.easing - Easing function for the transition animation.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```ts
|
|
17
17
|
* const [create] = createSlider({}, [autoplay]);
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var start = function start() {
|
|
26
|
-
dispose = makeTimer(function () {
|
|
27
|
-
return slider.moveToIdx(slider.track.details.position + 1, true, options.animation);
|
|
28
|
-
}, interval, setInterval);
|
|
20
|
+
const autoplay = (interval = 1000, options) => {
|
|
21
|
+
return slider => {
|
|
22
|
+
let dispose;
|
|
23
|
+
const start = () => {
|
|
24
|
+
dispose = makeTimer(() => slider.moveToIdx(slider.track.details.position + 1, true, options.animation), interval, setInterval);
|
|
29
25
|
};
|
|
30
26
|
// Pause the slider on drag
|
|
31
27
|
if (options.pauseOnDrag !== false) {
|
|
32
|
-
slider.on("dragStarted",
|
|
33
|
-
var _dispose;
|
|
34
|
-
return (_dispose = dispose) === null || _dispose === void 0 ? void 0 : _dispose();
|
|
35
|
-
});
|
|
28
|
+
slider.on("dragStarted", () => dispose?.());
|
|
36
29
|
}
|
|
37
|
-
createEffect(
|
|
38
|
-
var _dispose2;
|
|
39
|
-
return !options.pause || options.pause() === false ? start() : (_dispose2 = dispose) === null || _dispose2 === void 0 ? void 0 : _dispose2();
|
|
40
|
-
});
|
|
30
|
+
createEffect(() => !options.pause || options.pause() === false ? start() : dispose?.());
|
|
41
31
|
};
|
|
42
32
|
};
|
|
43
33
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.js","sources":["../../src/plugins/autoplay.tsx"],"sourcesContent":["import { makeTimer } from \"@solid-primitives/timer\";\nimport { KeenSliderInstance } from \"keen-slider\";\nimport { Accessor, createEffect } from \"solid-js\";\n\n/**\n * Provides an autoplay plugin.\n *\n * @param
|
|
1
|
+
{"version":3,"file":"index.module.js","sources":["../../src/plugins/autoplay.tsx"],"sourcesContent":["import { makeTimer } from \"@solid-primitives/timer\";\nimport { KeenSliderInstance } from \"keen-slider\";\nimport { Accessor, createEffect } from \"solid-js\";\n\n/**\n * Provides an autoplay plugin.\n *\n * @param interval - Interval in milliseconds for switching slides\n * @param options - Options to customize the autoplay\n * @param options.pause - A pause signal to control the autoplay\n * @param options.pauseOnDrag - Denotes of the autoplay should pause on drag.\n * @param options.animation - Allows for control of duration and easing.\n * @param options.duration - Duration for transitioning the slide.\n * @param options.easing - Easing function for the transition animation.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [autoplay]);\n * ```\n */\nexport const autoplay = (\n interval: number = 1000,\n options: {\n pause?: Accessor<boolean>;\n pauseOnDrag?: boolean;\n animation?: {\n duration?: number;\n easing?: (t: number) => number;\n };\n },\n) => {\n return (slider: KeenSliderInstance) => {\n let dispose: Function;\n const start = () => {\n dispose = makeTimer(\n () =>\n slider.moveToIdx(\n slider.track.details.position + 1,\n true,\n options.animation,\n ),\n interval,\n setInterval,\n );\n };\n // Pause the slider on drag\n if (options.pauseOnDrag !== false) {\n slider.on(\"dragStarted\", () => dispose?.());\n }\n createEffect(() =>\n !options.pause || options.pause() === false ? start() : dispose?.(),\n );\n };\n};\n"],"names":["autoplay","interval","options","slider","dispose","start","makeTimer","moveToIdx","track","details","position","animation","setInterval","pauseOnDrag","on","createEffect","pause"],"mappings":";;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAGA,CACtBC,QAAgB,GAAG,IAAI,EACvBC,OAOC,KACE;AACH,EAAA,OAAQC,MAA0B,IAAK;AACrC,IAAA,IAAIC,OAAiB;IACrB,MAAMC,KAAK,GAAGA,MAAM;AAClBD,MAAAA,OAAO,GAAGE,SAAS,CACjB,MACEH,MAAM,CAACI,SAAS,CACdJ,MAAM,CAACK,KAAK,CAACC,OAAO,CAACC,QAAQ,GAAG,CAAC,EACjC,IAAI,EACJR,OAAO,CAACS,SACV,CAAC,EACHV,QAAQ,EACRW,WACF,CAAC;IACH,CAAC;AACD;AACA,IAAA,IAAIV,OAAO,CAACW,WAAW,KAAK,KAAK,EAAE;MACjCV,MAAM,CAACW,EAAE,CAAC,aAAa,EAAE,MAAMV,OAAO,IAAI,CAAC;AAC7C,IAAA;IACAW,YAAY,CAAC,MACX,CAACb,OAAO,CAACc,KAAK,IAAId,OAAO,CAACc,KAAK,EAAE,KAAK,KAAK,GAAGX,KAAK,EAAE,GAAGD,OAAO,IACjE,CAAC;EACH,CAAC;AACH;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FlowComponent } from "solid-js";
|
|
1
|
+
import { FlowComponent, Component } from "solid-js";
|
|
2
2
|
import { KeenSliderOptions, KeenSliderPlugin } from "keen-slider";
|
|
3
3
|
interface Func<T> {
|
|
4
4
|
([...args]: any, args2?: any): T;
|
|
@@ -17,15 +17,15 @@ export declare const SliderContext: import("solid-js").Context<import("solid-js"
|
|
|
17
17
|
/**
|
|
18
18
|
* A helpful and simple Provider to wrap your Slider if controls such as SliderButton are used.
|
|
19
19
|
*
|
|
20
|
-
* @param props
|
|
21
|
-
* @param props
|
|
20
|
+
* @param props.options - Accepts all KeenSlider options.
|
|
21
|
+
* @param props.plugins - A list of Solid Slider or Keen slider plugins.
|
|
22
22
|
*/
|
|
23
23
|
export declare const SliderProvider: FlowComponent;
|
|
24
24
|
/**
|
|
25
25
|
* Main Slider component for specifying the Slider on the page.
|
|
26
26
|
*
|
|
27
|
-
* @param props
|
|
28
|
-
* @param props
|
|
27
|
+
* @param props.options - Accepts all KeenSlider options.
|
|
28
|
+
* @param props.plugins - A list of Solid Slider or Keen slider plugins.
|
|
29
29
|
*/
|
|
30
30
|
export declare const Slider: FlowComponent<{
|
|
31
31
|
options?: KeenSliderOptions;
|
|
@@ -34,10 +34,10 @@ export declare const Slider: FlowComponent<{
|
|
|
34
34
|
/**
|
|
35
35
|
* Provides a helpful button with next/prev to pair with your slider.
|
|
36
36
|
*
|
|
37
|
-
* @param props
|
|
38
|
-
* @param props
|
|
39
|
-
* @param props
|
|
40
|
-
* @param props
|
|
37
|
+
* @param props.next - Specify if this should be a next button.
|
|
38
|
+
* @param props.prev - Specify if this should be a prev button.
|
|
39
|
+
* @param props.class - Class to override the button.
|
|
40
|
+
* @param props.classList - List of classes to override the button.
|
|
41
41
|
*/
|
|
42
42
|
export declare const SliderButton: FlowComponent<{
|
|
43
43
|
next?: boolean;
|
|
@@ -48,4 +48,69 @@ export declare const SliderButton: FlowComponent<{
|
|
|
48
48
|
[k: string]: boolean | undefined;
|
|
49
49
|
};
|
|
50
50
|
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Navigation dots component for the slider.
|
|
53
|
+
* Displays a dot for each slide and highlights the current slide.
|
|
54
|
+
*
|
|
55
|
+
* @param props.class - Class to override the dots container.
|
|
56
|
+
* @param props.classList - List of classes to override the dots container.
|
|
57
|
+
* @param props.dotClass - Class to override individual dots.
|
|
58
|
+
* @param props.dotClassList - List of classes to override individual dots.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```tsx
|
|
62
|
+
* <SliderProvider>
|
|
63
|
+
* <Slider>
|
|
64
|
+
* <div class="keen-slider__slide">Slide 1</div>
|
|
65
|
+
* <div class="keen-slider__slide">Slide 2</div>
|
|
66
|
+
* </Slider>
|
|
67
|
+
* <SliderDots />
|
|
68
|
+
* </SliderProvider>
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare const SliderDots: Component<{
|
|
72
|
+
class?: string;
|
|
73
|
+
classList?: {
|
|
74
|
+
[k: string]: boolean | undefined;
|
|
75
|
+
};
|
|
76
|
+
dotClass?: string;
|
|
77
|
+
dotClassList?: {
|
|
78
|
+
[k: string]: boolean | undefined;
|
|
79
|
+
};
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Thumbnail navigation component for the slider.
|
|
83
|
+
* A second Slider that synchronizes with the main slider.
|
|
84
|
+
* User provides thumbnail slides as children.
|
|
85
|
+
*
|
|
86
|
+
* @param props.options - Options for the thumbnail slider.
|
|
87
|
+
* @param props.plugins - Plugins for the thumbnail slider.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```tsx
|
|
91
|
+
* <SliderProvider>
|
|
92
|
+
* <Slider options={{ loop: true }}>
|
|
93
|
+
* <div class="keen-slider__slide">
|
|
94
|
+
* <img src="slide1.jpg" alt="Slide 1" />
|
|
95
|
+
* </div>
|
|
96
|
+
* <div class="keen-slider__slide">
|
|
97
|
+
* <img src="slide2.jpg" alt="Slide 2" />
|
|
98
|
+
* </div>
|
|
99
|
+
* </Slider>
|
|
100
|
+
* <SliderThumbnails options={{ slides: { perView: 4, spacing: 10 } }}>
|
|
101
|
+
* <div class="keen-slider__slide">
|
|
102
|
+
* <img src="thumb1.jpg" alt="Thumbnail 1" />
|
|
103
|
+
* </div>
|
|
104
|
+
* <div class="keen-slider__slide">
|
|
105
|
+
* <img src="thumb2.jpg" alt="Thumbnail 2" />
|
|
106
|
+
* </div>
|
|
107
|
+
* </SliderThumbnails>
|
|
108
|
+
* </SliderProvider>
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare const SliderThumbnails: FlowComponent<{
|
|
112
|
+
options?: KeenSliderOptions;
|
|
113
|
+
plugins?: KeenSliderPlugin[];
|
|
114
|
+
activeClass?: string;
|
|
115
|
+
}>;
|
|
51
116
|
export {};
|