peek-carousel 1.0.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/LICENSE +21 -0
- package/README.en.md +238 -0
- package/README.md +234 -0
- package/dist/peek-carousel.css +1 -0
- package/dist/peek-carousel.esm.js +1368 -0
- package/dist/peek-carousel.esm.js.map +1 -0
- package/dist/peek-carousel.esm.min.js +8 -0
- package/dist/peek-carousel.esm.min.js.map +1 -0
- package/dist/peek-carousel.js +1376 -0
- package/dist/peek-carousel.js.map +1 -0
- package/dist/peek-carousel.min.css +1 -0
- package/dist/peek-carousel.min.js +8 -0
- package/dist/peek-carousel.min.js.map +1 -0
- package/examples/example-built.html +367 -0
- package/examples/example.css +2216 -0
- package/examples/example.js +404 -0
- package/examples/example.min.css +1 -0
- package/examples/example.min.js +1 -0
- package/package.json +92 -0
- package/src/core/PeekCarousel.js +294 -0
- package/src/core/config.js +49 -0
- package/src/core/constants.js +73 -0
- package/src/modules/Animator.js +244 -0
- package/src/modules/AutoRotate.js +43 -0
- package/src/modules/EventHandler.js +390 -0
- package/src/modules/Navigator.js +116 -0
- package/src/modules/UIManager.js +170 -0
- package/src/peek-carousel.d.ts +34 -0
- package/src/styles/base/_accessibility.scss +16 -0
- package/src/styles/base/_mixins.scss +7 -0
- package/src/styles/base/_variables.scss +75 -0
- package/src/styles/components/_carousel.scss +5 -0
- package/src/styles/components/_counter.scss +109 -0
- package/src/styles/components/_indicators.scss +154 -0
- package/src/styles/components/_navigation.scss +193 -0
- package/src/styles/components/carousel/_carousel-base.scss +99 -0
- package/src/styles/components/carousel/_carousel-classic.scss +76 -0
- package/src/styles/components/carousel/_carousel-mixins.scss +18 -0
- package/src/styles/components/carousel/_carousel-radial.scss +72 -0
- package/src/styles/components/carousel/_carousel-stack.scss +84 -0
- package/src/styles/components/carousel/_carousel-variables.scss +118 -0
- package/src/styles/peek-carousel.scss +11 -0
- package/src/utils/dom.js +53 -0
- package/src/utils/helpers.js +46 -0
- package/src/utils/icons.js +92 -0
- package/src/utils/preloader.js +69 -0
- package/types/index.d.ts +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 PeekCarousel
|
|
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.en.md
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# PeekCarousel
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/peek-carousel)
|
|
4
|
+
[](https://www.npmjs.com/package/peek-carousel)
|
|
5
|
+
[](https://bundlephobia.com/package/peek-carousel)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
[](https://github.com/lledellebell/peek-carousel/stargazers)
|
|
9
|
+
[](https://github.com/lledellebell/peek-carousel/network/members)
|
|
10
|
+
[](https://github.com/lledellebell/peek-carousel/issues)
|
|
11
|
+
[](https://github.com/lledellebell/peek-carousel/commits)
|
|
12
|
+
[](https://github.com/lledellebell/peek-carousel)
|
|
13
|
+
|
|
14
|
+
[](https://developer.mozilla.org/en-US/docs/Web/JavaScript)
|
|
15
|
+
[](https://sass-lang.com/)
|
|
16
|
+
[](https://github.com/lledellebell/peek-carousel/packages)
|
|
17
|
+
|
|
18
|
+
A modular carousel library inspired by the swipe interaction on the iPhone 17 Pro product page. Features a 'peek effect' where the next/previous items are slightly visible on either side of the active item, providing intuitive navigation. Supports three layout modes (Stack/Card, Radial Rotation, Classic Slide) with smooth transitions, touch/drag support, and full accessibility.
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
**[Live Demo](https://lledellebell.github.io/peek-carousel/examples/example-built.html)**
|
|
23
|
+
|
|
24
|
+
> [한국어](./README.md)
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- **3 Layout Modes** - Stack/Card, Radial Rotation, Classic Slide
|
|
29
|
+
- **Full Interaction Support** - Touch/drag, keyboard, and mouse wheel navigation
|
|
30
|
+
- **Zero Dependencies** - Built with pure vanilla JavaScript
|
|
31
|
+
- **Fully Accessible** - ARIA support and keyboard navigation
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
### NPM
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install peek-carousel
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import PeekCarousel from 'peek-carousel';
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### CDN
|
|
46
|
+
|
|
47
|
+
#### jsDelivr
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<!-- CSS -->
|
|
51
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/peek-carousel@1.0.2/dist/peek-carousel.css">
|
|
52
|
+
|
|
53
|
+
<!-- JavaScript -->
|
|
54
|
+
<script src="https://cdn.jsdelivr.net/npm/peek-carousel@1.0.2/dist/peek-carousel.min.js"></script>
|
|
55
|
+
|
|
56
|
+
<script>
|
|
57
|
+
// PeekCarousel is available as a global variable
|
|
58
|
+
const carousel = new PeekCarousel('#myCarousel');
|
|
59
|
+
</script>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### unpkg
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<!-- CSS -->
|
|
66
|
+
<link rel="stylesheet" href="https://unpkg.com/peek-carousel@1.0.2/dist/peek-carousel.css">
|
|
67
|
+
|
|
68
|
+
<!-- JavaScript -->
|
|
69
|
+
<script src="https://unpkg.com/peek-carousel@1.0.2/dist/peek-carousel.min.js"></script>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Quick Start
|
|
73
|
+
|
|
74
|
+
### 1. HTML Structure
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<div class="peek-carousel" id="myCarousel">
|
|
78
|
+
<div class="peek-carousel__track">
|
|
79
|
+
<!-- Carousel Items -->
|
|
80
|
+
<div class="peek-carousel__item">
|
|
81
|
+
<figure class="peek-carousel__figure">
|
|
82
|
+
<img class="peek-carousel__image" src="image1.jpg" alt="Image 1" width="650" height="490" />
|
|
83
|
+
<figcaption class="peek-carousel__caption">
|
|
84
|
+
<span class="peek-carousel__caption-title">Image 1</span>
|
|
85
|
+
<span class="peek-carousel__caption-subtitle">Description</span>
|
|
86
|
+
</figcaption>
|
|
87
|
+
</figure>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div class="peek-carousel__item">
|
|
91
|
+
<figure class="peek-carousel__figure">
|
|
92
|
+
<img class="peek-carousel__image" src="image2.jpg" alt="Image 2" width="650" height="490" />
|
|
93
|
+
<figcaption class="peek-carousel__caption">
|
|
94
|
+
<span class="peek-carousel__caption-title">Image 2</span>
|
|
95
|
+
<span class="peek-carousel__caption-subtitle">Description</span>
|
|
96
|
+
</figcaption>
|
|
97
|
+
</figure>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<!-- More items... -->
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<!-- Navigation buttons, indicators, auto-rotate button, and counter are automatically generated -->
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 2. Initialize JavaScript
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
const carousel = new PeekCarousel('#myCarousel', {
|
|
111
|
+
layoutMode: 'stack', // 'stack', 'radial', 'classic'
|
|
112
|
+
autoRotate: false
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Configuration Options
|
|
117
|
+
|
|
118
|
+
| Option | Type | Default | Description |
|
|
119
|
+
|--------|------|---------|-------------|
|
|
120
|
+
| `startIndex` | `number` | `0` | Starting slide index (0-based) |
|
|
121
|
+
| `layoutMode` | `string` | `'stack'` | Layout mode: `'stack'` (Stack/Card), `'radial'` (circular rotation), or `'classic'` (classic slide) |
|
|
122
|
+
| `autoRotate` | `boolean` | `false` | Enable auto-rotation on init |
|
|
123
|
+
| `autoRotateInterval` | `number` | `2500` | Auto-rotation interval in milliseconds |
|
|
124
|
+
| `swipeThreshold` | `number` | `50` | Swipe threshold distance in pixels |
|
|
125
|
+
| `dragThreshold` | `number` | `80` | Drag threshold distance in pixels |
|
|
126
|
+
| `preloadRange` | `number` | `2` | Number of images to preload around current item |
|
|
127
|
+
| `enableKeyboard` | `boolean` | `true` | Enable keyboard navigation |
|
|
128
|
+
| `enableWheel` | `boolean` | `true` | Enable mouse wheel navigation |
|
|
129
|
+
| `enableTouch` | `boolean` | `true` | Enable touch/swipe navigation |
|
|
130
|
+
| `enableMouse` | `boolean` | `true` | Enable mouse drag navigation |
|
|
131
|
+
| `showNavigation` | `boolean` | `true` | Show navigation buttons |
|
|
132
|
+
| `showCounter` | `boolean` | `true` | Show counter display |
|
|
133
|
+
| `showIndicators` | `boolean` | `true` | Show indicator buttons |
|
|
134
|
+
| `showAutoRotateButton` | `boolean` | `true` | Show auto-rotate toggle button |
|
|
135
|
+
|
|
136
|
+
## API Methods
|
|
137
|
+
|
|
138
|
+
### Navigation
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
// Go to next slide
|
|
142
|
+
carousel.next();
|
|
143
|
+
|
|
144
|
+
// Go to previous slide
|
|
145
|
+
carousel.prev();
|
|
146
|
+
|
|
147
|
+
// Go to specific slide (0-based index)
|
|
148
|
+
carousel.goTo(2);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Auto-rotate
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
// Start auto-rotation
|
|
155
|
+
carousel.startAutoRotate();
|
|
156
|
+
|
|
157
|
+
// Stop auto-rotation
|
|
158
|
+
carousel.stopAutoRotate();
|
|
159
|
+
|
|
160
|
+
// Toggle auto-rotation
|
|
161
|
+
carousel.toggleAutoRotate();
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Cleanup
|
|
165
|
+
|
|
166
|
+
```javascript
|
|
167
|
+
// Destroy carousel and remove event listeners
|
|
168
|
+
carousel.destroy();
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Properties
|
|
172
|
+
|
|
173
|
+
```javascript
|
|
174
|
+
// Get current slide index
|
|
175
|
+
console.log(carousel.currentIndex);
|
|
176
|
+
|
|
177
|
+
// Get total number of slides
|
|
178
|
+
console.log(carousel.totalItems);
|
|
179
|
+
|
|
180
|
+
// Check if auto-rotating
|
|
181
|
+
console.log(carousel.isAutoRotating);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Browser Support
|
|
185
|
+
|
|
186
|
+
- Chrome/Edge (latest)
|
|
187
|
+
- Firefox (latest)
|
|
188
|
+
- Safari (latest)
|
|
189
|
+
- Mobile Safari (iOS 12+)
|
|
190
|
+
- Chrome Mobile (Android 5+)
|
|
191
|
+
|
|
192
|
+
## Usage Examples
|
|
193
|
+
|
|
194
|
+
```javascript
|
|
195
|
+
// Basic usage
|
|
196
|
+
const carousel = new PeekCarousel('#myCarousel');
|
|
197
|
+
|
|
198
|
+
// Change layout mode
|
|
199
|
+
new PeekCarousel('#myCarousel', { layoutMode: 'radial' });
|
|
200
|
+
|
|
201
|
+
// Enable auto-rotate
|
|
202
|
+
new PeekCarousel('#myCarousel', { autoRotate: true });
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Customization
|
|
206
|
+
|
|
207
|
+
Override CSS classes to customize styles:
|
|
208
|
+
|
|
209
|
+
```css
|
|
210
|
+
.peek-carousel__btn { /* Button styles */ }
|
|
211
|
+
.peek-carousel__indicator--active::before { /* Indicator styles */ }
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Development
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
git clone https://github.com/lledellebell/peek-carousel.git
|
|
218
|
+
npm install
|
|
219
|
+
npm run build
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Contributing
|
|
223
|
+
|
|
224
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
MIT License - see [LICENSE](LICENSE) file for details
|
|
229
|
+
|
|
230
|
+
## Credits
|
|
231
|
+
|
|
232
|
+
Inspired by the swipe interaction on the iPhone 17 Pro product page.
|
|
233
|
+
|
|
234
|
+
- [Image 1](./public/motivation0.png)
|
|
235
|
+
|
|
236
|
+
## Changelog
|
|
237
|
+
|
|
238
|
+
See [GitHub Releases](https://github.com/lledellebell/peek-carousel/releases) for the changelog.
|
package/README.md
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# PeekCarousel
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/peek-carousel)
|
|
4
|
+
[](https://www.npmjs.com/package/peek-carousel)
|
|
5
|
+
[](https://bundlephobia.com/package/peek-carousel)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
[](https://github.com/lledellebell/peek-carousel/stargazers)
|
|
9
|
+
[](https://github.com/lledellebell/peek-carousel/network/members)
|
|
10
|
+
[](https://github.com/lledellebell/peek-carousel/issues)
|
|
11
|
+
[](https://github.com/lledellebell/peek-carousel/commits)
|
|
12
|
+
[](https://github.com/lledellebell/peek-carousel)
|
|
13
|
+
|
|
14
|
+
[](https://developer.mozilla.org/en-US/docs/Web/JavaScript)
|
|
15
|
+
[](https://sass-lang.com/)
|
|
16
|
+
[](https://github.com/lledellebell/peek-carousel/packages)
|
|
17
|
+
|
|
18
|
+
iPhone 17 Pro 제품 소개 페이지의 스와이프 인터랙션에서 영감을 받은 모듈형 캐러셀 라이브러리. 현재 활성 아이템 양옆으로 다음/이전 아이템이 살짝 보이는 'Peek 효과'를 제공하여 직관적인 내비게이션을 지원합니다. 세 가지 레이아웃 모드(Stack/Card, Radial Rotation, Classic Slide)를 지원하며, 부드러운 전환 효과, 터치/드래그 지원, 완전한 접근성을 제공합니다.
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
**[라이브 데모 보기](https://lledellebell.github.io/peek-carousel/examples/example-built.html)**
|
|
23
|
+
|
|
24
|
+
> [English](./README.en.md)
|
|
25
|
+
|
|
26
|
+
## 특징
|
|
27
|
+
|
|
28
|
+
- **3가지 레이아웃 모드** - Stack/Card, Radial Rotation, Classic Slide
|
|
29
|
+
- **완전한 인터랙션 지원** - 터치/드래그, 키보드, 마우스 휠 내비게이션
|
|
30
|
+
- **제로 의존성** - 순수 바닐라 JavaScript로 구현
|
|
31
|
+
- **완전한 접근성** - ARIA 지원 및 키보드 내비게이션
|
|
32
|
+
|
|
33
|
+
## 설치
|
|
34
|
+
|
|
35
|
+
### NPM
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install peek-carousel
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import PeekCarousel from 'peek-carousel';
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### CDN
|
|
46
|
+
|
|
47
|
+
#### jsDelivr
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<!-- CSS -->
|
|
51
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/peek-carousel@1.0.2/dist/peek-carousel.css">
|
|
52
|
+
|
|
53
|
+
<!-- JavaScript -->
|
|
54
|
+
<script src="https://cdn.jsdelivr.net/npm/peek-carousel@1.0.2/dist/peek-carousel.min.js"></script>
|
|
55
|
+
|
|
56
|
+
<script>
|
|
57
|
+
// PeekCarousel는 전역 변수로 사용 가능
|
|
58
|
+
const carousel = new PeekCarousel('#myCarousel');
|
|
59
|
+
</script>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### unpkg
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<!-- CSS -->
|
|
66
|
+
<link rel="stylesheet" href="https://unpkg.com/peek-carousel@1.0.2/dist/peek-carousel.css">
|
|
67
|
+
|
|
68
|
+
<!-- JavaScript -->
|
|
69
|
+
<script src="https://unpkg.com/peek-carousel@1.0.2/dist/peek-carousel.min.js"></script>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 빠른 시작
|
|
73
|
+
|
|
74
|
+
### 1. HTML 구조
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<div class="peek-carousel" id="myCarousel">
|
|
78
|
+
<div class="peek-carousel__track">
|
|
79
|
+
<!-- 캐러셀 아이템 -->
|
|
80
|
+
<div class="peek-carousel__item">
|
|
81
|
+
<figure class="peek-carousel__figure">
|
|
82
|
+
<img class="peek-carousel__image" src="image1.jpg" alt="이미지 1" width="650" height="490" />
|
|
83
|
+
<figcaption class="peek-carousel__caption">
|
|
84
|
+
<span class="peek-carousel__caption-title">이미지 1</span>
|
|
85
|
+
<span class="peek-carousel__caption-subtitle">설명</span>
|
|
86
|
+
</figcaption>
|
|
87
|
+
</figure>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div class="peek-carousel__item">
|
|
91
|
+
<figure class="peek-carousel__figure">
|
|
92
|
+
<img class="peek-carousel__image" src="image2.jpg" alt="이미지 2" width="650" height="490" />
|
|
93
|
+
<figcaption class="peek-carousel__caption">
|
|
94
|
+
<span class="peek-carousel__caption-title">이미지 2</span>
|
|
95
|
+
<span class="peek-carousel__caption-subtitle">설명</span>
|
|
96
|
+
</figcaption>
|
|
97
|
+
</figure>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<!-- 더 많은 아이템... -->
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<!-- 네비게이션 버튼, 인디케이터, 자동 회전 버튼, 카운터는 자동으로 생성됩니다 -->
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 2. JavaScript 초기화
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
const carousel = new PeekCarousel('#myCarousel', {
|
|
111
|
+
layoutMode: 'stack', // 'stack', 'radial', 'classic'
|
|
112
|
+
autoRotate: false
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 설정 옵션
|
|
117
|
+
|
|
118
|
+
| 옵션 | 타입 | 기본값 | 설명 |
|
|
119
|
+
|------|------|--------|------|
|
|
120
|
+
| `startIndex` | `number` | `1` | 시작 슬라이드 인덱스 (0부터 시작) |
|
|
121
|
+
| `layoutMode` | `string` | `'stack'` | 레이아웃 모드: `'stack'` (Stack/Card), `'radial'` (원형 회전), 또는 `'classic'` (클래식 슬라이드) |
|
|
122
|
+
| `autoRotate` | `boolean` | `false` | 초기화 시 자동 회전 활성화 |
|
|
123
|
+
| `autoRotateInterval` | `number` | `2500` | 자동 회전 간격 (밀리초) |
|
|
124
|
+
| `swipeThreshold` | `number` | `50` | 스와이프 임계값 거리 (픽셀) |
|
|
125
|
+
| `dragThreshold` | `number` | `80` | 드래그 임계값 거리 (픽셀) |
|
|
126
|
+
| `preloadRange` | `number` | `2` | 현재 아이템 주변에 미리 로드할 이미지 수 |
|
|
127
|
+
| `enableKeyboard` | `boolean` | `true` | 키보드 내비게이션 활성화 |
|
|
128
|
+
| `enableWheel` | `boolean` | `true` | 마우스 휠 내비게이션 활성화 |
|
|
129
|
+
| `enableTouch` | `boolean` | `true` | 터치/스와이프 내비게이션 활성화 |
|
|
130
|
+
| `enableMouse` | `boolean` | `true` | 마우스 드래그 내비게이션 활성화 |
|
|
131
|
+
|
|
132
|
+
## API 메서드
|
|
133
|
+
|
|
134
|
+
### 네비게이션
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
// 다음 슬라이드로 이동
|
|
138
|
+
carousel.next();
|
|
139
|
+
|
|
140
|
+
// 이전 슬라이드로 이동
|
|
141
|
+
carousel.prev();
|
|
142
|
+
|
|
143
|
+
// 특정 슬라이드로 이동 (0부터 시작하는 인덱스)
|
|
144
|
+
carousel.goTo(2);
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 자동 회전
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
// 자동 회전 시작
|
|
151
|
+
carousel.startAutoRotate();
|
|
152
|
+
|
|
153
|
+
// 자동 회전 중지
|
|
154
|
+
carousel.stopAutoRotate();
|
|
155
|
+
|
|
156
|
+
// 자동 회전 토글
|
|
157
|
+
carousel.toggleAutoRotate();
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### 정리
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
// 캐러셀 제거 및 이벤트 리스너 정리
|
|
164
|
+
carousel.destroy();
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 속성
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
// 현재 슬라이드 인덱스 가져오기
|
|
171
|
+
console.log(carousel.currentIndex);
|
|
172
|
+
|
|
173
|
+
// 전체 슬라이드 수 가져오기
|
|
174
|
+
console.log(carousel.totalItems);
|
|
175
|
+
|
|
176
|
+
// 자동 회전 상태 확인
|
|
177
|
+
console.log(carousel.isAutoRotating);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## 브라우저 지원
|
|
181
|
+
|
|
182
|
+
- Chrome/Edge (최신)
|
|
183
|
+
- Firefox (최신)
|
|
184
|
+
- Safari (최신)
|
|
185
|
+
- Mobile Safari (iOS 12+)
|
|
186
|
+
- Chrome Mobile (Android 5+)
|
|
187
|
+
|
|
188
|
+
## 사용 예제
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
// 기본 사용
|
|
192
|
+
const carousel = new PeekCarousel('#myCarousel');
|
|
193
|
+
|
|
194
|
+
// 레이아웃 모드 변경
|
|
195
|
+
new PeekCarousel('#myCarousel', { layoutMode: 'radial' });
|
|
196
|
+
|
|
197
|
+
// 자동 회전 활성화
|
|
198
|
+
new PeekCarousel('#myCarousel', { autoRotate: true });
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## 커스터마이징
|
|
202
|
+
|
|
203
|
+
CSS 클래스를 오버라이드하여 스타일을 커스터마이징할 수 있습니다:
|
|
204
|
+
|
|
205
|
+
```css
|
|
206
|
+
.peek-carousel__btn { /* 버튼 스타일 */ }
|
|
207
|
+
.peek-carousel__indicator--active::before { /* 인디케이터 스타일 */ }
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## 개발
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
git clone https://github.com/lledellebell/peek-carousel.git
|
|
214
|
+
npm install
|
|
215
|
+
npm run build
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## 기여
|
|
219
|
+
|
|
220
|
+
기여를 환영합니다! Pull Request를 자유롭게 제출해 주세요.
|
|
221
|
+
|
|
222
|
+
## 라이선스
|
|
223
|
+
|
|
224
|
+
MIT 라이선스 - 자세한 내용은 [LICENSE](LICENSE) 파일을 참조하세요
|
|
225
|
+
|
|
226
|
+
## 크레딧
|
|
227
|
+
|
|
228
|
+
iPhone 17 Pro 제품 소개 페이지의 스와이프 인터랙션에서 영감을 받았습니다.
|
|
229
|
+
|
|
230
|
+
- [이미지1](./public/motivation0.png)
|
|
231
|
+
|
|
232
|
+
## 변경 로그
|
|
233
|
+
|
|
234
|
+
변경 사항은 [GitHub Releases](https://github.com/lledellebell/peek-carousel/releases)를 참조하세요.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.peek-carousel__item:focus-visible{border-radius:12px;outline:3px solid rgba(102,126,234,.8);outline-offset:8px}.peek-carousel{animation:fadeInUp .8s cubic-bezier(.4,0,.2,1) forwards;animation-delay:.1s;cursor:grab;display:grid;height:100%;opacity:0;place-items:center;position:relative;transform:translateY(30px);-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%;--drag-offset:0px;--drag-rotation:0deg;--drag-rotation-y:0deg}.peek-carousel__track{height:100%;position:relative;touch-action:pan-y;transform-style:preserve-3d;width:100%}.peek-carousel__item{aspect-ratio:1.3265306122;backface-visibility:hidden;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%) scale(.8);transform-origin:center;width:clamp(300px,35vw,500px);will-change:transform,opacity;z-index:0;--item-x:0%;--item-scale:0.8;--item-offset-x:0px;--item-angle:0deg;--item-radius:400px}.peek-carousel__item--active .peek-carousel__caption{opacity:1}@media (max-width:768px){.peek-carousel__item{width:clamp(280px,80vw,400px);--item-radius:300px}}.peek-carousel__figure{height:100%;margin:0;position:relative;width:100%}.peek-carousel__image{border-radius:16px;box-shadow:0,20px,60px,rgba(0,0,0,.6),0,5px,15px,rgba(0,0,0,.4);height:100%;-o-object-fit:cover;object-fit:cover;transition:filter .4s cubic-bezier(.4,0,.2,1),box-shadow .4s cubic-bezier(.4,0,.2,1);width:100%;will-change:filter,box-shadow}.peek-carousel__caption{background:linear-gradient(0deg,rgba(0,0,0,.8),transparent);border-radius:0 0 16px 16px;color:#fff;inset:auto 0 0;opacity:0;padding:1.5rem;pointer-events:none;position:absolute;text-align:center;transition:opacity .3s ease}@keyframes fadeInUp{to{opacity:1;transform:translateY(0)}}.peek-carousel--stack .peek-carousel__track{transform:none;transition:none}.peek-carousel--stack .peek-carousel__item{cursor:pointer;opacity:.5;transition:transform .05s,opacity .05s,z-index 0s;visibility:visible}.peek-carousel--stack .peek-carousel__item:not(.peek-carousel__item--dragging-left):not(.peek-carousel__item--dragging-right){transition:transform .5s,opacity .5s,z-index 0s}.peek-carousel--stack .peek-carousel__item--active{opacity:1;z-index:100}.peek-carousel--stack .peek-carousel__item--active .peek-carousel__image{box-shadow:0 40px 100px rgba(102,126,234,.6),0 0 40px rgba(102,126,234,.4),0 0 80px rgba(118,75,162,.3);filter:brightness(1.2) saturate(1.1)}.peek-carousel--stack .peek-carousel__item:not(.peek-carousel--stack .peek-carousel__item--active) .peek-carousel__image{box-shadow:0 20px 50px rgba(0,0,0,.5);filter:brightness(.7) saturate(.85)}.peek-carousel--stack .peek-carousel__item:not(.peek-carousel--stack .peek-carousel__item--active):hover .peek-carousel__image{box-shadow:0 30px 70px rgba(102,126,234,.3)!important;filter:brightness(.9) saturate(1)!important;transition:all .3s ease}.peek-carousel--stack .peek-carousel__item--center{transform:translate(-50%,-50%) scale(1.15) translateX(var(--drag-offset)) rotate(var(--drag-rotation))}.peek-carousel--stack .peek-carousel__item--prev{transform:translate(-95%,-50%) scale(.85) translateX(calc(-15px + var(--drag-offset))) rotate(var(--drag-rotation))}.peek-carousel--stack .peek-carousel__item--next{transform:translate(-5%,-50%) scale(.85) translateX(calc(15px + var(--drag-offset))) rotate(var(--drag-rotation))}.peek-carousel--stack .peek-carousel__item--hidden{transform:translate(-50%,-50%) scale(.7) translateX(var(--drag-offset)) rotate(var(--drag-rotation))}.peek-carousel--radial{perspective:1200px}.peek-carousel--radial .peek-carousel__track{transform:rotateY(calc(var(--carousel-rotation, 0deg) + var(--drag-rotation-y)));transition:transform .5s cubic-bezier(.4,0,.2,1)}.peek-carousel--radial .peek-carousel__track:active{transition:transform .05s}.peek-carousel--radial .peek-carousel__item{cursor:default;opacity:0;transform:translate(-50%,-50%) rotateY(var(--item-angle)) translateZ(var(--item-radius));transition:transform .5s cubic-bezier(.4,0,.2,1),opacity .5s cubic-bezier(.4,0,.2,1),visibility 0s .5s,z-index 0s;visibility:hidden}.peek-carousel--radial .peek-carousel__item--active{cursor:grab;opacity:1;transition:transform .5s cubic-bezier(.4,0,.2,1),opacity .5s cubic-bezier(.4,0,.2,1),visibility 0s 0s,z-index 0s;visibility:visible;z-index:100}.peek-carousel--radial .peek-carousel__item--active:active{cursor:grabbing}.peek-carousel--radial .peek-carousel__item--active .peek-carousel__image{box-shadow:0 40px 100px rgba(102,126,234,.6),0 0 40px rgba(102,126,234,.4),0 0 80px rgba(118,75,162,.3);filter:brightness(1.2) saturate(1.1)}.peek-carousel--radial .peek-carousel__item--next,.peek-carousel--radial .peek-carousel__item--prev{opacity:.3;transition:transform .5s cubic-bezier(.4,0,.2,1),opacity .5s cubic-bezier(.4,0,.2,1),visibility 0s 0s,z-index 0s;visibility:visible;z-index:50}.peek-carousel--radial .peek-carousel__item--next .peek-carousel__image,.peek-carousel--radial .peek-carousel__item--prev .peek-carousel__image{box-shadow:0 25px 60px rgba(0,0,0,.6);filter:brightness(.8) saturate(.9)}.peek-carousel--radial .peek-carousel__item:not(.peek-carousel--radial .peek-carousel__item--active) .peek-carousel__image{box-shadow:0 20px 50px rgba(0,0,0,.5);filter:brightness(.7) saturate(.85)}@media (max-width:768px){.peek-carousel--radial .peek-carousel__item{--item-radius:300px}}.peek-carousel--classic{overflow:hidden}.peek-carousel--classic .peek-carousel__track{transform:translateX(calc(var(--track-offset, 0px) + var(--drag-offset)));transition:transform .5s cubic-bezier(.4,0,.2,1)}.peek-carousel--classic .peek-carousel__track:active{transition:transform .05s}.peek-carousel--classic .peek-carousel__item{cursor:default;left:var(--item-x,50%);opacity:0;position:absolute;transform:translate(-50%,-50%) scale(var(--item-scale,1));transition:transform .5s cubic-bezier(.4,0,.2,1),opacity .5s cubic-bezier(.4,0,.2,1),left .5s cubic-bezier(.4,0,.2,1),visibility 0s cubic-bezier(.4,0,.2,1) .5s,z-index 0s;visibility:hidden;z-index:0}.peek-carousel--classic .peek-carousel__item--active{cursor:grab;opacity:1;transition:transform .5s cubic-bezier(.4,0,.2,1),opacity .5s cubic-bezier(.4,0,.2,1),left .5s cubic-bezier(.4,0,.2,1),visibility 0s 0s,z-index 0s;visibility:visible;z-index:100}.peek-carousel--classic .peek-carousel__item--active:active{cursor:grabbing}.peek-carousel--classic .peek-carousel__item--active .peek-carousel__image{box-shadow:0 40px 100px rgba(102,126,234,.6),0 0 40px rgba(102,126,234,.4),0 0 80px rgba(118,75,162,.3);filter:brightness(1.15) saturate(1.1)}.peek-carousel--classic .peek-carousel__item--next,.peek-carousel--classic .peek-carousel__item--prev{cursor:pointer;opacity:.6;transition:transform .5s cubic-bezier(.4,0,.2,1),opacity .5s cubic-bezier(.4,0,.2,1),left .5s cubic-bezier(.4,0,.2,1),visibility 0s 0s,z-index 0s;visibility:visible;z-index:50}.peek-carousel--classic .peek-carousel__item--next .peek-carousel__image,.peek-carousel--classic .peek-carousel__item--prev .peek-carousel__image{box-shadow:0 25px 60px rgba(0,0,0,.5);filter:brightness(.8) saturate(.95)}.peek-carousel--classic .peek-carousel__item--next:hover .peek-carousel__image,.peek-carousel--classic .peek-carousel__item--prev:hover .peek-carousel__image{box-shadow:0 30px 70px rgba(102,126,234,.3)!important;filter:brightness(1) saturate(1.05)!important;transition:all .3s ease}.peek-carousel--classic .peek-carousel__item:not(.peek-carousel--classic .peek-carousel__item--active):not(.peek-carousel--classic .peek-carousel__item--prev):not(.peek-carousel--classic .peek-carousel__item--next) .peek-carousel__image{box-shadow:0 10px 30px rgba(0,0,0,.3);filter:brightness(.5) saturate(.7)}.peek-carousel__controls{align-items:center;animation:fadeInUpControls .6s cubic-bezier(.4,0,.2,1) forwards;animation-delay:.6s;display:flex;gap:.75rem;inset:auto auto 3% 50%;opacity:0;position:absolute;transform:translateX(-50%);z-index:100}.peek-carousel__indicators{align-items:center;backdrop-filter:blur(12px);background:rgba(0,0,0,.5);border:1px solid hsla(0,0%,100%,.15);border-radius:50px;display:flex;gap:.875rem;padding:.625rem 1rem}.peek-carousel__indicator{align-items:center;background:transparent;border:none;border-radius:50%;cursor:pointer;display:flex;height:10px;justify-content:center;padding:0;position:relative;transition:all .3s ease;width:10px}.peek-carousel__indicator:before{background:hsla(0,0%,100%,.4);border-radius:50%;content:"";height:10px;transition:all .3s ease;width:10px}.peek-carousel__indicator:hover:before{background:hsla(0,0%,100%,.6);transform:scale(1.2)}.peek-carousel__indicator--active{border-radius:50px;overflow:hidden;width:50px}.peek-carousel__indicator--active:before{background:hsla(0,0%,100%,.3);border-radius:50px;content:"";height:8px;transition:all .3s ease;width:50px}.peek-carousel__indicator--active:after{background:hsla(0,0%,100%,.95);border-radius:50px;box-shadow:0 2px 8px hsla(0,0%,100%,.3),0 0 12px hsla(0,0%,100%,.2);content:"";height:8px;inset:50% auto auto 0;position:absolute;transform:translateY(-50%);transition:all .3s ease;width:50px}.peek-carousel__indicator--active:hover:before{background:hsla(0,0%,100%,.4)}.peek-carousel__indicator--active:hover:after{background:#fff;box-shadow:0 2px 12px hsla(0,0%,100%,.4),0 0 16px hsla(0,0%,100%,.3)}.peek-carousel__indicator--active.peek-carousel__indicator--progress:after{animation:indicatorProgress linear forwards;animation-duration:var(--progress-duration,2.5s);width:0}.peek-carousel__indicator--completed:after{animation:none;width:50px!important}@keyframes fadeInUpControls{0%{opacity:0;transform:translateX(-50%) translateY(20px)}to{opacity:1;transform:translateX(-50%) translateY(0)}}@keyframes indicatorProgress{0%{width:0}to{width:50px}}.peek-carousel__nav{align-items:center;animation:fadeInUpNav .6s cubic-bezier(.4,0,.2,1) forwards;animation-delay:.5s;display:flex;gap:2rem;inset:auto auto 8% 50%;opacity:0;position:absolute;transform:translateX(-50%);z-index:100}@media (max-width:768px){.peek-carousel__nav{bottom:12%}}.peek-carousel__btn{align-items:center;backdrop-filter:blur(10px);background:hsla(0,0%,100%,.1);border:1px solid hsla(0,0%,100%,.2);border-radius:50%;color:#fff;cursor:pointer;display:flex;display:grid;font-size:1rem;height:36px;justify-content:center;place-items:center;transition:all .3s ease;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:36px}.peek-carousel__btn svg{flex-shrink:0;height:18px;transition:transform .15s ease-out;width:18px}.peek-carousel__btn:hover{background:hsla(0,0%,100%,.2);transform:scale(1.1)}.peek-carousel__btn:active{transform:scale(.95)}.peek-carousel__btn:focus-visible{outline:3px solid rgba(102,126,234,.8);outline-offset:4px}.peek-carousel__btn:hover svg{transform:translateX(0)}.peek-carousel__btn.prev-btn:hover svg{transform:translateX(-2px)}.peek-carousel__btn.next-btn:hover svg{transform:translateX(2px)}@media (max-width:768px){.peek-carousel__btn{height:36px;width:36px}}.peek-carousel__btn--auto-rotate{align-items:center;backdrop-filter:blur(12px);background:rgba(0,0,0,.5);border:1px solid hsla(0,0%,100%,.15);border-radius:50%;cursor:pointer;display:flex;height:36px;justify-content:center;padding:0;transition:all .3s ease;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:36px}.peek-carousel__btn--auto-rotate svg{flex-shrink:0}.peek-carousel__btn--auto-rotate .play-icon{display:block}.peek-carousel__btn--auto-rotate .pause-icon{display:none}.peek-carousel__btn--auto-rotate:hover{background:rgba(0,0,0,.6);border-color:hsla(0,0%,100%,.3);transform:scale(1.1)}.peek-carousel__btn--auto-rotate:active{transform:scale(.95)}.peek-carousel__btn--auto-rotate:focus-visible{outline:3px solid rgba(102,126,234,.8);outline-offset:4px}.peek-carousel__btn--auto-rotate.peek-carousel__btn--active{background:hsla(0,0%,100%,.2);border-color:hsla(0,0%,100%,.3)}.peek-carousel__btn--auto-rotate.peek-carousel__btn--active .play-icon{display:none}.peek-carousel__btn--auto-rotate.peek-carousel__btn--active .pause-icon{display:block}@keyframes fadeInUpNav{0%{opacity:0;transform:translateX(-50%) translateY(20px)}to{opacity:1;transform:translateX(-50%) translateY(0)}}.peek-carousel__counter{animation:fadeInDown .6s cubic-bezier(.4,0,.2,1) forwards;animation-delay:.7s;backdrop-filter:blur(10px);background:rgba(0,0,0,.5);border:1px solid hsla(0,0%,100%,.15);border-radius:20px;color:#fff;font-size:.875rem;font-weight:500;inset:3% auto auto 3%;line-height:1;opacity:0;padding:.5rem 1rem;pointer-events:none;position:absolute;transform:translateY(-10px);-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:100}@media (max-width:768px){.peek-carousel__counter{font-size:.75rem;inset:2% auto auto 2%;padding:.4rem .8rem;position:absolute}}.peek-carousel__counter-separator{margin:0 .25rem;opacity:.7}.peek-carousel__counter-current{font-weight:600}.peek-carousel__counter-total{opacity:.8}@keyframes fadeInDown{to{opacity:1;transform:translateY(0)}}
|