@egjs/flicking 4.12.0-beta.4 → 4.12.0-beta.6
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/declaration/CrossFlicking.d.ts +36 -0
- package/declaration/Flicking.d.ts +244 -244
- package/declaration/camera/Camera.d.ts +89 -90
- package/declaration/camera/index.d.ts +4 -4
- package/declaration/camera/mode/BoundCameraMode.d.ts +13 -13
- package/declaration/camera/mode/CameraMode.d.ts +20 -20
- package/declaration/camera/mode/CircularCameraMode.d.ts +19 -19
- package/declaration/camera/mode/LinearCameraMode.d.ts +9 -9
- package/declaration/camera/mode/index.d.ts +6 -6
- package/declaration/cfc/getDefaultCameraTransform.d.ts +3 -3
- package/declaration/cfc/getRenderingPanels.d.ts +4 -4
- package/declaration/cfc/index.d.ts +5 -5
- package/declaration/cfc/sync.d.ts +4 -4
- package/declaration/cfc/withFlickingMethods.d.ts +2 -2
- package/declaration/const/axes.d.ts +8 -8
- package/declaration/const/error.d.ts +34 -34
- package/declaration/const/external.d.ts +54 -48
- package/declaration/control/AxesController.d.ts +44 -44
- package/declaration/control/Control.d.ts +45 -45
- package/declaration/control/FreeControl.d.ts +14 -14
- package/declaration/control/SnapControl.d.ts +16 -16
- package/declaration/control/StateMachine.d.ts +14 -14
- package/declaration/control/StrictControl.d.ts +20 -20
- package/declaration/control/index.d.ts +14 -14
- package/declaration/control/states/AnimatingState.d.ts +9 -9
- package/declaration/control/states/DisabledState.d.ts +9 -9
- package/declaration/control/states/DraggingState.d.ts +8 -8
- package/declaration/control/states/HoldingState.d.ts +10 -10
- package/declaration/control/states/IdleState.d.ts +9 -9
- package/declaration/control/states/State.d.ts +47 -47
- package/declaration/core/AnchorPoint.d.ts +15 -15
- package/declaration/core/AutoResizer.d.ts +16 -16
- package/declaration/core/FlickingError.d.ts +5 -5
- package/declaration/core/ResizeWatcher.d.ts +33 -33
- package/declaration/core/Viewport.d.ts +25 -25
- package/declaration/core/VirtualManager.d.ts +37 -37
- package/declaration/core/index.d.ts +6 -6
- package/declaration/core/panel/Panel.d.ts +89 -89
- package/declaration/core/panel/VirtualPanel.d.ts +19 -19
- package/declaration/core/panel/index.d.ts +5 -5
- package/declaration/core/panel/provider/ElementProvider.d.ts +8 -8
- package/declaration/core/panel/provider/VanillaElementProvider.d.ts +12 -12
- package/declaration/core/panel/provider/VirtualElementProvider.d.ts +15 -15
- package/declaration/core/panel/provider/index.d.ts +5 -5
- package/declaration/index.cjs.d.ts +3 -3
- package/declaration/index.d.ts +15 -13
- package/declaration/index.umd.d.ts +2 -2
- package/declaration/renderer/ExternalRenderer.d.ts +7 -7
- package/declaration/renderer/Renderer.d.ts +59 -59
- package/declaration/renderer/VanillaRenderer.d.ts +10 -10
- package/declaration/renderer/index.d.ts +6 -6
- package/declaration/renderer/strategy/NormalRenderingStrategy.d.ts +23 -23
- package/declaration/renderer/strategy/RenderingStrategy.d.ts +15 -15
- package/declaration/renderer/strategy/VirtualRenderingStrategy.d.ts +17 -17
- package/declaration/renderer/strategy/index.d.ts +5 -5
- package/declaration/type/event.d.ts +88 -88
- package/declaration/type/external.d.ts +31 -31
- package/declaration/type/internal.d.ts +13 -13
- package/declaration/utils.d.ts +47 -45
- package/dist/flicking.cjs.js +361 -15
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +353 -15
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +362 -15
- package/dist/flicking.js.map +1 -1
- package/dist/flicking.min.js +2 -2
- package/dist/flicking.min.js.map +1 -1
- package/dist/flicking.pkgd.js +1129 -775
- package/dist/flicking.pkgd.js.map +1 -1
- package/dist/flicking.pkgd.min.js +2 -2
- package/dist/flicking.pkgd.min.js.map +1 -1
- package/package.json +2 -2
- package/src/CrossFlicking.ts +405 -0
- package/src/camera/Camera.ts +0 -9
- package/src/const/external.ts +14 -0
- package/src/index.ts +4 -1
- package/src/index.umd.ts +2 -0
- package/src/utils.ts +21 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@egjs/flicking",
|
|
3
|
-
"version": "4.12.0-beta.
|
|
3
|
+
"version": "4.12.0-beta.6",
|
|
4
4
|
"description": "Everyday 30 million people experience. It's reliable, flexible and extendable carousel.",
|
|
5
5
|
"main": "dist/flicking.cjs.js",
|
|
6
6
|
"module": "dist/flicking.esm.js",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"typescript-transform-paths": "^2.2.3"
|
|
140
140
|
},
|
|
141
141
|
"dependencies": {
|
|
142
|
-
"@egjs/axes": "^3.9.
|
|
142
|
+
"@egjs/axes": "^3.9.0",
|
|
143
143
|
"@egjs/component": "^3.0.1",
|
|
144
144
|
"@egjs/imready": "^1.3.1",
|
|
145
145
|
"@egjs/list-differ": "^1.0.1"
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
3
|
+
* egjs projects are licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import Flicking, { FlickingOptions } from "./Flicking";
|
|
7
|
+
import { ChangedEvent, MoveEndEvent, MoveEvent } from "./type/event";
|
|
8
|
+
import { LiteralUnion, ValueOf } from "./type/internal";
|
|
9
|
+
import { CLASS, EVENTS, MOVE_DIRECTION } from "./const/external";
|
|
10
|
+
import { getDataAttributes, includes, toArray } from "./utils";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @interface
|
|
14
|
+
*/
|
|
15
|
+
export interface CrossFlickingEvents {
|
|
16
|
+
// FlickingEvent 들을 확장하자...
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @interface
|
|
21
|
+
*/
|
|
22
|
+
export interface CrossFlickingOptions extends FlickingOptions {
|
|
23
|
+
sideOptions: Partial<FlickingOptions> | undefined;
|
|
24
|
+
// 한쪽 움직이면 다른 한쪽 움직임을 막을지 여부
|
|
25
|
+
// 이전 패널 기억 여부
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Flicking Status returned by {@link Flicking#getStatus}
|
|
30
|
+
* @ko {@link Flicking#getStatus}에 의해 반환된 Flicking 상태 객체
|
|
31
|
+
* @interface
|
|
32
|
+
* @property {number} index An index of the active panel<ko>활성화된 패널의 인덱스</ko>
|
|
33
|
+
* @property {object} position A info to restore camera {@link Camera#position position}<ko>카메라 {@link Camera#position position}을 설정하기 위한 정보들</ko>
|
|
34
|
+
* @property {number} [position.panel] An index of the panel camera is located at<ko>카메라가 위치한 패널의 인덱스</ko>
|
|
35
|
+
* @property {number} [position.progressInPanel] A progress of the camera position inside the panel<ko>패널 내에서의 카메라 위치의 진행도</ko>
|
|
36
|
+
* @property {number} visibleOffset An offset to visible panel's original index. This value is available only when `visiblePanelsOnly` is `true`
|
|
37
|
+
* <ko>현재 보이는 패널들을 저장했을 때, 원래의 인덱스 대비 offset. `visiblePanelsOnly` 옵션을 사용했을 때만 사용 가능합니다</ko>
|
|
38
|
+
* @property {object[]} panels A data array of panels<ko>패널의 정보를 담은 배열</ko>
|
|
39
|
+
* @property {index} [panels.index] An index of the panel<ko>패널의 인덱스</ko>
|
|
40
|
+
* @property {string | undefined} [panels.html] An `outerHTML` of the panel element<ko>패널 엘리먼트의 `outerHTML`</ko>
|
|
41
|
+
*/
|
|
42
|
+
export interface SideState {
|
|
43
|
+
key: string;
|
|
44
|
+
start: number;
|
|
45
|
+
end: number;
|
|
46
|
+
element: HTMLElement;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @extends Component
|
|
51
|
+
* @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
|
|
52
|
+
* @requires {@link https://github.com/naver/egjs-component|@egjs/component}
|
|
53
|
+
* @requires {@link https://github.com/naver/egjs-axes|@egjs/axes}
|
|
54
|
+
*/
|
|
55
|
+
export class CrossFlicking extends Flicking {
|
|
56
|
+
// Core components
|
|
57
|
+
private _sideFlicking: Flicking[];
|
|
58
|
+
|
|
59
|
+
// Options
|
|
60
|
+
private _sideOptions: CrossFlickingOptions["sideOptions"];
|
|
61
|
+
|
|
62
|
+
// Internal State
|
|
63
|
+
private _sideState: SideState[];
|
|
64
|
+
private _moveDirection: LiteralUnion<ValueOf<typeof MOVE_DIRECTION>> | null;
|
|
65
|
+
private _nextIndex: number;
|
|
66
|
+
|
|
67
|
+
// Components
|
|
68
|
+
/**
|
|
69
|
+
* {@link Control} instance of the Flicking
|
|
70
|
+
* @ko 현재 Flicking에 활성화된 {@link Control} 인스턴스
|
|
71
|
+
* @type {Control}
|
|
72
|
+
* @default SnapControl
|
|
73
|
+
* @readonly
|
|
74
|
+
* @see Control
|
|
75
|
+
* @see SnapControl
|
|
76
|
+
* @see FreeControl
|
|
77
|
+
*/
|
|
78
|
+
public get sideFlicking() {
|
|
79
|
+
return this._sideFlicking;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Internal States
|
|
83
|
+
/**
|
|
84
|
+
* Whether Flicking's {@link Flicking#init init()} is called.
|
|
85
|
+
* This is `true` when {@link Flicking#init init()} is called, and is `false` after calling {@link Flicking#destroy destroy()}.
|
|
86
|
+
* @ko Flicking의 {@link Flicking#init init()}이 호출되었는지를 나타내는 멤버 변수.
|
|
87
|
+
* 이 값은 {@link Flicking#init init()}이 호출되었으면 `true`로 변하고, {@link Flicking#destroy destroy()}호출 이후에 다시 `false`로 변경됩니다.
|
|
88
|
+
* @type {boolean}
|
|
89
|
+
* @default false
|
|
90
|
+
* @readonly
|
|
91
|
+
*/
|
|
92
|
+
public get sideState() {
|
|
93
|
+
return this._sideState;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Options Getter
|
|
97
|
+
/**
|
|
98
|
+
* Change active panel index on mouse/touch hold while animating.
|
|
99
|
+
* `index` of the `willChange`/`willRestore` event will be used as new index.
|
|
100
|
+
* @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
|
|
101
|
+
* `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
|
|
102
|
+
* @type {FlickingOptions}
|
|
103
|
+
* @default undefined
|
|
104
|
+
* @see {@link https://naver.github.io/egjs-flicking/Options#changeonhold changeOnHold ( Options )}
|
|
105
|
+
*/
|
|
106
|
+
public get sideOptions() {
|
|
107
|
+
return this._sideOptions;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Options Setter
|
|
111
|
+
// public set align(val: FlickingOptions["align"]) {
|
|
112
|
+
// this._align = val;
|
|
113
|
+
// }
|
|
114
|
+
|
|
115
|
+
public constructor(
|
|
116
|
+
root: HTMLElement | string,
|
|
117
|
+
options: Partial<CrossFlickingOptions> = {}
|
|
118
|
+
) {
|
|
119
|
+
super(root, options);
|
|
120
|
+
|
|
121
|
+
// Internal states
|
|
122
|
+
this._sideState = this._createSideState();
|
|
123
|
+
this._moveDirection = null;
|
|
124
|
+
this._nextIndex = 0;
|
|
125
|
+
|
|
126
|
+
// Bind options
|
|
127
|
+
this._sideOptions = options.sideOptions;
|
|
128
|
+
|
|
129
|
+
// Create core components
|
|
130
|
+
this._sideFlicking = this._createSideFlicking();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Initialize Flicking and move to the default index
|
|
135
|
+
* This is automatically called on Flicking's constructor when `autoInit` is true(default)
|
|
136
|
+
* @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
|
|
137
|
+
* 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
|
|
138
|
+
* @fires Flicking#ready
|
|
139
|
+
* @return {Promise<void>}
|
|
140
|
+
*/
|
|
141
|
+
public init(): Promise<void> {
|
|
142
|
+
return super.init().then(() => this._addComponentEvents());
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Destroy Flicking and remove all event handlers
|
|
147
|
+
* @ko Flicking과 하위 컴포넌트들을 초기 상태로 되돌리고, 부착된 모든 이벤트 핸들러를 제거합니다
|
|
148
|
+
* @return {void}
|
|
149
|
+
*/
|
|
150
|
+
public destroy(): void {
|
|
151
|
+
// TODO 모든 child flicking destroy
|
|
152
|
+
super.destroy();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private _addComponentEvents(): void {
|
|
156
|
+
this.on(EVENTS.HOLD_START, this._onHorizontalHoldStart);
|
|
157
|
+
this.on(EVENTS.MOVE, this._onHorizontalMove);
|
|
158
|
+
this.on(EVENTS.MOVE_END, this._onHorizontalMoveEnd);
|
|
159
|
+
|
|
160
|
+
this._sideFlicking.forEach((flicking) => {
|
|
161
|
+
flicking.on(EVENTS.HOLD_START, this._onSideHoldStart);
|
|
162
|
+
flicking.on(EVENTS.MOVE, this._onSideMove);
|
|
163
|
+
flicking.on(EVENTS.MOVE_END, this._onSideMoveEnd);
|
|
164
|
+
flicking.on(EVENTS.CHANGED, this._onSideChanged);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
private _createSideState(): SideState[] {
|
|
169
|
+
// data-index로 분류하기 전에 임시로 모든 children에 대해 side flicking으로 해보자.
|
|
170
|
+
// panels에 data-attributes가 붙어있을 때와 안 붙어있을 때를 다르게 처리
|
|
171
|
+
// 붙어있다면 가상의 viewport들을 index 갯수만큼 만들어줘야 한다
|
|
172
|
+
const viewportEl = this.element;
|
|
173
|
+
const cameraEl = this.camera.element;
|
|
174
|
+
const panels = toArray(cameraEl.children) as HTMLElement[];
|
|
175
|
+
let sideState: SideState[] = [];
|
|
176
|
+
let sidePanels: string = "";
|
|
177
|
+
|
|
178
|
+
// check data attribute exists
|
|
179
|
+
const groupKeys: string[] = [];
|
|
180
|
+
const groupPanels: Record<string, HTMLElement[]> = {};
|
|
181
|
+
const sideCamera = document.createElement("div");
|
|
182
|
+
sideCamera.classList.add(CLASS.CAMERA);
|
|
183
|
+
|
|
184
|
+
const isCrossStructure = getDataAttributes(viewportEl, "data-cross-").structure;
|
|
185
|
+
|
|
186
|
+
if (!isCrossStructure) {
|
|
187
|
+
viewportEl.setAttribute("data-cross-structure", "true");
|
|
188
|
+
|
|
189
|
+
panels.forEach((panel) => {
|
|
190
|
+
const groupKey = getDataAttributes(panel, "data-cross-").groupkey;
|
|
191
|
+
if (groupKey && !includes(groupKeys, groupKey)) {
|
|
192
|
+
groupKeys.push(groupKey);
|
|
193
|
+
groupPanels[groupKey] = [panel];
|
|
194
|
+
} else if (groupKey) {
|
|
195
|
+
groupPanels[groupKey].push(panel);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
if (groupKeys.length) {
|
|
200
|
+
sideState = groupKeys.reduce(
|
|
201
|
+
(state: SideState[], key: string) => {
|
|
202
|
+
const start = state.length ? +state[state.length - 1].end + 1 : 0;
|
|
203
|
+
const element = groupPanels[key].reduce(
|
|
204
|
+
(el: HTMLElement, panel: HTMLElement) => {
|
|
205
|
+
sidePanels += panel.outerHTML;
|
|
206
|
+
el.innerHTML += panel.outerHTML;
|
|
207
|
+
return el;
|
|
208
|
+
},
|
|
209
|
+
document.createElement("div")
|
|
210
|
+
);
|
|
211
|
+
return [
|
|
212
|
+
...state,
|
|
213
|
+
{
|
|
214
|
+
key,
|
|
215
|
+
start,
|
|
216
|
+
end: start + groupPanels[key].length - 1,
|
|
217
|
+
element: element
|
|
218
|
+
}
|
|
219
|
+
];
|
|
220
|
+
},
|
|
221
|
+
[]
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
this.remove(0, this.panelCount - groupKeys.length);
|
|
225
|
+
sideState.forEach((_, i) => {
|
|
226
|
+
const panel = this.camera.children[i];
|
|
227
|
+
Array.from(panel.attributes).forEach(attribute => panel.removeAttribute(attribute.name));
|
|
228
|
+
});
|
|
229
|
+
} else {
|
|
230
|
+
sideState = panels.reduce(
|
|
231
|
+
(state: SideState[], panel: HTMLElement, i: number) => {
|
|
232
|
+
const start = state.length ? +state[state.length - 1].end + 1 : 0;
|
|
233
|
+
sidePanels += panel.innerHTML;
|
|
234
|
+
return [
|
|
235
|
+
...state,
|
|
236
|
+
{
|
|
237
|
+
key: i.toString(),
|
|
238
|
+
start,
|
|
239
|
+
end: start + panel.children.length - 1,
|
|
240
|
+
element: panel
|
|
241
|
+
}
|
|
242
|
+
];
|
|
243
|
+
},
|
|
244
|
+
[]
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
sideCamera.innerHTML = sidePanels;
|
|
249
|
+
sideState.forEach((_, i) => {
|
|
250
|
+
const panel = this.camera.children[i];
|
|
251
|
+
[CLASS.VIEWPORT, CLASS.VERTICAL].forEach((className) => {
|
|
252
|
+
if (!panel.classList.contains(className)) {
|
|
253
|
+
panel.classList.add(className);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
panel.innerHTML = sideCamera.outerHTML;
|
|
257
|
+
});
|
|
258
|
+
} else {
|
|
259
|
+
(toArray(panels[0].children[0].children) as HTMLElement[]).forEach((panel) => {
|
|
260
|
+
const groupKey = getDataAttributes(panel, "data-cross-").groupkey;
|
|
261
|
+
if (groupKey && !includes(groupKeys, groupKey)) {
|
|
262
|
+
groupKeys.push(groupKey);
|
|
263
|
+
groupPanels[groupKey] = [panel];
|
|
264
|
+
} else if (groupKey) {
|
|
265
|
+
groupPanels[groupKey].push(panel);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
sideState = groupKeys.reduce(
|
|
270
|
+
(state: SideState[], key: string) => {
|
|
271
|
+
const start = state.length ? +state[state.length - 1].end + 1 : 0;
|
|
272
|
+
const element = groupPanels[key].reduce(
|
|
273
|
+
(el: HTMLElement, panel: HTMLElement) => {
|
|
274
|
+
el.innerHTML += panel.outerHTML;
|
|
275
|
+
return el;
|
|
276
|
+
},
|
|
277
|
+
document.createElement("div")
|
|
278
|
+
);
|
|
279
|
+
return [
|
|
280
|
+
...state,
|
|
281
|
+
{
|
|
282
|
+
key,
|
|
283
|
+
start,
|
|
284
|
+
end: start + groupPanels[key].length - 1,
|
|
285
|
+
element: element
|
|
286
|
+
}
|
|
287
|
+
];
|
|
288
|
+
},
|
|
289
|
+
[]
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return sideState;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
private _createSideFlicking(): Flicking[] {
|
|
297
|
+
return this.sideState.map((state, i) => {
|
|
298
|
+
return new Flicking(this.camera.children[i], {
|
|
299
|
+
...this.sideOptions,
|
|
300
|
+
horizontal: false,
|
|
301
|
+
panelsPerView: 1,
|
|
302
|
+
defaultIndex: state.start
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
private _syncToCategory(index: number, outerIndex: number): void {
|
|
308
|
+
this.stopAnimation();
|
|
309
|
+
this._sideFlicking.forEach((child, i) => {
|
|
310
|
+
const { start, end } = this._sideState[i];
|
|
311
|
+
|
|
312
|
+
if (start <= index && end >= index && outerIndex !== i) {
|
|
313
|
+
child.stopAnimation();
|
|
314
|
+
void child.moveTo(index, 0);
|
|
315
|
+
void this.moveTo(i, 0);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
private _onHorizontalHoldStart = (): void => {
|
|
321
|
+
this.dragThreshold = 10;
|
|
322
|
+
this._moveDirection = null;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
private _onHorizontalMove = (e: MoveEvent): void => {
|
|
326
|
+
if (e.isTrusted && !this._moveDirection) {
|
|
327
|
+
this._sideFlicking.forEach((child) => {
|
|
328
|
+
child.dragThreshold = Infinity;
|
|
329
|
+
});
|
|
330
|
+
this._moveDirection = MOVE_DIRECTION.HORIZONTAL;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
private _onHorizontalMoveEnd = (e: MoveEndEvent): void => {
|
|
335
|
+
const visiblePanels = this.visiblePanels;
|
|
336
|
+
|
|
337
|
+
this._sideFlicking.forEach((child) => {
|
|
338
|
+
child.dragThreshold = 10;
|
|
339
|
+
});
|
|
340
|
+
this._moveDirection = null;
|
|
341
|
+
|
|
342
|
+
if (visiblePanels.length > 1) {
|
|
343
|
+
this._nextIndex =
|
|
344
|
+
e.direction === "NEXT"
|
|
345
|
+
? visiblePanels[1].index
|
|
346
|
+
: visiblePanels[0].index;
|
|
347
|
+
} else {
|
|
348
|
+
this._nextIndex = visiblePanels[0].index;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 timeout으로 처리
|
|
352
|
+
setTimeout(() => {
|
|
353
|
+
this._sideFlicking.forEach((child, i) => {
|
|
354
|
+
if (this._nextIndex !== i) {
|
|
355
|
+
const { start, end } = this._sideState[i];
|
|
356
|
+
|
|
357
|
+
if (child.index < start) {
|
|
358
|
+
child.stopAnimation();
|
|
359
|
+
void child.moveTo(start, 0);
|
|
360
|
+
} else if (child.index > end) {
|
|
361
|
+
child.stopAnimation();
|
|
362
|
+
void child.moveTo(end, 0);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
if (e.isTrusted) {
|
|
369
|
+
this._syncToCategory(
|
|
370
|
+
this._sideFlicking[this._nextIndex].index,
|
|
371
|
+
this._nextIndex
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
private _onSideHoldStart = (): void => {
|
|
377
|
+
this._sideFlicking.forEach((child) => {
|
|
378
|
+
child.dragThreshold = 10;
|
|
379
|
+
});
|
|
380
|
+
this._moveDirection = null;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
private _onSideMove = (e: MoveEvent): void => {
|
|
384
|
+
if (e.isTrusted && !this._moveDirection) {
|
|
385
|
+
this.dragThreshold = Infinity;
|
|
386
|
+
this._moveDirection = MOVE_DIRECTION.VERTICAL;
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
private _onSideMoveEnd = (): void => {
|
|
391
|
+
this.dragThreshold = 10;
|
|
392
|
+
this._moveDirection = null;
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
private _onSideChanged = (e: ChangedEvent): void => {
|
|
396
|
+
// this.visiblePanels.length 가 2보다 크다면 가로 방향 Flicking이 조작 중이라는 것을 의미합니다.
|
|
397
|
+
// 이 경우 가로 방향 Flicking의 이동이 완전히 끝난 뒤 _onHorizontalMoveEnd 에서 syncToCategory할 것이므로 여기서는 하지 않습니다.
|
|
398
|
+
if (
|
|
399
|
+
this.visiblePanels.length < 2 &&
|
|
400
|
+
this._sideFlicking[this.index] === e.currentTarget
|
|
401
|
+
) {
|
|
402
|
+
this._syncToCategory(e.index, this.index);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
}
|
package/src/camera/Camera.ts
CHANGED
|
@@ -32,7 +32,6 @@ class Camera {
|
|
|
32
32
|
private _mode: CameraMode;
|
|
33
33
|
private _el: HTMLElement;
|
|
34
34
|
private _transform: string;
|
|
35
|
-
private _lookedOffset = 0;
|
|
36
35
|
private _position: number;
|
|
37
36
|
private _alignPos: number;
|
|
38
37
|
private _offset: number;
|
|
@@ -293,8 +292,6 @@ class Camera {
|
|
|
293
292
|
* @return {this}
|
|
294
293
|
*/
|
|
295
294
|
public lookAt(pos: number): void {
|
|
296
|
-
const prevOffset = this._offset;
|
|
297
|
-
const isChangedOffset = this._lookedOffset !== prevOffset;
|
|
298
295
|
const flicking = getFlickingAttached(this._flicking);
|
|
299
296
|
const prevPos = this._position;
|
|
300
297
|
|
|
@@ -307,12 +304,7 @@ class Camera {
|
|
|
307
304
|
if (toggled) {
|
|
308
305
|
void flicking.renderer.render().then(() => {
|
|
309
306
|
this.updateOffset();
|
|
310
|
-
this._lookedOffset = this._offset;
|
|
311
307
|
});
|
|
312
|
-
} else if (isChangedOffset) {
|
|
313
|
-
// sync offset for renderOnlyVisible on resize
|
|
314
|
-
this.updateOffset();
|
|
315
|
-
this._lookedOffset = this._offset;
|
|
316
308
|
} else {
|
|
317
309
|
this.applyTransform();
|
|
318
310
|
}
|
|
@@ -607,7 +599,6 @@ class Camera {
|
|
|
607
599
|
|
|
608
600
|
private _resetInternalValues() {
|
|
609
601
|
this._position = 0;
|
|
610
|
-
this._lookedOffset = 0;
|
|
611
602
|
this._alignPos = 0;
|
|
612
603
|
this._offset = 0;
|
|
613
604
|
this._circularOffset = 0;
|
package/src/const/external.ts
CHANGED
|
@@ -94,6 +94,8 @@ export const MOVE_TYPE = {
|
|
|
94
94
|
} as const;
|
|
95
95
|
|
|
96
96
|
export const CLASS = {
|
|
97
|
+
VIEWPORT: "flicking-viewport",
|
|
98
|
+
CAMERA: "flicking-camera",
|
|
97
99
|
VERTICAL: "vertical",
|
|
98
100
|
HIDDEN: "flicking-hidden",
|
|
99
101
|
DEFAULT_VIRTUAL: "flicking-panel"
|
|
@@ -122,3 +124,15 @@ export const ORDER = {
|
|
|
122
124
|
LTR: "ltr",
|
|
123
125
|
RTL: "rtl"
|
|
124
126
|
} as const;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* An object that contains the direction that {@link Flicking} is moving
|
|
130
|
+
* @ko {@link Flicking}이 움직이는 방향을 담고 있는 객체
|
|
131
|
+
* @type {object}
|
|
132
|
+
* @property {"horizontal"} HORIZONTAL horizontal<ko>수평 방향</ko>
|
|
133
|
+
* @property {"vertical"} VERTICAL vertical<ko>수직 방향</ko>
|
|
134
|
+
*/
|
|
135
|
+
export const MOVE_DIRECTION = {
|
|
136
|
+
HORIZONTAL: "horizontal",
|
|
137
|
+
VERTICAL: "vertical"
|
|
138
|
+
} as const;
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import Flicking from "./Flicking";
|
|
6
6
|
import type { FlickingOptions, FlickingEvents } from "./Flicking";
|
|
7
|
+
import type { CrossFlickingOptions } from "./CrossFlicking";
|
|
8
|
+
|
|
9
|
+
export * from "./CrossFlicking";
|
|
7
10
|
|
|
8
11
|
export * from "./core";
|
|
9
12
|
export * from "./camera";
|
|
@@ -15,6 +18,6 @@ export * from "./utils";
|
|
|
15
18
|
|
|
16
19
|
export * from "./type/event";
|
|
17
20
|
export * from "./type/external";
|
|
18
|
-
export type { FlickingOptions, FlickingEvents };
|
|
21
|
+
export type { FlickingOptions, FlickingEvents, CrossFlickingOptions };
|
|
19
22
|
|
|
20
23
|
export default Flicking;
|
package/src/index.umd.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import Flicking from "./Flicking";
|
|
6
|
+
import * as CrossFlicking from "./CrossFlicking";
|
|
6
7
|
import * as Core from "./core";
|
|
7
8
|
import * as Camera from "./camera";
|
|
8
9
|
import * as Control from "./control";
|
|
@@ -19,5 +20,6 @@ merge(Flicking, Renderer);
|
|
|
19
20
|
merge(Flicking, Constants);
|
|
20
21
|
merge(Flicking, CFC);
|
|
21
22
|
merge(Flicking, Utils);
|
|
23
|
+
merge(Flicking, CrossFlicking);
|
|
22
24
|
|
|
23
25
|
export default Flicking;
|
package/src/utils.ts
CHANGED
|
@@ -349,3 +349,24 @@ export const setPrototypeOf = Object.setPrototypeOf || ((obj, proto) => {
|
|
|
349
349
|
obj.__proto__ = proto;
|
|
350
350
|
return obj;
|
|
351
351
|
});
|
|
352
|
+
|
|
353
|
+
export const camelize = (str: string): string => {
|
|
354
|
+
return str.replace(/[\s-_]([a-z])/g, (all, letter) => letter.toUpperCase());
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
export const getDataAttributes = (element: HTMLElement, attributePrefix: string): Record<string, string> => {
|
|
358
|
+
const dataAttributes: Record<string, string> = {};
|
|
359
|
+
const attributes = element.attributes;
|
|
360
|
+
const length = attributes.length;
|
|
361
|
+
|
|
362
|
+
for (let i = 0; i < length; ++i) {
|
|
363
|
+
const attribute = attributes[i];
|
|
364
|
+
const { name, value } = attribute;
|
|
365
|
+
if (name.indexOf(attributePrefix) === -1) {
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
dataAttributes[camelize(name.replace(attributePrefix, ""))] = value;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
return dataAttributes;
|
|
372
|
+
};
|