@egjs/flicking 4.12.1-beta.5 → 4.13.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/panel-visual.md DELETED
@@ -1,328 +0,0 @@
1
- # Panel 시각적 속성과 계산 로직
2
-
3
- ## 1. 핵심 시각적 속성
4
-
5
- ### 1.1 크기 속성
6
- ```typescript
7
- protected _size: number; // 기본 패널 크기 (가로/세로)
8
- protected _height: number; // 패널 높이
9
- protected _margin: {
10
- prev: number; // 이전 마진 (왼쪽/위)
11
- next: number; // 다음 마진 (오른쪽/아래)
12
- };
13
- ```
14
-
15
- ```mermaid
16
- graph TD
17
- A[패널 크기 구성] --> B[기본 크기 _size]
18
- A --> C[마진]
19
- C --> D[이전 마진 prev]
20
- C --> E[다음 마진 next]
21
- A --> F[높이 _height]
22
- ```
23
-
24
- ### 1.2 위치 속성
25
- ```typescript
26
- protected _pos: number; // 기본 위치
27
- protected _alignPos: number; // 정렬 오프셋
28
- protected _togglePosition: number; // 순환 모드 토글 위치
29
- ```
30
-
31
- ```mermaid
32
- graph LR
33
- A[패널 위치 구성] --> B[기본 위치 _pos]
34
- A --> C[정렬 오프셋 _alignPos]
35
- A --> D[토글 위치 _togglePosition]
36
- E[총 위치] --> B
37
- E --> C
38
- ```
39
-
40
- ## 2. 크기 계산
41
-
42
- ### 2.1 기본 크기 계산
43
- 패널의 크기는 `resize()` 메소드에서 계산됩니다:
44
-
45
- ```typescript
46
- public resize(cached?: {
47
- size: number;
48
- height?: number;
49
- margin: { prev: number; next: number };
50
- }): this {
51
- const el = this.element;
52
- const { horizontal, useFractionalSize } = this._flicking;
53
-
54
- // 캐시된 값이 있으면 사용
55
- if (cached) {
56
- this._size = cached.size;
57
- this._margin = { ...cached.margin };
58
- this._height = cached.height ?? getElementSize({
59
- el,
60
- horizontal: false,
61
- useFractionalSize,
62
- useOffset: true,
63
- style: getStyle(el)
64
- });
65
- } else {
66
- // 새로운 값 계산
67
- const elStyle = getStyle(el);
68
-
69
- // 주요 크기 (가로/세로)
70
- this._size = getElementSize({
71
- el,
72
- horizontal,
73
- useFractionalSize,
74
- useOffset: true,
75
- style: elStyle
76
- });
77
-
78
- // 마진
79
- this._margin = horizontal
80
- ? {
81
- prev: parseFloat(elStyle.marginLeft || "0"),
82
- next: parseFloat(elStyle.marginRight || "0")
83
- }
84
- : {
85
- prev: parseFloat(elStyle.marginTop || "0"),
86
- next: parseFloat(elStyle.marginBottom || "0")
87
- };
88
-
89
- // 높이
90
- this._height = horizontal
91
- ? getElementSize({
92
- el,
93
- horizontal: false,
94
- useFractionalSize,
95
- useOffset: true,
96
- style: elStyle
97
- })
98
- : this._size;
99
- }
100
- }
101
- ```
102
-
103
- ```mermaid
104
- graph TD
105
- A[크기 계산 프로세스] --> B{캐시 존재?}
106
- B -->|Yes| C[캐시된 값 사용]
107
- B -->|No| D[새로운 값 계산]
108
- D --> E[기본 크기 계산]
109
- D --> F[마진 계산]
110
- D --> G[높이 계산]
111
- C --> H[최종 크기 설정]
112
- E --> H
113
- F --> H
114
- G --> H
115
- ```
116
-
117
- ### 2.2 마진 포함 크기
118
- ```typescript
119
- public get sizeIncludingMargin(): number {
120
- return this._size + this._margin.prev + this._margin.next;
121
- }
122
- ```
123
-
124
- ```mermaid
125
- graph LR
126
- A[총 크기] --> B[기본 크기]
127
- A --> C[이전 마진]
128
- A --> D[다음 마진]
129
- ```
130
-
131
- ## 3. 위치 계산
132
-
133
- ### 3.1 기본 위치
134
- 기본 위치는 이전 패널을 기준으로 계산됩니다:
135
-
136
- ```typescript
137
- public updatePosition(): this {
138
- const prevPanel = this._flicking.renderer.panels[this._index - 1];
139
-
140
- this._pos = prevPanel
141
- ? prevPanel.range.max + prevPanel.margin.next + this._margin.prev
142
- : this._margin.prev;
143
-
144
- return this;
145
- }
146
- ```
147
-
148
- ```mermaid
149
- graph LR
150
- A[패널 위치 계산] --> B{이전 패널 존재?}
151
- B -->|Yes| C[이전 패널 끝 + 마진]
152
- B -->|No| D[첫 번째 마진]
153
- C --> E[최종 위치]
154
- D --> E
155
- ```
156
-
157
- ### 3.2 정렬 위치
158
- 정렬 위치는 align 옵션에 따라 계산됩니다:
159
-
160
- ```typescript
161
- private _updateAlignPos() {
162
- this._alignPos = parseAlign(this._align, this._size);
163
- }
164
- ```
165
-
166
- ```mermaid
167
- graph TD
168
- A[정렬 위치 계산] --> B{정렬 옵션}
169
- B -->|prev| C[시작점]
170
- B -->|center| D[중앙]
171
- B -->|next| E[끝점]
172
- B -->|custom| F[사용자 정의]
173
- ```
174
-
175
- ### 3.3 총 위치
176
- 총 위치는 기본 위치와 정렬 오프셋을 포함합니다:
177
-
178
- ```typescript
179
- public get position(): number {
180
- return this._pos + this._alignPos;
181
- }
182
- ```
183
-
184
- ## 4. 범위와 가시성
185
-
186
- ### 4.1 패널 범위
187
- ```typescript
188
- public get range() {
189
- return {
190
- min: this._pos,
191
- max: this._pos + this._size
192
- };
193
- }
194
- ```
195
-
196
- ```mermaid
197
- graph LR
198
- A[패널 범위] --> B[시작점 min]
199
- A --> C[끝점 max]
200
- B --> D[기본 위치]
201
- C --> E[기본 위치 + 크기]
202
- ```
203
-
204
- ### 4.2 가시성 계산
205
- ```typescript
206
- public get visibleRatio(): number {
207
- const range = this.range;
208
- const size = this._size;
209
- const offset = this.offset;
210
- const visibleRange = this._flicking.camera.visibleRange;
211
-
212
- const checkingRange = {
213
- min: range.min + offset,
214
- max: range.max + offset
215
- };
216
-
217
- // 완전히 보이지 않음
218
- if (checkingRange.max <= visibleRange.min || checkingRange.min >= visibleRange.max) {
219
- return 0;
220
- }
221
-
222
- let visibleSize = size;
223
-
224
- // 보이는 부분 계산
225
- if (visibleRange.min > checkingRange.min) {
226
- visibleSize -= visibleRange.min - checkingRange.min;
227
- }
228
- if (visibleRange.max < checkingRange.max) {
229
- visibleSize -= checkingRange.max - visibleRange.max;
230
- }
231
-
232
- return visibleSize / size;
233
- }
234
- ```
235
-
236
- ```mermaid
237
- graph TD
238
- A[가시성 계산] --> B{뷰포트 범위 확인}
239
- B -->|완전히 보이지 않음| C[0 반환]
240
- B -->|부분적으로 보임| D[보이는 부분 계산]
241
- D --> E[가시성 비율 계산]
242
- ```
243
-
244
- ## 5. 순환 모드 위치 처리
245
-
246
- ### 5.1 토글 방향과 위치
247
- ```typescript
248
- public updateCircularToggleDirection(): this {
249
- const flicking = this._flicking;
250
- if (!flicking.circularEnabled) {
251
- this._toggleDirection = DIRECTION.NONE;
252
- this._togglePosition = 0;
253
- this._toggled = false;
254
- return this;
255
- }
256
-
257
- const camera = flicking.camera;
258
- const camRange = camera.range;
259
- const camAlignPosition = camera.alignPosition;
260
- const camVisibleRange = camera.visibleRange;
261
- const camVisibleSize = camVisibleRange.max - camVisibleRange.min;
262
-
263
- // Calculate visibility boundaries
264
- const minimumVisible = camRange.min - camAlignPosition;
265
- const maximumVisible = camRange.max - camAlignPosition + camVisibleSize;
266
-
267
- // Check if panel should be visible at boundaries
268
- const shouldBeVisibleAtMin = this.includeRange(
269
- maximumVisible - camVisibleSize,
270
- maximumVisible,
271
- false
272
- );
273
- const shouldBeVisibleAtMax = this.includeRange(
274
- minimumVisible,
275
- minimumVisible + camVisibleSize,
276
- false
277
- );
278
-
279
- // Set toggle direction and position
280
- this._toggled = false;
281
- if (shouldBeVisibleAtMin) {
282
- this._toggleDirection = DIRECTION.PREV;
283
- this._togglePosition = this.range.max + camRange.min - camRange.max + camAlignPosition;
284
- this.toggle(Infinity, camera.position);
285
- } else if (shouldBeVisibleAtMax) {
286
- this._toggleDirection = DIRECTION.NEXT;
287
- this._togglePosition = this.range.min + camRange.max - camVisibleSize + camAlignPosition;
288
- this.toggle(-Infinity, camera.position);
289
- } else {
290
- this._toggleDirection = DIRECTION.NONE;
291
- this._togglePosition = 0;
292
- }
293
-
294
- return this;
295
- }
296
- ```
297
-
298
- ```mermaid
299
- graph TD
300
- A[순환 모드 위치 처리] --> B{순환 모드 활성화?}
301
- B -->|No| C[토글 비활성화]
302
- B -->|Yes| D[가시성 경계 계산]
303
- D --> E{경계에서 보여야 함?}
304
- E -->|Yes| F[토글 방향 설정]
305
- E -->|No| G[토글 비활성화]
306
- ```
307
-
308
- ## 6. 주요 기능
309
-
310
- 1. **소수점 크기 지원**
311
- - `useFractionalSize` 옵션으로 서브픽셀 크기 처리
312
- - 1px 오프셋 이슈 방지
313
-
314
- 2. **마진 처리**
315
- - 콘텐츠 크기와 마진을 포함한 총 크기 분리
316
- - 가로/세로 모드에 따른 마진 방향 처리
317
-
318
- 3. **순환 모드**
319
- - 위치 토글을 통한 무한 스크롤 지원
320
- - 부드러운 전환을 위한 최적의 토글 위치 계산
321
-
322
- 4. **가시성 감지**
323
- - 정확한 가시 영역 계산
324
- - 뷰포트 경계에서의 부분 가시성 처리
325
-
326
- 5. **정렬 시스템**
327
- - 유연한 정렬 옵션 (prev, center, next, custom)
328
- - 패널과 카메라 모두에 대한 정렬 지원
@@ -1,11 +0,0 @@
1
- .flicking-viewport {
2
- position: relative;
3
- overflow: hidden;
4
- }
5
- .flicking-viewport .flicking-camera {
6
- display: flex;
7
- position: relative;
8
- width: 100%;
9
- height: 100%;
10
- will-change: transform;
11
- }