@twistedandy/better-carousel 1.1.1 → 1.1.2

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 CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  <p>A small, fast and accessible JavaScript carousel.<br />The CSS sets the layout, and the motion runs on the compositor, also on slow phones.</p>
6
6
 
7
- [![Gzip size](https://flat.badgen.net/static/gzip/12.4%20KB/green)](dist/better-carousel.min.js)
7
+ [![Gzip size](https://flat.badgen.net/static/gzip/12.6%20KB/green)](dist/better-carousel.min.js)
8
8
  [![MIT license](https://flat.badgen.net/static/license/MIT/purple)](LICENSE)
9
9
  [![No dependencies](https://flat.badgen.net/static/dependencies/0/blue)](package.json)
10
10
 
@@ -16,7 +16,7 @@
16
16
 
17
17
  - **Layout from CSS** - Your CSS sets the sizes of the slides, the space between them, the axis and the alignment. One carousel can show 1 slide on a phone and 4 slides on a desktop.
18
18
  - **Smooth** - Each motion is a Web Animations API animation of `translate`. No script runs on each frame, also during the auto scroll.
19
- - **Small** - <!-- generated:gzip -->12.4 KB<!-- /generated --> gzip with loop, autoplay, auto scroll, auto height, sync and the mouse wheel.
19
+ - **Small** - <!-- generated:gzip -->12.6 KB<!-- /generated --> gzip with loop, autoplay, auto scroll, auto height, sync and the mouse wheel.
20
20
  - **Loop** - The loop moves the original slides. It adds clones only if the slides are too few.
21
21
  - **Vertical and grid** - A column layout makes a vertical carousel. A CSS grid with more rows also works.
22
22
  - **Accessible** - WCAG 2.1 AA: names for the carousel, the slides and the buttons, the keyboard focus, a live region and reduced motion.
@@ -29,13 +29,13 @@ Load the minified script and the stylesheet from jsDelivr. The script adds the g
29
29
  ```html
30
30
  <link
31
31
  rel="stylesheet"
32
- href="https://cdn.jsdelivr.net/gh/TwistedAndy/better-carousel@v1.1.1/dist/better-carousel.css"
33
- integrity="sha384-3ROtqpAC1ZPhSpDul73SGiTOv1L5kTr/08sUr6FPY6S79RIDi7mpI22ttbuxI/w8"
32
+ href="https://cdn.jsdelivr.net/gh/TwistedAndy/better-carousel@v1.1.2/dist/better-carousel.css"
33
+ integrity="sha384-WH4VE2eTsNlsGXmOFkXZ+1tAsP2NEOB318/Byze8PAwaRtrgx+ZBmXaRIMLL9Cdq"
34
34
  crossorigin="anonymous"
35
35
  />
36
36
  <script
37
- src="https://cdn.jsdelivr.net/gh/TwistedAndy/better-carousel@v1.1.1/dist/better-carousel.min.js"
38
- integrity="sha384-iAm/5iXDxHA5oHmRJqH1xjWnZzqQsmfklYM5v0iVGvJx/3cWrzFZ67xjIHyTVIz1"
37
+ src="https://cdn.jsdelivr.net/gh/TwistedAndy/better-carousel@v1.1.2/dist/better-carousel.min.js"
38
+ integrity="sha384-h0ZLTfuVtmQW35SwAzeU1mNp4DQqHyJDBrmuKXU7953wMh0AKZj1vCFv3XcJg+Dw"
39
39
  crossorigin="anonymous"
40
40
  ></script>
41
41
  ```
@@ -152,10 +152,12 @@ The library does not set the size of the slides or the space between them. It re
152
152
  | `direction: rtl` | A right-to-left carousel |
153
153
  | The padding of the viewport | The snaps align to the inner edge of the padding. The padding shows parts of the slides next to the selected slide. |
154
154
 
155
- The carousel measures again when the CSS changes, when the page adds or removes a slide, and when an image loads. A slide with `display: none` gets no snap. The `template`, `script` and `style` elements in the container are not slides. A CSS `scale` or `rotate` on a parent, such as the open animation of a modal window, does not change the snaps. To add or remove a slide, change the elements in the container.
155
+ The carousel measures again when the CSS changes, when the page adds or removes a slide, and when an image loads. A slide with `display: none` gets no snap. The `template`, `script` and `style` elements in the container are not slides. A CSS `scale` or `zoom` on a parent, such as the open animation of a modal window, does not change the snaps. To add or remove a slide, change the elements in the container.
156
156
 
157
157
  A carousel can start in a hidden element, such as a tab, an accordion or a modal window. It has no size, so it shows no arrows and no dots. When the element shows, the carousel measures and starts to move.
158
158
 
159
+ A horizontal carousel gets its width from its parent, not from its slides, so it does not overflow a flex item or a grid column. For this reason, a parent that gets its width from its content, such as an `inline-block` element or a flex item with no `flex` value, must have a width.
160
+
159
161
  ## Frameworks
160
162
 
161
163
  1. Render the root and the viewport in the component.
@@ -354,8 +356,8 @@ BetterCarousel(element, {
354
356
  | `duration` | `number` | `400` | The duration of a motion by one snap, in ms. A longer motion takes more time, to a maximum of 2 times this value. ([example](https://twistedandy.github.io/better-carousel/#options-usage)) |
355
357
  | `startSnap` | `number` | `0` | The index of the snap at the start. ([example](https://twistedandy.github.io/better-carousel/#options-usage)) |
356
358
  | `lazy` | `boolean`, `number` | `false` | `true`: start when the carousel comes within one screen of the view. A number: the distance in px. ([example](https://twistedandy.github.io/better-carousel/#lazy)) |
357
- | `drag` | `boolean` | `true` | Drag with the mouse, the pen and the finger. |
358
- | `wheel` | `boolean`, `'both'` | `true` | The mouse wheel moves a vertical carousel. `'both'`: also a horizontal carousel. `false`: the wheel does not move the carousel. ([example](https://twistedandy.github.io/better-carousel/#vertical)) |
359
+ | `drag` | `boolean` | `true` | Drag with the mouse, the pen and the finger. A press on a form field does not start a drag. To keep the drag off another element, such as a map in a slide, stop the propagation of its `pointerdown` event. |
360
+ | `wheel` | `boolean`, `'axis'`, `'both'` | `true` | The mouse wheel moves a vertical carousel. `'axis'`: also a horizontal carousel, but only with a horizontal wheel motion, such as a trackpad swipe. A vertical wheel scrolls the page. `'both'`: also a horizontal carousel, with all wheel motions. `false`: the wheel does not move the carousel. ([example](https://twistedandy.github.io/better-carousel/#vertical)) |
359
361
  | `keys` | `boolean` | `true` | The arrow keys move the carousel while the keyboard focus is in it: left and right in a horizontal carousel, up and down in a vertical carousel. A key in a form field does not move the carousel. |
360
362
  | `resize` | `boolean` | `true` | Measure again when a size changes. ([example](https://twistedandy.github.io/better-carousel/#options-usage)) |
361
363
  | `slideChanges` | `boolean` | `true` | Measure again when the page adds or removes a slide. ([example](https://twistedandy.github.io/better-carousel/#changes)) |
@@ -369,7 +371,7 @@ BetterCarousel(element, {
369
371
  | `arrows` | `boolean`, `Element`, `string` | `true` | Add the arrows to the root. `false`: no arrows. An element or a selector: add the arrows to that element. ([example](https://twistedandy.github.io/better-carousel/#heading)) |
370
372
  | `dots` | `boolean`, `Element`, `string` | `true` | Add the dots. The values are the same as for `arrows`. ([example](https://twistedandy.github.io/better-carousel/#heading)) |
371
373
  | `dotsStyle` | `'zoom'`, `'all'` | `'zoom'` | The style of the dots. `'zoom'`: a window of 5 dots that slides, with smaller dots at the ends. `'all'`: all dots with the same size. |
372
- | `labels` | `object` | English | The texts for screen readers: `carousel`, `slide` (`'%d of %n'`), `prev`, `next`, `dot` (`'Go to slide %d'`), `play`, `pause`. `%d` is the slide number, and `%n` is the number of slides. ([example](#accessibility)) |
374
+ | `labels` | `object` | English | The texts for screen readers: `carousel`, `slide` (`'%d of %n'`), `prev`, `next`, `dot` (`'Go to slide %d'`), `play`, `pause`. `%d` is the slide number, and `%n` is the number of slides. An empty text adds no name. ([example](#accessibility)) |
373
375
  | `classes` | `string`, `object` | `null` | A class prefix such as `'embla'`, or an object with the names to change. The [Classes](#classes) table gives all names. ([example](https://twistedandy.github.io/better-carousel/#embla)) |
374
376
  | `state` | `string` | `''` | The prefix of the state classes, such as `'is_'`. ([example](https://twistedandy.github.io/better-carousel/#embla)) |
375
377
  | `sync` | carousel, `Element`, `string` | `null` | Another carousel, its container or a selector. This carousel follows the selected slide of the other carousel. A click on a slide selects it in the other carousel. ([example](https://twistedandy.github.io/better-carousel/#product)) |
@@ -691,7 +693,7 @@ The carousel follows the carousel pattern of the WAI-ARIA Authoring Practices an
691
693
  - The arrows and the dots are buttons with names. A screen reader reads each new slide (`aria-live`), but not during the autoplay.
692
694
  - Tab moves the focus through the links and the fields in the slides. The carousel moves to show the focused element.
693
695
  - While the focus is in the carousel, the arrow keys go to the previous and the next slide. To turn them off, set `keys: false`.
694
- - Clones are `inert` and hidden from screen readers.
696
+ - Clones are `inert` and hidden from screen readers. A click on a link or a button in a clone goes to the same element in its slide. The form fields in clones have no name, so the form sends only the fields of the slides.
695
697
  - The autoplay and the auto scroll have a play and pause button (WCAG 2.2.2). The keyboard focus pauses them. If the user prefers reduced motion, they do not start.
696
698
  - A drag across the axis scrolls the page. A link opens on a click, but not after a drag.
697
699
 
@@ -718,9 +720,9 @@ The library is made for slow phones. A motion runs on the compositor, and a caro
718
720
  <!-- generated:sizes -->
719
721
  | File | Minified | Gzip | Brotli |
720
722
  | --- | --- | --- | --- |
721
- | `better-carousel.min.js` | 30.3 KB | 12.4 KB | 11.4 KB |
722
- | `better-carousel.css` | 4.7 KB | 1.3 KB | 1.1 KB |
723
- | Total | 35.0 KB | 13.8 KB | 12.5 KB |
723
+ | `better-carousel.min.js` | 30.6 KB | 12.6 KB | 11.5 KB |
724
+ | `better-carousel.css` | 4.8 KB | 1.4 KB | 1.2 KB |
725
+ | Total | 35.3 KB | 13.9 KB | 12.7 KB |
724
726
  <!-- /generated -->
725
727
 
726
728
  The [Comparison](#comparison) section gives the sizes and the runtime costs of other carousel libraries.
@@ -1 +1 @@
1
- .better{display:block;position:relative}.better.dragging{cursor:grabbing}.better_viewport{position:relative;overflow:hidden;width:100%;margin:0;z-index:1}.better_horizontal .better_container{overflow:visible;--gap-grid-y: 0px}.better_vertical .better_viewport{height:100%}.better_vertical .better_container{overflow:visible;height:calc(100% + var(--gap-grid-y, 0px));margin-bottom:calc(-1*var(--gap-grid-y, 0px));--gap-grid-x: 0px}.better_auto_height .better_viewport{transition:height .3s}.better_auto_height .better_container{align-items:flex-start}.better_button{display:block;position:absolute;bottom:0;inset-inline-end:0;width:var(--height-button);height:var(--height-button);padding:0;border:1px solid var(--button-border, #222);border-radius:var(--radius-regular, 10px);background-color:var(--button-base, #222);color:var(--button-text, #fff);transition:.2s;cursor:pointer;z-index:5;--height-button: 2.5rem}.better_button:focus-visible{outline:2px solid var(--button-border-active, #000);outline-offset:2px}.better_button:before{content:"";display:block;position:absolute;top:50%;left:50%;width:.5rem;height:.75rem;margin:-0.375rem 0 0 -0.25rem;background-color:currentColor;-webkit-mask:var(--button-arrow, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 12'%3E%3Cpath d='m1 1 5 5-5 5' fill='none' stroke='black' stroke-width='1.5'/%3E%3C/svg%3E")) 50% 50% no-repeat;mask:var(--button-arrow, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 12'%3E%3Cpath d='m1 1 5 5-5 5' fill='none' stroke='black' stroke-width='1.5'/%3E%3C/svg%3E")) 50% 50% no-repeat}@media(hover: hover){.better_button:hover{border-color:var(--button-border-active, #000);background-color:var(--button-base-active, #000);color:var(--button-text-active, #fff)}}.better_button:disabled{border-color:var(--button-border-disabled, #eee);background-color:var(--button-base-disabled, #eee);color:var(--button-text-disabled, #aaa);cursor:default}.better_prev{inset-inline-start:0;inset-inline-end:auto}.better_prev:dir(ltr):before,.better_next:dir(rtl):before{transform:scaleX(-1)}.better_play{inset-inline-start:calc(var(--height-button) + .5rem);inset-inline-end:auto}.better_play:before{width:.625rem;margin-left:-0.3125rem;-webkit-mask:none;mask:none;clip-path:polygon(0 0, 100% 50%, 0 100%)}.better.playing .better_play:before{background:linear-gradient(90deg, currentColor 35%, transparent 35% 65%, currentColor 65%);clip-path:none}.better_dots{display:flex;position:relative;align-items:center;width:7.5rem;height:var(--height-button);margin:var(--gap-grid-y, 20px) auto 0;overflow:hidden;z-index:3;--height-button: 2.5rem}.better_dot{display:flex;flex:none;align-items:center;justify-content:center;width:1.5rem;height:1.5rem;padding:0;border:0;border-radius:50%;background:none;color:var(--button-text-disabled, #767676);transition:color .2s;cursor:pointer}.better_dot:focus-visible{outline:2px solid var(--button-border-active, #000);outline-offset:-2px}.better_dot:before{content:"";display:block;width:.875rem;height:.875rem;border-radius:50%;background:currentColor;transform:scale(0)}.better_dot.last:before,.better_dot.first:before{transform:scale(0.333)}.better_dot.prev:before,.better_dot.next:before{transform:scale(0.666)}.better_dot.current:before{transform:scale(1)}@media(hover: hover){.better_dot:hover{color:var(--button-base-active, #000)}}.better_dots_track{display:flex;position:relative;flex:none;translate:calc(var(--better-shift, 0)*1.5rem);transition:translate .4s}.better_dots_track:dir(rtl){translate:calc(var(--better-shift, 0)*-1.5rem)}.better_dots_marker{position:absolute;z-index:1;top:.3125rem;inset-inline-start:.3125rem;width:.875rem;height:.875rem;border-radius:50%;background:var(--button-base, #222);translate:calc(var(--better-dot, 0)*1.5rem);transition:translate .4s;pointer-events:none}.better_dots_marker:dir(rtl){translate:calc(var(--better-dot, 0)*-1.5rem)}.better_dots.better_dots_all{width:max-content;max-width:100%}.better_dots.better_dots_all .better_dots_track{translate:none}.better_dots.better_dots_all .better_dot:before{transform:scale(0.666)}.better_vertical .better_button{top:auto;right:0;bottom:0;left:0;width:auto;height:30px;margin:0}.better_vertical .better_button:before{transform:rotate(90deg)}.better_vertical .better_prev{top:0;bottom:auto}.better_vertical .better_prev:before{transform:rotate(-90deg)}.better_vertical .better_dots{position:absolute;top:50%;right:0;flex-direction:column;width:var(--height-button);height:7.5rem;margin:0;transform:translateY(-50%)}.better_vertical .better_dots_track{flex-direction:column;translate:0 calc(var(--better-shift, 0)*1.5rem)}.better_vertical .better_dots_marker{translate:0 calc(var(--better-dot, 0)*1.5rem)}.better_vertical .better_dots_all{height:auto;max-height:100%}
1
+ .better{display:block;position:relative}.better.dragging{cursor:grabbing}.better_viewport{position:relative;overflow:hidden;width:100%;margin:0;z-index:1}.better_horizontal .better_viewport{contain:inline-size}.better_horizontal .better_container{overflow:visible;--gap-grid-y: 0px}.better_vertical .better_viewport{height:100%}.better_vertical .better_container{overflow:visible;height:calc(100% + var(--gap-grid-y, 0px));margin-bottom:calc(-1*var(--gap-grid-y, 0px));--gap-grid-x: 0px}.better_auto_height .better_viewport{transition:height .3s}.better_auto_height .better_container{align-items:flex-start}.better_button{display:block;position:absolute;bottom:0;inset-inline-end:0;width:var(--height-button);height:var(--height-button);padding:0;border:1px solid var(--button-border, #222);border-radius:var(--radius-regular, 10px);background-color:var(--button-base, #222);color:var(--button-text, #fff);transition:.2s;cursor:pointer;z-index:5;--height-button: 2.5rem}.better_button:focus-visible{outline:2px solid var(--button-border-active, #000);outline-offset:2px}.better_button:before{content:"";display:block;position:absolute;top:50%;left:50%;width:.5rem;height:.75rem;margin:-0.375rem 0 0 -0.25rem;background-color:currentColor;-webkit-mask:var(--button-arrow, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 12'%3E%3Cpath d='m1 1 5 5-5 5' fill='none' stroke='black' stroke-width='1.5'/%3E%3C/svg%3E")) 50% 50% no-repeat;mask:var(--button-arrow, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 12'%3E%3Cpath d='m1 1 5 5-5 5' fill='none' stroke='black' stroke-width='1.5'/%3E%3C/svg%3E")) 50% 50% no-repeat}@media(hover: hover){.better_button:hover{border-color:var(--button-border-active, #000);background-color:var(--button-base-active, #000);color:var(--button-text-active, #fff)}}.better_button:disabled{border-color:var(--button-border-disabled, #eee);background-color:var(--button-base-disabled, #eee);color:var(--button-text-disabled, #aaa);cursor:default}.better_prev{inset-inline-start:0;inset-inline-end:auto}.better_prev:dir(ltr):before,.better_next:dir(rtl):before{transform:scaleX(-1)}.better_play{inset-inline-start:calc(var(--height-button) + .5rem);inset-inline-end:auto}.better_play:before{width:.625rem;margin-left:-0.3125rem;-webkit-mask:none;mask:none;clip-path:polygon(0 0, 100% 50%, 0 100%)}.better.playing .better_play:before{background:linear-gradient(90deg, currentColor 35%, transparent 35% 65%, currentColor 65%);clip-path:none}.better_dots{display:flex;position:relative;align-items:center;width:7.5rem;height:var(--height-button);margin:var(--gap-grid-y, 20px) auto 0;overflow:hidden;z-index:3;--height-button: 2.5rem}.better_dot{display:flex;flex:none;align-items:center;justify-content:center;width:1.5rem;height:1.5rem;padding:0;border:0;border-radius:50%;background:none;color:var(--button-text-disabled, #767676);transition:color .2s;cursor:pointer}.better_dot:focus-visible{outline:2px solid var(--button-border-active, #000);outline-offset:-2px}.better_dot:before{content:"";display:block;width:.875rem;height:.875rem;border-radius:50%;background:currentColor;transform:scale(0)}.better_dot.last:before,.better_dot.first:before{transform:scale(0.333)}.better_dot.prev:before,.better_dot.next:before{transform:scale(0.666)}.better_dot.current:before{transform:scale(1)}@media(hover: hover){.better_dot:hover{color:var(--button-base-active, #000)}}.better_dots_track{display:flex;position:relative;flex:none;translate:calc(var(--better-shift, 0)*1.5rem);transition:translate .4s}.better_dots_track:dir(rtl){translate:calc(var(--better-shift, 0)*-1.5rem)}.better_dots_marker{position:absolute;z-index:1;top:.3125rem;inset-inline-start:.3125rem;width:.875rem;height:.875rem;border-radius:50%;background:var(--button-base, #222);translate:calc(var(--better-dot, 0)*1.5rem);transition:translate .4s;pointer-events:none}.better_dots_marker:dir(rtl){translate:calc(var(--better-dot, 0)*-1.5rem)}.better_dots.better_dots_all{width:max-content;max-width:100%}.better_dots.better_dots_all .better_dots_track{translate:none}.better_dots.better_dots_all .better_dot:before{transform:scale(0.666)}.better_vertical .better_button{top:auto;right:0;bottom:0;left:0;width:auto;height:30px;margin:0}.better_vertical .better_button:before{transform:rotate(90deg)}.better_vertical .better_prev{top:0;bottom:auto}.better_vertical .better_prev:before{transform:rotate(-90deg)}.better_vertical .better_dots{position:absolute;top:50%;right:0;flex-direction:column;width:var(--height-button);height:7.5rem;margin:0;transform:translateY(-50%)}.better_vertical .better_dots_track{flex-direction:column;translate:0 calc(var(--better-shift, 0)*1.5rem)}.better_vertical .better_dots_marker{translate:0 calc(var(--better-dot, 0)*1.5rem)}.better_vertical .better_dots_all{height:auto;max-height:100%}