slickless 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 yfxie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ <div align="center">
2
+
3
+ # slickless
4
+
5
+ A jQuery-free rewrite of slick. Same option names, no runtime dependencies, ~8 KB gzipped.
6
+
7
+ [![npm](https://img.shields.io/npm/v/slickless.svg)](https://www.npmjs.com/package/slickless)
8
+ [![bundle](https://img.shields.io/bundlephobia/minzip/slickless)](https://bundlephobia.com/package/slickless)
9
+ [![license](https://img.shields.io/npm/l/slickless.svg)](./LICENSE)
10
+
11
+ [Live demo, options, API, recipes →](https://yfxie.github.io/slickless/)
12
+
13
+ 📖 Languages: **English** · [繁體中文](./README.zh-TW.md)
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ ## Why
20
+
21
+ Slick is the most-installed carousel of the jQuery era. The behaviour still holds up, but pulling jQuery into a modern bundle just for one widget no longer does.
22
+
23
+ | | slick | slickless |
24
+ |---|---|---|
25
+ | Dependencies | jQuery | none |
26
+ | Type declarations | community | shipped |
27
+ | Touch + mouse + pen | separate code paths | unified Pointer Events |
28
+ | Resize handling | `window.resize` | `ResizeObserver` |
29
+ | Reduced-motion respect | manual | built-in |
30
+ | ARIA roles | partial | full carousel pattern |
31
+ | Gzipped (core + CSS) | ~11 kB + jQuery (~24–30 kB) | ~8 kB, no deps |
32
+
33
+ Most option names carry straight over: `slidesToShow`, `infinite`, `fade`, `centerMode`, `asNavFor`, `customPaging`, `responsive`. The DOM uses BEM class names (`.slickless__track`, `.slickless__slide`, …) and you construct with `new Slickless(el, options)`. So it's a rename pass, not a drop-in.
34
+
35
+ ## Install
36
+
37
+ ```bash
38
+ bun add slickless
39
+ # or
40
+ pnpm add slickless
41
+ # or
42
+ npm install slickless
43
+ ```
44
+
45
+ ## Use
46
+
47
+ ```js
48
+ import { Slickless } from "slickless";
49
+ import "slickless/style.css";
50
+
51
+ const carousel = new Slickless("#my-carousel", {
52
+ slidesToShow: 3,
53
+ dots: true,
54
+ autoplay: true,
55
+ });
56
+
57
+ carousel.on("afterChange", ({ currentSlide }) => {
58
+ console.log("now on", currentSlide);
59
+ });
60
+ ```
61
+
62
+ ```html
63
+ <div id="my-carousel">
64
+ <div>Slide 1</div>
65
+ <div>Slide 2</div>
66
+ <div>Slide 3</div>
67
+ </div>
68
+ ```
69
+
70
+ Each direct child becomes a slide. Add `data-lazy="…"` on `<img>` to defer image loads.
71
+
72
+ ## Documentation
73
+
74
+ Options, API, events and styling recipes live on the demo:
75
+
76
+ **[yfxie.github.io/slickless](https://yfxie.github.io/slickless/)**
77
+
78
+ ## Browser support
79
+
80
+ Modern evergreen browsers (Chrome, Edge, Firefox, Safari ≥ 14). Pointer Events, `ResizeObserver` and CSS custom properties are required.
81
+
82
+ ## Development
83
+
84
+ ```bash
85
+ bun install
86
+ bun run dev # demo dev server
87
+ bun run test # vitest
88
+ bun run build # library bundle + d.ts
89
+ bun run build:demo # demo build → demo-dist/
90
+ ```
91
+
92
+ ## License
93
+
94
+ [MIT](./LICENSE)
@@ -0,0 +1,94 @@
1
+ <div align="center">
2
+
3
+ # slickless
4
+
5
+ slick carousel 拿掉 jQuery 的重寫版。選項名稱不變,零執行期依賴,gzip 約 8 KB。
6
+
7
+ [![npm](https://img.shields.io/npm/v/slickless.svg)](https://www.npmjs.com/package/slickless)
8
+ [![bundle](https://img.shields.io/bundlephobia/minzip/slickless)](https://bundlephobia.com/package/slickless)
9
+ [![license](https://img.shields.io/npm/l/slickless.svg)](./LICENSE)
10
+
11
+ [線上範例、選項、API、樣式技巧 →](https://yfxie.github.io/slickless/)
12
+
13
+ 📖 語言:[English](./README.md) · **繁體中文**
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ ## 為什麼
20
+
21
+ slick 是 jQuery 時代裝機量最高的 carousel,行為到現在還很扎實。但為了一個 carousel 把 jQuery 拉進現代 bundle 已經說不過去了。
22
+
23
+ | | slick | slickless |
24
+ |---|---|---|
25
+ | 依賴 | jQuery | 無 |
26
+ | 型別宣告 | 社群提供 | 內建 |
27
+ | 觸控 + 滑鼠 + 觸控筆 | 各自處理 | 統一 Pointer Events |
28
+ | Resize 處理 | `window.resize` | `ResizeObserver` |
29
+ | 減少動態尊重 | 手動 | 內建 |
30
+ | ARIA 角色 | 部分 | 完整 carousel pattern |
31
+ | Gzip 後(核心 + CSS) | ~11 kB + jQuery(~24–30 kB) | ~8 kB,零依賴 |
32
+
33
+ 大多數選項名稱完全沿用:`slidesToShow`、`infinite`、`fade`、`centerMode`、`asNavFor`、`customPaging`、`responsive`。DOM 採 BEM 命名(`.slickless__track`、`.slickless__slide` 等),初始化用 `new Slickless(el, options)`。所以遷移主要是改名工作,不是直接替換。
34
+
35
+ ## 安裝
36
+
37
+ ```bash
38
+ bun add slickless
39
+ # 或
40
+ pnpm add slickless
41
+ # 或
42
+ npm install slickless
43
+ ```
44
+
45
+ ## 使用
46
+
47
+ ```js
48
+ import { Slickless } from "slickless";
49
+ import "slickless/style.css";
50
+
51
+ const carousel = new Slickless("#my-carousel", {
52
+ slidesToShow: 3,
53
+ dots: true,
54
+ autoplay: true,
55
+ });
56
+
57
+ carousel.on("afterChange", ({ currentSlide }) => {
58
+ console.log("目前在", currentSlide);
59
+ });
60
+ ```
61
+
62
+ ```html
63
+ <div id="my-carousel">
64
+ <div>Slide 1</div>
65
+ <div>Slide 2</div>
66
+ <div>Slide 3</div>
67
+ </div>
68
+ ```
69
+
70
+ 每個直接子元素都會成為一張 slide。`<img>` 上加 `data-lazy="…"` 可延後圖片載入。
71
+
72
+ ## 完整文件
73
+
74
+ 選項、API、事件、樣式技巧都在線上 demo:
75
+
76
+ **[yfxie.github.io/slickless](https://yfxie.github.io/slickless/)**
77
+
78
+ ## 瀏覽器支援
79
+
80
+ 主流瀏覽器(Chrome、Edge、Firefox、Safari ≥ 14)。需要 Pointer Events、`ResizeObserver`、CSS Custom Properties。
81
+
82
+ ## 開發
83
+
84
+ ```bash
85
+ bun install
86
+ bun run dev # demo 開發伺服器
87
+ bun run test # vitest 測試
88
+ bun run build # 函式庫建置 + d.ts
89
+ bun run build:demo # demo 建置 → demo-dist/
90
+ ```
91
+
92
+ ## 授權
93
+
94
+ [MIT](./LICENSE)
@@ -0,0 +1,3 @@
1
+ import type { SlicklessOptions } from "./types";
2
+ export declare const DEFAULTS: SlicklessOptions;
3
+ export declare function mergeOptions(base: SlicklessOptions, override: Partial<SlicklessOptions>): SlicklessOptions;
@@ -0,0 +1,9 @@
1
+ import "./styles.css";
2
+ export { Slickless } from "./slickless";
3
+ export { DEFAULTS } from "./defaults";
4
+ export type { SlicklessOptions, ResponsiveBreakpoint, SlicklessEvent, BeforeChangeDetail, AfterChangeDetail, SwipeDetail, EdgeDetail, BreakpointDetail, LazyLoadDetail, Direction, } from "./types";
5
+ import { Slickless as _Slickless } from "./slickless";
6
+ import type { SlicklessOptions } from "./types";
7
+ /** Functional helper — creates a Slickless instance. */
8
+ export declare function slickless(root: string | HTMLElement, options?: Partial<SlicklessOptions>): _Slickless;
9
+ export default _Slickless;
@@ -0,0 +1,2 @@
1
+ .slickless{--slickless-arrow-size:44px;--slickless-arrow-color:#0f172a;--slickless-arrow-bg:#fff;--slickless-arrow-bg-hover:#f8fafc;--slickless-arrow-shadow:0 4px 16px -2px #0f172a29, 0 2px 4px -1px #0f172a14;--slickless-arrow-disabled-opacity:.3;--slickless-dot-size:8px;--slickless-dot-color:#0f172a40;--slickless-dot-color-active:#0f172a;--slickless-dot-gap:10px;--slickless-focus-ring:0 0 0 3px #6366f173;box-sizing:border-box;outline:none;min-width:0;position:relative}.slickless *,.slickless :before,.slickless :after{box-sizing:border-box}.slickless:not(.slickless--initialized)>:not(:first-child){display:none}.slickless:focus-visible{box-shadow:var(--slickless-focus-ring);border-radius:4px}.slickless__viewport{touch-action:pan-y;width:100%;min-width:0;position:relative;overflow:hidden}.slickless--vertical .slickless__viewport{touch-action:pan-x;height:100%;min-height:0}.slickless--fade .slickless__viewport{min-height:1px}.slickless__track{will-change:transform;width:100%;min-width:0;display:flex}.slickless--vertical .slickless__track{flex-direction:column;height:100%;min-height:0}.slickless--adaptive-height .slickless__track{align-items:flex-start}.slickless--fade .slickless__track{height:100%;display:block;position:relative}.slickless--dragging .slickless__track{cursor:grabbing}.slickless__slide{-webkit-user-select:none;user-select:none;-webkit-user-drag:none;outline:none;flex:none;position:relative}.slickless__slide>*{width:100%;height:100%}.slickless--fade .slickless__slide{width:100%;position:absolute;top:0;left:0}.slickless__slide:focus-visible{box-shadow:var(--slickless-focus-ring);border-radius:4px}.slickless__arrow{z-index:5;width:var(--slickless-arrow-size);height:var(--slickless-arrow-size);background:var(--slickless-arrow-bg);color:var(--slickless-arrow-color);box-shadow:var(--slickless-arrow-shadow);cursor:pointer;border:0;border-radius:999px;justify-content:center;align-items:center;padding:0;transition:background-color .16s,transform .16s,opacity .16s;display:inline-flex;position:absolute;top:50%;transform:translateY(-50%)}.slickless__arrow:hover{background:var(--slickless-arrow-bg-hover)}.slickless__arrow:active{transform:translateY(-50%)scale(.94)}.slickless__arrow:focus-visible{box-shadow:var(--slickless-arrow-shadow), var(--slickless-focus-ring)}.slickless__arrow--prev{left:12px}.slickless__arrow--next{right:12px}.slickless--rtl .slickless__arrow--prev{left:auto;right:12px}.slickless--rtl .slickless__arrow--next{left:12px;right:auto}.slickless--vertical .slickless__arrow{top:auto;left:50%;transform:translate(-50%)rotate(90deg)}.slickless--vertical .slickless__arrow--prev{top:12px}.slickless--vertical .slickless__arrow--next{bottom:12px;right:auto}.slickless__arrow svg{width:22px;height:22px}.slickless__arrow--disabled{opacity:var(--slickless-arrow-disabled-opacity);cursor:not-allowed}.slickless__arrow--disabled:hover{background:var(--slickless-arrow-bg)}.slickless__dots{justify-content:center;align-items:center;gap:var(--slickless-dot-gap);margin:16px 0 0;padding:0;list-style:none;display:flex}.slickless__dots li{display:inline-flex}.slickless__dot{cursor:pointer}.slickless__dot:focus-visible{box-shadow:var(--slickless-focus-ring)}.slickless__dot--bullet{width:var(--slickless-dot-size);height:var(--slickless-dot-size);background:var(--slickless-dot-color);color:#0000;border:0;border-radius:999px;padding:0;font-size:0;transition:background-color .2s,width .2s}.slickless__dot--bullet:hover{background:var(--slickless-dot-color-active);opacity:.7}.slickless__dot--bullet.slickless__dot--active{background:var(--slickless-dot-color-active);width:calc(var(--slickless-dot-size) * 3);border-radius:999px}.slickless--center .slickless__slide{transition:opacity var(--slickless-transition-duration,.4s) ease, transform var(--slickless-transition-duration,.4s) ease;opacity:.55;transform:scale(.92)}.slickless--center .slickless__slide--center{opacity:1;transform:scale(1)}.slickless--snap .slickless__slide,.slickless--snap .slickless__track{transition:none!important}@media (prefers-reduced-motion:reduce){.slickless__track,.slickless__slide,.slickless__arrow,.slickless__dot{transition-duration:.01ms!important}}
2
+ /*$vite$:1*/
@@ -0,0 +1,107 @@
1
+ import type { SlicklessOptions } from "./types";
2
+ export declare class Slickless {
3
+ readonly root: HTMLElement;
4
+ private userOptions;
5
+ options: SlicklessOptions;
6
+ private originalChildren;
7
+ private slides;
8
+ private track;
9
+ private viewport;
10
+ private prevArrow;
11
+ private nextArrow;
12
+ private dotsList;
13
+ private cloneCount;
14
+ private currentIndex;
15
+ /** Track index we are animating toward. Lets layout reads use the future
16
+ * slide for height-syncing while the transform is still in flight. */
17
+ private animatingTo;
18
+ private slideCount;
19
+ private animating;
20
+ /** Last observed root width — used to ignore height-only ResizeObserver
21
+ * fires (e.g. when adaptiveHeight changes the viewport height). */
22
+ private lastRootWidth;
23
+ private destroyed;
24
+ private currentBreakpoint;
25
+ private resizeObserver;
26
+ private autoplayTimer;
27
+ private autoplayPaused;
28
+ private listeners;
29
+ private pointer;
30
+ private pointerHandlers;
31
+ private linkedNav;
32
+ private linkedFromExternal;
33
+ constructor(root: string | HTMLElement, options?: Partial<SlicklessOptions>);
34
+ private init;
35
+ destroy(): void;
36
+ reInit(): void;
37
+ private captureChildren;
38
+ private applyResponsive;
39
+ private build;
40
+ private wrapAsSlide;
41
+ private cloneSlide;
42
+ private buildArrows;
43
+ private resolveArrow;
44
+ private buildDots;
45
+ private htmlToElement;
46
+ private viewportSize;
47
+ private slideSize;
48
+ /**
49
+ * Resolve `centerPadding` (e.g. "50px" or "10%") to a pixel value based on
50
+ * the current viewport size. Negative or unparseable values fall back to 0.
51
+ */
52
+ private parseCenterPadding;
53
+ private applyLayout;
54
+ private effectiveSpeed;
55
+ private indexToOffset;
56
+ private translateTo;
57
+ next(): void;
58
+ prev(): void;
59
+ goTo(index: number, immediate?: boolean): void;
60
+ play(): void;
61
+ pause(): void;
62
+ private scheduleAutoplay;
63
+ on<T = unknown>(event: string, handler: (detail: T) => void): () => void;
64
+ off(event: string, handler: (detail: unknown) => void): void;
65
+ private emit;
66
+ private handlePrevClick;
67
+ private handleNextClick;
68
+ private handleResize;
69
+ private handleKey;
70
+ private handleMouseEnter;
71
+ private handleMouseLeave;
72
+ private handleFocusIn;
73
+ private handleFocusOut;
74
+ private bindEvents;
75
+ private unbindEvents;
76
+ private bindPointerEvents;
77
+ private unbindPointerEvents;
78
+ private parseTranslate;
79
+ private bindFocusOnSelect;
80
+ private realToTrackIndex;
81
+ private updateAria;
82
+ private suppressSlideTransitionsForOneFrame;
83
+ private updateCenterMode;
84
+ private isSlideInActiveRange;
85
+ private updateArrows;
86
+ private pageCount;
87
+ private updateDots;
88
+ private updateAdaptiveHeight;
89
+ private applyLazyLoad;
90
+ private loadImagesIn;
91
+ private activateLazyImage;
92
+ private linkAsNavFor;
93
+ private notifyLinked;
94
+ getCurrentSlide(): number;
95
+ getSlideCount(): number;
96
+ getSlides(): HTMLElement[];
97
+ setOptions(options: Partial<SlicklessOptions>, refresh?: boolean): void;
98
+ /**
99
+ * Recompute slide widths and re-position the track using the currently
100
+ * stored options. Cheaper than `reInit` — no DOM teardown, no rebuild — and
101
+ * suitable for live tweaks like dragging a slider that updates layout-only
102
+ * options (e.g. `centerPadding`, `slidesToScroll`, `cssEase`).
103
+ */
104
+ refresh(): void;
105
+ addSlide(element: HTMLElement, index?: number): void;
106
+ removeSlide(index: number): void;
107
+ }