@egjs/flicking 4.3.1 → 4.4.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/README.md +1 -1
- package/declaration/Flicking.d.ts +20 -11
- package/declaration/camera/Camera.d.ts +3 -2
- package/declaration/camera/CircularCamera.d.ts +2 -1
- package/declaration/const/error.d.ts +3 -1
- package/declaration/const/external.d.ts +5 -0
- package/declaration/core/AutoResizer.d.ts +13 -0
- package/declaration/core/VirtualManager.d.ts +37 -0
- package/declaration/core/index.d.ts +2 -1
- package/declaration/core/panel/ExternalPanel.d.ts +9 -5
- package/declaration/core/panel/Panel.d.ts +13 -7
- package/declaration/core/panel/VirtualPanel.d.ts +19 -0
- package/declaration/core/panel/index.d.ts +4 -3
- package/declaration/core/panel/provider/ElementProvider.d.ts +7 -0
- package/declaration/core/panel/provider/ExternalElementProvider.d.ts +8 -0
- package/declaration/core/panel/provider/VanillaElementProvider.d.ts +10 -0
- package/declaration/core/panel/provider/VirtualElementProvider.d.ts +13 -0
- package/declaration/core/panel/provider/index.d.ts +6 -0
- package/declaration/index.d.ts +11 -1
- package/declaration/renderer/ExternalRenderer.d.ts +1 -0
- package/declaration/renderer/Renderer.d.ts +17 -12
- package/declaration/renderer/VanillaRenderer.d.ts +2 -7
- package/declaration/renderer/index.d.ts +1 -0
- package/declaration/renderer/strategy/NormalRenderingStrategy.d.ts +25 -0
- package/declaration/renderer/strategy/RenderingStrategy.d.ts +15 -0
- package/declaration/renderer/strategy/VirtualRenderingStrategy.d.ts +17 -0
- package/declaration/renderer/strategy/index.d.ts +5 -0
- package/declaration/utils.d.ts +7 -1
- package/dist/flicking.esm.js +4583 -3686
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +4596 -3674
- 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 +10626 -9704
- 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 +1 -1
- package/src/Flicking.ts +130 -27
- package/src/camera/BoundCamera.ts +2 -2
- package/src/camera/Camera.ts +49 -26
- package/src/camera/CircularCamera.ts +23 -24
- package/src/camera/LinearCamera.ts +1 -1
- package/src/cfc/sync.ts +2 -2
- package/src/const/error.ts +6 -3
- package/src/const/external.ts +6 -0
- package/src/control/AxesController.ts +11 -6
- package/src/control/Control.ts +6 -6
- package/src/control/FreeControl.ts +2 -2
- package/src/control/SnapControl.ts +3 -3
- package/src/control/StrictControl.ts +2 -2
- package/src/core/AutoResizer.ts +81 -0
- package/src/core/VirtualManager.ts +188 -0
- package/src/core/index.ts +3 -1
- package/src/core/panel/ExternalPanel.ts +23 -15
- package/src/core/panel/Panel.ts +54 -34
- package/src/core/panel/VirtualPanel.ts +110 -0
- package/src/core/panel/index.ts +5 -4
- package/src/core/panel/provider/ElementProvider.ts +13 -0
- package/src/core/panel/provider/ExternalElementProvider.ts +15 -0
- package/src/core/panel/provider/VanillaElementProvider.ts +40 -0
- package/src/core/panel/provider/VirtualElementProvider.ts +45 -0
- package/src/core/panel/provider/index.ts +18 -0
- package/src/index.ts +12 -1
- package/src/index.umd.ts +2 -0
- package/src/renderer/ExternalRenderer.ts +36 -4
- package/src/renderer/Renderer.ts +106 -65
- package/src/renderer/VanillaRenderer.ts +28 -86
- package/src/renderer/index.ts +2 -0
- package/src/renderer/strategy/NormalRenderingStrategy.ts +109 -0
- package/src/renderer/strategy/RenderingStrategy.ts +21 -0
- package/src/renderer/strategy/VirtualRenderingStrategy.ts +110 -0
- package/src/renderer/strategy/index.ts +17 -0
- package/src/utils.ts +36 -2
- package/declaration/core/panel/ElementPanel.d.ts +0 -14
- package/declaration/exports.d.ts +0 -10
- package/src/core/panel/ElementPanel.ts +0 -52
- package/src/exports.ts +0 -16
package/src/core/panel/Panel.ts
CHANGED
|
@@ -3,25 +3,34 @@
|
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import Flicking from "../../Flicking";
|
|
6
|
-
import { getProgress, getStyle,
|
|
6
|
+
import { getProgress, getStyle, parseAlign, setSize } from "../../utils";
|
|
7
7
|
import { ALIGN, DIRECTION } from "../../const/external";
|
|
8
8
|
import { LiteralUnion, ValueOf } from "../../type/internal";
|
|
9
9
|
|
|
10
|
+
import ElementProvider from "./provider/ElementProvider";
|
|
11
|
+
|
|
10
12
|
export interface PanelOptions {
|
|
11
13
|
index: number;
|
|
12
14
|
align: LiteralUnion<ValueOf<typeof ALIGN>> | number;
|
|
13
15
|
flicking: Flicking;
|
|
16
|
+
elementProvider: ElementProvider;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
/**
|
|
20
|
+
* A slide data component that holds information of a single HTMLElement
|
|
21
|
+
* @ko 슬라이드 데이터 컴포넌트로, 단일 HTMLElement의 정보를 갖고 있습니다
|
|
22
|
+
*/
|
|
23
|
+
class Panel {
|
|
17
24
|
// Internal States
|
|
18
25
|
protected _flicking: Flicking;
|
|
26
|
+
protected _elProvider: ElementProvider;
|
|
19
27
|
protected _index: number;
|
|
20
28
|
protected _pos: number;
|
|
21
29
|
protected _size: number;
|
|
22
30
|
protected _height: number;
|
|
23
31
|
protected _margin: { prev: number; next: number };
|
|
24
32
|
protected _alignPos: number; // Actual align pos
|
|
33
|
+
protected _rendered: boolean;
|
|
25
34
|
protected _removed: boolean;
|
|
26
35
|
protected _loading: boolean;
|
|
27
36
|
protected _toggleDirection: ValueOf<typeof DIRECTION>;
|
|
@@ -38,7 +47,12 @@ abstract class Panel {
|
|
|
38
47
|
* @type {HTMLElement}
|
|
39
48
|
* @readonly
|
|
40
49
|
*/
|
|
41
|
-
|
|
50
|
+
public get element() { return this._elProvider.element; }
|
|
51
|
+
/**
|
|
52
|
+
* @internal
|
|
53
|
+
* @readonly
|
|
54
|
+
*/
|
|
55
|
+
public get elementProvider() { return this._elProvider; }
|
|
42
56
|
/**
|
|
43
57
|
* Index of the panel
|
|
44
58
|
* @ko 패널의 인덱스
|
|
@@ -104,19 +118,19 @@ abstract class Panel {
|
|
|
104
118
|
*/
|
|
105
119
|
public get removed() { return this._removed; }
|
|
106
120
|
/**
|
|
107
|
-
* A value indicating whether the panel's
|
|
108
|
-
* @ko
|
|
121
|
+
* A value indicating whether the panel's element is being rendered on the screen
|
|
122
|
+
* @ko 패널의 엘리먼트가 화면상에 렌더링되고있는지 여부를 나타내는 값
|
|
109
123
|
* @type {boolean}
|
|
110
124
|
* @readonly
|
|
111
125
|
*/
|
|
112
|
-
public get
|
|
126
|
+
public get rendered() { return this._rendered; }
|
|
113
127
|
/**
|
|
114
|
-
* A value indicating whether the panel's
|
|
115
|
-
* @ko
|
|
128
|
+
* A value indicating whether the panel's image/video is not loaded and waiting for resize
|
|
129
|
+
* @ko 패널 내부의 이미지/비디오가 아직 로드되지 않아 {@link Panel#resize resize}될 것인지를 나타내는 값
|
|
116
130
|
* @type {boolean}
|
|
117
131
|
* @readonly
|
|
118
132
|
*/
|
|
119
|
-
public
|
|
133
|
+
public get loading() { return this._loading; }
|
|
120
134
|
/**
|
|
121
135
|
* Panel element's range of the bounding box
|
|
122
136
|
* @ko 패널 엘리먼트의 Bounding box 범위
|
|
@@ -247,18 +261,22 @@ abstract class Panel {
|
|
|
247
261
|
* @param {number} [options.index] An initial index of the panel<ko>패널의 초기 인덱스</ko>
|
|
248
262
|
* @param {Constants.ALIGN | string | number} [options.align] An initial {@link Flicking#align align} value of the panel<ko>패널의 초기 {@link Flicking#align align}값</ko>
|
|
249
263
|
* @param {Flicking} [options.flicking] A Flicking instance panel's referencing<ko>패널이 참조하는 {@link Flicking} 인스턴스</ko>
|
|
264
|
+
* @param {Flicking} [options.elementProvider] A provider instance that redirects elements<ko>실제 엘리먼트를 반환하는 엘리먼트 공급자의 인스턴스</ko>
|
|
250
265
|
*/
|
|
251
266
|
public constructor({
|
|
252
267
|
index,
|
|
253
268
|
align,
|
|
254
|
-
flicking
|
|
269
|
+
flicking,
|
|
270
|
+
elementProvider
|
|
255
271
|
}: PanelOptions) {
|
|
256
272
|
this._index = index;
|
|
257
273
|
this._flicking = flicking;
|
|
274
|
+
this._elProvider = elementProvider;
|
|
258
275
|
|
|
259
276
|
this._align = align;
|
|
260
277
|
|
|
261
278
|
this._removed = false;
|
|
279
|
+
this._rendered = true;
|
|
262
280
|
this._loading = false;
|
|
263
281
|
this._resetInternalStates();
|
|
264
282
|
}
|
|
@@ -267,13 +285,19 @@ abstract class Panel {
|
|
|
267
285
|
* Mark panel element to be appended on the camera element
|
|
268
286
|
* @internal
|
|
269
287
|
*/
|
|
270
|
-
public
|
|
288
|
+
public markForShow() {
|
|
289
|
+
this._rendered = true;
|
|
290
|
+
this._elProvider.show(this._flicking);
|
|
291
|
+
}
|
|
271
292
|
|
|
272
293
|
/**
|
|
273
294
|
* Mark panel element to be removed from the camera element
|
|
274
295
|
* @internal
|
|
275
296
|
*/
|
|
276
|
-
public
|
|
297
|
+
public markForHide() {
|
|
298
|
+
this._rendered = false;
|
|
299
|
+
this._elProvider.hide(this._flicking);
|
|
300
|
+
}
|
|
277
301
|
|
|
278
302
|
/**
|
|
279
303
|
* Update size of the panel
|
|
@@ -288,7 +312,6 @@ abstract class Panel {
|
|
|
288
312
|
margin: { prev: number; next: number };
|
|
289
313
|
}): this {
|
|
290
314
|
const el = this.element;
|
|
291
|
-
const elStyle = getStyle(el);
|
|
292
315
|
const flicking = this._flicking;
|
|
293
316
|
const horizontal = flicking.horizontal;
|
|
294
317
|
|
|
@@ -297,6 +320,8 @@ abstract class Panel {
|
|
|
297
320
|
this._margin = { ...cached.margin };
|
|
298
321
|
this._height = cached.height;
|
|
299
322
|
} else {
|
|
323
|
+
const elStyle = getStyle(el);
|
|
324
|
+
|
|
300
325
|
this._size = horizontal ? el.offsetWidth : el.offsetHeight;
|
|
301
326
|
this._margin = horizontal
|
|
302
327
|
? {
|
|
@@ -324,29 +349,11 @@ abstract class Panel {
|
|
|
324
349
|
* @chainable
|
|
325
350
|
* @return {this}
|
|
326
351
|
*/
|
|
327
|
-
public setSize({
|
|
328
|
-
width,
|
|
329
|
-
height
|
|
330
|
-
}: Partial<{
|
|
352
|
+
public setSize(size: Partial<{
|
|
331
353
|
width: number | string;
|
|
332
354
|
height: number | string;
|
|
333
355
|
}>): this {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
if (width != null) {
|
|
337
|
-
if (isString(width)) {
|
|
338
|
-
el.style.width = width;
|
|
339
|
-
} else {
|
|
340
|
-
el.style.width = `${width}px`;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
if (height != null) {
|
|
344
|
-
if (isString(height)) {
|
|
345
|
-
el.style.height = height;
|
|
346
|
-
} else {
|
|
347
|
-
el.style.height = `${height}px`;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
356
|
+
setSize(this.element, size);
|
|
350
357
|
|
|
351
358
|
return this;
|
|
352
359
|
}
|
|
@@ -383,7 +390,7 @@ abstract class Panel {
|
|
|
383
390
|
}
|
|
384
391
|
|
|
385
392
|
/**
|
|
386
|
-
* Check whether the given range is fully included in this panel's area
|
|
393
|
+
* Check whether the given range is fully included in this panel's area (inclusive)
|
|
387
394
|
* @ko 주어진 범위가 이 패널 내부에 완전히 포함되는지를 반환합니다
|
|
388
395
|
* @param {number} min Minimum value of the range to check<ko>확인하고자 하는 최소 범위</ko>
|
|
389
396
|
* @param {number} max Maximum value of the range to check<ko>확인하고자 하는 최대 범위</ko>
|
|
@@ -402,6 +409,19 @@ abstract class Panel {
|
|
|
402
409
|
return max >= panelRange.min && min <= panelRange.max;
|
|
403
410
|
}
|
|
404
411
|
|
|
412
|
+
/**
|
|
413
|
+
* Check whether the panel is visble in the given range (exclusive)
|
|
414
|
+
* @ko 주어진 범위 내에서 이 패널의 일부가 보여지는지를 반환합니다
|
|
415
|
+
* @param {number} min Minimum value of the range to check<ko>확인하고자 하는 최소 범위</ko>
|
|
416
|
+
* @param {number} max Maximum value of the range to check<ko>확인하고자 하는 최대 범위</ko>
|
|
417
|
+
* @returns {boolean} A Boolean value indicating whether the panel is visible<ko>해당 범위 내에서 패널을 볼 수 있는지 여부</ko>
|
|
418
|
+
*/
|
|
419
|
+
public isVisibleOnRange(min: number, max: number): boolean {
|
|
420
|
+
const panelRange = this.range;
|
|
421
|
+
|
|
422
|
+
return max > panelRange.min && min < panelRange.max;
|
|
423
|
+
}
|
|
424
|
+
|
|
405
425
|
/**
|
|
406
426
|
* Move {@link Camera} to this panel
|
|
407
427
|
* @ko {@link Camera}를 이 패널로 이동합니다
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
3
|
+
* egjs projects are licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
import { DIRECTION } from "../../const/external";
|
|
6
|
+
import { circulateIndex } from "../../utils";
|
|
7
|
+
|
|
8
|
+
import Panel, { PanelOptions } from "./Panel";
|
|
9
|
+
import VirtualElementProvider from "./provider/VirtualElementProvider";
|
|
10
|
+
|
|
11
|
+
interface VirtualPanelOptions extends PanelOptions {
|
|
12
|
+
elementProvider: VirtualElementProvider;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* An slide data component that holds information of a single HTMLElement
|
|
17
|
+
* @ko 슬라이드 데이터 컴포넌트로, 단일 HTMLElement의 정보를 갖고 있습니다
|
|
18
|
+
*/
|
|
19
|
+
class VirtualPanel extends Panel {
|
|
20
|
+
protected _elProvider: VirtualElementProvider;
|
|
21
|
+
protected _cachedInnerHTML: string | null;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `HTMLElement` that panel's referencing
|
|
25
|
+
* @ko 패널이 참조하고 있는 `HTMLElement`
|
|
26
|
+
* @type {HTMLElement}
|
|
27
|
+
* @readonly
|
|
28
|
+
*/
|
|
29
|
+
public get element() { return this._elProvider.element; }
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Cached innerHTML by the previous render function
|
|
33
|
+
* @ko 이전 렌더링에서 캐시된 innerHTML 정보
|
|
34
|
+
* @type {string|null}
|
|
35
|
+
* @readonly
|
|
36
|
+
*/
|
|
37
|
+
public get cachedInnerHTML() { return this._cachedInnerHTML; }
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* An number for indexing which element it will be rendered on
|
|
41
|
+
* @ko 몇 번째 엘리먼트에 렌더링될 것인지를 나타내는 숫자
|
|
42
|
+
* @type {number}
|
|
43
|
+
* @readonly
|
|
44
|
+
*/
|
|
45
|
+
public get elementIndex() {
|
|
46
|
+
const flicking = this._flicking;
|
|
47
|
+
const virtualElCount = flicking.panelsPerView + 1;
|
|
48
|
+
const panelCount = flicking.panelCount;
|
|
49
|
+
let index = this._index;
|
|
50
|
+
|
|
51
|
+
if (this._toggled) {
|
|
52
|
+
// To prevent element duplication
|
|
53
|
+
index = this._toggleDirection === DIRECTION.NEXT
|
|
54
|
+
? index + panelCount
|
|
55
|
+
: index - panelCount;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return circulateIndex(index, virtualElCount);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {object} options An options object<ko>옵션 오브젝트</ko>
|
|
63
|
+
* @param {number} [options.index] An initial index of the panel<ko>패널의 초기 인덱스</ko>
|
|
64
|
+
* @param {Constants.ALIGN | string | number} [options.align] An initial {@link Flicking#align align} value of the panel<ko>패널의 초기 {@link Flicking#align align}값</ko>
|
|
65
|
+
* @param {Flicking} [options.flicking] A Flicking instance panel's referencing<ko>패널이 참조하는 {@link Flicking} 인스턴스</ko>
|
|
66
|
+
*/
|
|
67
|
+
public constructor(options: VirtualPanelOptions) {
|
|
68
|
+
super(options);
|
|
69
|
+
|
|
70
|
+
options.elementProvider.init(this);
|
|
71
|
+
this._elProvider = options.elementProvider;
|
|
72
|
+
this._cachedInnerHTML = null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public cacheRenderResult(result: string) {
|
|
76
|
+
this._cachedInnerHTML = result;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public uncacheRenderResult() {
|
|
80
|
+
this._cachedInnerHTML = null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public render() {
|
|
84
|
+
const flicking = this._flicking;
|
|
85
|
+
const { renderPanel, cache } = flicking.virtual;
|
|
86
|
+
|
|
87
|
+
const element = this._elProvider.element;
|
|
88
|
+
const newInnerHTML = this._cachedInnerHTML || renderPanel(this, this._index);
|
|
89
|
+
|
|
90
|
+
if (newInnerHTML === element.innerHTML) return;
|
|
91
|
+
|
|
92
|
+
element.innerHTML = newInnerHTML;
|
|
93
|
+
|
|
94
|
+
if (cache) {
|
|
95
|
+
this.cacheRenderResult(newInnerHTML);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public increaseIndex(val: number) {
|
|
100
|
+
this.uncacheRenderResult();
|
|
101
|
+
return super.increaseIndex(val);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public decreaseIndex(val: number) {
|
|
105
|
+
this.uncacheRenderResult();
|
|
106
|
+
return super.decreaseIndex(val);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export default VirtualPanel;
|
package/src/core/panel/index.ts
CHANGED
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import Panel, { PanelOptions } from "./Panel";
|
|
6
|
-
import ElementPanel, { ElementPanelOptions } from "./ElementPanel";
|
|
7
6
|
import ExternalPanel, { ExternalPanelOptions } from "./ExternalPanel";
|
|
7
|
+
import VirtualPanel from "./VirtualPanel";
|
|
8
|
+
|
|
9
|
+
export * from "./provider";
|
|
8
10
|
|
|
9
11
|
export {
|
|
10
12
|
Panel,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
ExternalPanel,
|
|
14
|
+
VirtualPanel
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
export type {
|
|
16
18
|
PanelOptions,
|
|
17
|
-
ElementPanelOptions,
|
|
18
19
|
ExternalPanelOptions
|
|
19
20
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
3
|
+
* egjs projects are licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
import Flicking from "../../../Flicking";
|
|
6
|
+
|
|
7
|
+
interface ElementProvider {
|
|
8
|
+
element: HTMLElement;
|
|
9
|
+
show(flicking: Flicking): void;
|
|
10
|
+
hide(flicking: Flicking): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default ElementProvider;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
3
|
+
* egjs projects are licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
import Flicking from "../../../Flicking";
|
|
6
|
+
|
|
7
|
+
import ElementProvider from "./ElementProvider";
|
|
8
|
+
|
|
9
|
+
interface ExternalElementProvider extends ElementProvider {
|
|
10
|
+
rendered: boolean;
|
|
11
|
+
show(flicking: Flicking): any;
|
|
12
|
+
hide(flicking: Flicking): any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default ExternalElementProvider;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
3
|
+
* egjs projects are licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
import Flicking from "../../../Flicking";
|
|
6
|
+
|
|
7
|
+
import ElementProvider from "./ElementProvider";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
class VanillaElementProvider implements ElementProvider {
|
|
13
|
+
private _element: HTMLElement;
|
|
14
|
+
|
|
15
|
+
public get element() { return this._element; }
|
|
16
|
+
|
|
17
|
+
public constructor(element: HTMLElement) {
|
|
18
|
+
this._element = element;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public show(flicking: Flicking): void {
|
|
22
|
+
const el = this.element;
|
|
23
|
+
const cameraEl = flicking.camera.element;
|
|
24
|
+
|
|
25
|
+
if (el.parentElement !== cameraEl) {
|
|
26
|
+
cameraEl.appendChild(el);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public hide(flicking: Flicking): void {
|
|
31
|
+
const el = this.element;
|
|
32
|
+
const cameraEl = flicking.camera.element;
|
|
33
|
+
|
|
34
|
+
if (el.parentElement === cameraEl) {
|
|
35
|
+
cameraEl.removeChild(el);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default VanillaElementProvider;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
3
|
+
* egjs projects are licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import Flicking from "../../../Flicking";
|
|
7
|
+
import VirtualPanel from "../VirtualPanel";
|
|
8
|
+
|
|
9
|
+
import ElementProvider from "./ElementProvider";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
class VirtualElementProvider implements ElementProvider {
|
|
15
|
+
private _flicking: Flicking;
|
|
16
|
+
private _panel: VirtualPanel;
|
|
17
|
+
|
|
18
|
+
public get element() {
|
|
19
|
+
const flicking = this._flicking;
|
|
20
|
+
const elIndex = this._panel.elementIndex;
|
|
21
|
+
const virtualElements = flicking.virtual.elements;
|
|
22
|
+
|
|
23
|
+
return virtualElements[elIndex].nativeElement;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public constructor(flicking: Flicking) {
|
|
27
|
+
this._flicking = flicking;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public init(panel: VirtualPanel) {
|
|
31
|
+
this._panel = panel;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public show(): void {
|
|
35
|
+
// DO_NOTHING
|
|
36
|
+
// Actual element visibility is controlled by VirtualManager
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public hide(): void {
|
|
40
|
+
// DO_NOTHING
|
|
41
|
+
// Actual element visibility is controlled by VirtualManager
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default VirtualElementProvider;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 NAVER Corp.
|
|
3
|
+
* egjs projects are licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
import ElementProvider from "./ElementProvider";
|
|
6
|
+
import ExternalElementProvider from "./ExternalElementProvider";
|
|
7
|
+
import VanillaElementProvider from "./VanillaElementProvider";
|
|
8
|
+
import VirtualElementProvider from "./VirtualElementProvider";
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
VanillaElementProvider,
|
|
12
|
+
VirtualElementProvider
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type {
|
|
16
|
+
ElementProvider,
|
|
17
|
+
ExternalElementProvider
|
|
18
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,18 @@
|
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import Flicking from "./Flicking";
|
|
6
|
+
import type { FlickingOptions, FlickingEvents } from "./Flicking";
|
|
6
7
|
|
|
7
|
-
export * from "./
|
|
8
|
+
export * from "./core";
|
|
9
|
+
export * from "./camera";
|
|
10
|
+
export * from "./control";
|
|
11
|
+
export * from "./renderer";
|
|
12
|
+
export * from "./const/external";
|
|
13
|
+
export * from "./cfc";
|
|
14
|
+
export * from "./utils";
|
|
15
|
+
|
|
16
|
+
export * from "./type/event";
|
|
17
|
+
export * from "./type/external";
|
|
18
|
+
export type { FlickingOptions, FlickingEvents };
|
|
8
19
|
|
|
9
20
|
export default Flicking;
|
package/src/index.umd.ts
CHANGED
|
@@ -9,6 +9,7 @@ import * as Control from "./control";
|
|
|
9
9
|
import * as Renderer from "./renderer";
|
|
10
10
|
import * as Constants from "./const/external";
|
|
11
11
|
import * as CFC from "./cfc";
|
|
12
|
+
import * as Utils from "./utils";
|
|
12
13
|
import { merge } from "./utils";
|
|
13
14
|
|
|
14
15
|
merge(Flicking, Core);
|
|
@@ -17,5 +18,6 @@ merge(Flicking, Control);
|
|
|
17
18
|
merge(Flicking, Renderer);
|
|
18
19
|
merge(Flicking, Constants);
|
|
19
20
|
merge(Flicking, CFC);
|
|
21
|
+
merge(Flicking, Utils);
|
|
20
22
|
|
|
21
23
|
export default Flicking;
|
|
@@ -10,15 +10,47 @@ import Renderer from "./Renderer";
|
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
abstract class ExternalRenderer extends Renderer {
|
|
13
|
-
|
|
13
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
14
14
|
protected _insertPanelElements(panels: Panel[], nextSibling: Panel | null): void {
|
|
15
|
-
// DO NOTHING
|
|
15
|
+
// DO NOTHING, overrided to prevent an unexpected error
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
18
|
protected _removePanelElements(panels: Panel[]): void {
|
|
20
|
-
// DO NOTHING
|
|
19
|
+
// DO NOTHING, overrided to prevent an unexpected error
|
|
21
20
|
}
|
|
21
|
+
|
|
22
|
+
protected _removeAllChildsFromCamera(): void {
|
|
23
|
+
// DO NOTHING, overrided to prevent an unexpected error
|
|
24
|
+
}
|
|
25
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
26
|
+
|
|
27
|
+
// protected _renderVirtualPanels() {
|
|
28
|
+
// const flicking = getFlickingAttached(this._flicking);
|
|
29
|
+
// const virtualManager = this._virtualManager;
|
|
30
|
+
|
|
31
|
+
// if (!virtualManager) return;
|
|
32
|
+
|
|
33
|
+
// const elements = virtualManager.elements;
|
|
34
|
+
// const visiblePanels = flicking.visiblePanels as VirtualPanel[];
|
|
35
|
+
// const invisibles = elements.map((_, idx) => idx);
|
|
36
|
+
|
|
37
|
+
// visiblePanels.forEach(panel => {
|
|
38
|
+
// const virtualEl = panel.virtualElement;
|
|
39
|
+
|
|
40
|
+
// invisibles[virtualEl.index] = -1;
|
|
41
|
+
// virtualEl.renderingPanel = panel;
|
|
42
|
+
// virtualEl.show();
|
|
43
|
+
// panel.markForShow();
|
|
44
|
+
// });
|
|
45
|
+
|
|
46
|
+
// invisibles.filter(val => val >= 0)
|
|
47
|
+
// .forEach(idx => {
|
|
48
|
+
// const virtualEl = elements[idx];
|
|
49
|
+
// virtualEl.hide();
|
|
50
|
+
// virtualEl.renderingPanel?.markForHide();
|
|
51
|
+
// virtualEl.renderingPanel = null;
|
|
52
|
+
// });
|
|
53
|
+
// }
|
|
22
54
|
}
|
|
23
55
|
|
|
24
56
|
export default ExternalRenderer;
|