@egjs/flicking 4.3.0 → 4.4.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.
Files changed (78) hide show
  1. package/README.md +1 -2
  2. package/declaration/Flicking.d.ts +23 -11
  3. package/declaration/camera/Camera.d.ts +3 -2
  4. package/declaration/camera/CircularCamera.d.ts +2 -1
  5. package/declaration/const/error.d.ts +3 -1
  6. package/declaration/const/external.d.ts +5 -0
  7. package/declaration/core/AutoResizer.d.ts +13 -0
  8. package/declaration/core/VirtualManager.d.ts +37 -0
  9. package/declaration/core/index.d.ts +2 -1
  10. package/declaration/core/panel/Panel.d.ts +13 -7
  11. package/declaration/core/panel/VirtualPanel.d.ts +19 -0
  12. package/declaration/core/panel/index.d.ts +4 -4
  13. package/declaration/core/panel/provider/ElementProvider.d.ts +8 -0
  14. package/declaration/core/panel/provider/VanillaElementProvider.d.ts +12 -0
  15. package/declaration/core/panel/provider/VirtualElementProvider.d.ts +15 -0
  16. package/declaration/core/panel/provider/index.d.ts +5 -0
  17. package/declaration/index.d.ts +11 -1
  18. package/declaration/renderer/ExternalRenderer.d.ts +1 -1
  19. package/declaration/renderer/Renderer.d.ts +17 -12
  20. package/declaration/renderer/VanillaRenderer.d.ts +2 -7
  21. package/declaration/renderer/index.d.ts +1 -0
  22. package/declaration/renderer/strategy/NormalRenderingStrategy.d.ts +23 -0
  23. package/declaration/renderer/strategy/RenderingStrategy.d.ts +15 -0
  24. package/declaration/renderer/strategy/VirtualRenderingStrategy.d.ts +17 -0
  25. package/declaration/renderer/strategy/index.d.ts +5 -0
  26. package/declaration/utils.d.ts +7 -1
  27. package/dist/flicking.esm.js +1401 -421
  28. package/dist/flicking.esm.js.map +1 -1
  29. package/dist/flicking.js +1429 -425
  30. package/dist/flicking.js.map +1 -1
  31. package/dist/flicking.min.js +2 -2
  32. package/dist/flicking.min.js.map +1 -1
  33. package/dist/flicking.pkgd.js +8683 -8061
  34. package/dist/flicking.pkgd.js.map +1 -1
  35. package/dist/flicking.pkgd.min.js +2 -2
  36. package/dist/flicking.pkgd.min.js.map +1 -1
  37. package/package.json +9 -22
  38. package/src/Flicking.ts +146 -30
  39. package/src/camera/BoundCamera.ts +2 -2
  40. package/src/camera/Camera.ts +50 -27
  41. package/src/camera/CircularCamera.ts +52 -27
  42. package/src/camera/LinearCamera.ts +1 -1
  43. package/src/cfc/sync.ts +10 -5
  44. package/src/const/error.ts +6 -3
  45. package/src/const/external.ts +6 -0
  46. package/src/control/AxesController.ts +11 -6
  47. package/src/control/Control.ts +6 -6
  48. package/src/control/FreeControl.ts +2 -2
  49. package/src/control/SnapControl.ts +3 -3
  50. package/src/control/StrictControl.ts +2 -2
  51. package/src/core/AutoResizer.ts +81 -0
  52. package/src/core/Viewport.ts +4 -4
  53. package/src/core/VirtualManager.ts +188 -0
  54. package/src/core/index.ts +3 -1
  55. package/src/core/panel/Panel.ts +54 -34
  56. package/src/core/panel/VirtualPanel.ts +110 -0
  57. package/src/core/panel/index.ts +5 -7
  58. package/src/core/panel/provider/ElementProvider.ts +14 -0
  59. package/src/core/panel/provider/VanillaElementProvider.ts +45 -0
  60. package/src/core/panel/provider/VirtualElementProvider.ts +48 -0
  61. package/src/core/panel/provider/index.ts +16 -0
  62. package/src/index.ts +12 -1
  63. package/src/index.umd.ts +2 -0
  64. package/src/renderer/ExternalRenderer.ts +7 -7
  65. package/src/renderer/Renderer.ts +106 -65
  66. package/src/renderer/VanillaRenderer.ts +28 -86
  67. package/src/renderer/index.ts +2 -0
  68. package/src/renderer/strategy/NormalRenderingStrategy.ts +106 -0
  69. package/src/renderer/strategy/RenderingStrategy.ts +21 -0
  70. package/src/renderer/strategy/VirtualRenderingStrategy.ts +110 -0
  71. package/src/renderer/strategy/index.ts +17 -0
  72. package/src/utils.ts +36 -2
  73. package/declaration/core/panel/ElementPanel.d.ts +0 -14
  74. package/declaration/core/panel/ExternalPanel.d.ts +0 -9
  75. package/declaration/exports.d.ts +0 -10
  76. package/src/core/panel/ElementPanel.ts +0 -52
  77. package/src/core/panel/ExternalPanel.ts +0 -32
  78. package/src/exports.ts +0 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egjs/flicking",
3
- "version": "4.3.0",
3
+ "version": "4.4.2",
4
4
  "description": "Everyday 30 million people experience. It's reliable, flexible and extendable carousel.",
5
5
  "main": "dist/flicking.js",
6
6
  "module": "dist/flicking.esm.js",
@@ -13,9 +13,9 @@
13
13
  "declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json",
14
14
  "css": "postcss css/*.css --use autoprefixer postcss-clean -d dist/ -m",
15
15
  "printsizes": "print-sizes ./dist --exclude=\\.map",
16
- "test": "karma start",
17
- "test:chrome": "karma start --chrome",
18
- "coverage": "karma start --coverage && print-coveralls --sort=desc",
16
+ "test": "npm run test --prefix test/unit",
17
+ "test:chrome": "npm run test:chrome --prefix test/unit",
18
+ "test:cfc": "npm run test --prefix test/cfc",
19
19
  "lint": "eslint 'src/**/*.ts'",
20
20
  "lint:test": "eslint 'test/unit/**/*.ts'",
21
21
  "jsdoc": "jsdoc -c jsdoc.json",
@@ -69,26 +69,22 @@
69
69
  "egjs"
70
70
  ],
71
71
  "devDependencies": {
72
+ "@babel/preset-env": "^7.16.0",
72
73
  "@daybrush/jsdoc": "^0.3.10",
73
- "@egjs/flicking-plugins": "^4.0.0-beta.1",
74
+ "@egjs/flicking-plugins": "^4.2.2",
74
75
  "@egjs/release-helper": "0.0.3",
75
76
  "@rollup/plugin-babel": "^5.3.0",
76
77
  "@rollup/plugin-commonjs": "^11.1.0",
77
78
  "@rollup/plugin-node-resolve": "^7.1.3",
78
79
  "@rollup/plugin-replace": "^2.4.1",
79
- "@types/chai": "^4.2.15",
80
80
  "@types/fs-extra": "^9.0.11",
81
- "@types/karma-chai": "^0.1.1",
82
- "@types/mocha": "^5.2.5",
83
81
  "@types/node": "^14.14.35",
84
- "@types/sinon": "^7.0.3",
85
82
  "@typescript-eslint/eslint-plugin": "^4.18.0",
86
83
  "@typescript-eslint/eslint-plugin-tslint": "^4.18.0",
87
84
  "@typescript-eslint/parser": "^4.18.0",
88
85
  "autoprefixer": "^9.8.5",
89
86
  "babel-loader": "^8.2.2",
90
- "chai": "^4.3.4",
91
- "chalk": "^2.4.2",
87
+ "babel-preset-env": "^1.7.0",
92
88
  "concurrently": "^6.0.0",
93
89
  "core-js": "^3.9.1",
94
90
  "coveralls": "^3.0.2",
@@ -105,15 +101,7 @@
105
101
  "http-serve": "^1.0.1",
106
102
  "husky": "^1.3.1",
107
103
  "jsdoc-to-mdx": "^1.0.5",
108
- "karma": "^3.1.4",
109
- "karma-chai": "^0.1.0",
110
- "karma-chrome-launcher": "^2.2.0",
111
- "karma-mocha": "^1.3.0",
112
- "karma-mocha-reporter": "^2.2.5",
113
- "karma-sinon": "^1.0.5",
114
- "karma-typescript-egjs": "^4.0.0",
115
- "karma-viewport": "^1.0.8",
116
- "mocha": "^5.2.0",
104
+ "karma-typescript-es6-transform": "^5.5.2",
117
105
  "postcss-clean": "^1.2.2",
118
106
  "postcss-cli": "^7.1.1",
119
107
  "print-coveralls": "^1.2.2",
@@ -124,10 +112,9 @@
124
112
  "rollup-plugin-postcss": "^3.1.3",
125
113
  "rollup-plugin-prototype-minify": "^1.1.0",
126
114
  "rollup-plugin-serve": "^1.1.0",
115
+ "rollup-plugin-terser": "^7.0.2",
127
116
  "rollup-plugin-typescript2": "^0.30.0",
128
- "rollup-plugin-uglify": "^6.0.4",
129
117
  "rollup-plugin-visualizer": "^4.2.1",
130
- "sinon": "^7.2.3",
131
118
  "sync-exec": "^0.6.2",
132
119
  "ts-mock-imports": "^1.3.3",
133
120
  "tsconfig-paths-webpack-plugin": "^3.5.1",
package/src/Flicking.ts CHANGED
@@ -6,10 +6,13 @@ import Component, { ComponentEvent } from "@egjs/component";
6
6
 
7
7
  import FlickingError from "./core/FlickingError";
8
8
  import Viewport from "./core/Viewport";
9
+ import AutoResizer from "./core/AutoResizer";
9
10
  import { Panel } from "./core/panel";
11
+ import { VanillaElementProvider } from "./core/panel/provider";
12
+ import VirtualManager, { VirtualOptions } from "./core/VirtualManager";
10
13
  import { Control, SnapControl, SnapControlOptions, FreeControl, StrictControl, FreeControlOptions, StrictControlOptions } from "./control";
11
14
  import { BoundCamera, Camera, CircularCamera, LinearCamera } from "./camera";
12
- import { Renderer, VanillaRenderer, ExternalRenderer } from "./renderer";
15
+ import { Renderer, VanillaRenderer, ExternalRenderer, RendererOptions, NormalRenderingStrategy, VirtualRenderingStrategy } from "./renderer";
13
16
  import { EVENTS, ALIGN, MOVE_TYPE, DIRECTION } from "./const/external";
14
17
  import * as ERROR from "./const/error";
15
18
  import { findIndex, getElement, includes, parseElement } from "./utils";
@@ -72,12 +75,16 @@ export interface FlickingOptions {
72
75
  disableOnInit: boolean;
73
76
  // PERFORMANCE
74
77
  renderOnlyVisible: boolean;
78
+ virtual: VirtualOptions | null;
75
79
  // OTHERS
76
80
  autoInit: boolean;
77
81
  autoResize: boolean;
82
+ useResizeObserver: boolean;
83
+ externalRenderer: ExternalRenderer | null;
84
+ // @deprecated
78
85
  renderExternal: {
79
- renderer: typeof ExternalRenderer;
80
- rendererOptions: {[key: string]: any};
86
+ renderer: new (options: RendererOptions) => ExternalRenderer;
87
+ rendererOptions: RendererOptions;
81
88
  } | null;
82
89
  }
83
90
 
@@ -102,9 +109,11 @@ class Flicking extends Component<FlickingEvents> {
102
109
 
103
110
  // Core components
104
111
  private _viewport: Viewport;
112
+ private _autoResizer: AutoResizer;
105
113
  private _camera: Camera;
106
114
  private _control: Control;
107
115
  private _renderer: Renderer;
116
+ private _virtualManager: VirtualManager;
108
117
 
109
118
  // Options
110
119
  private _align: FlickingOptions["align"];
@@ -116,6 +125,7 @@ class Flicking extends Component<FlickingEvents> {
116
125
  private _panelsPerView: FlickingOptions["panelsPerView"];
117
126
  private _noPanelStyleOverride: FlickingOptions["noPanelStyleOverride"];
118
127
  private _resizeOnContentsReady: FlickingOptions["resizeOnContentsReady"];
128
+ private _virtual: FlickingOptions["virtual"];
119
129
 
120
130
  private _needPanelThreshold: FlickingOptions["needPanelThreshold"];
121
131
  private _preventEventsBeforeInit: FlickingOptions["preventEventsBeforeInit"];
@@ -135,8 +145,10 @@ class Flicking extends Component<FlickingEvents> {
135
145
 
136
146
  private _renderOnlyVisible: FlickingOptions["renderOnlyVisible"];
137
147
 
138
- private _autoResize: FlickingOptions["autoResize"];
139
148
  private _autoInit: FlickingOptions["autoInit"];
149
+ private _autoResize: FlickingOptions["autoResize"];
150
+ private _useResizeObserver: FlickingOptions["useResizeObserver"];
151
+ private _externalRenderer: FlickingOptions["externalRenderer"];
140
152
  private _renderExternal: FlickingOptions["renderExternal"];
141
153
 
142
154
  // Internal State
@@ -207,6 +219,16 @@ class Flicking extends Component<FlickingEvents> {
207
219
  * @readonly
208
220
  */
209
221
  public get circularEnabled() { return this._camera.controlParams.circular; }
222
+ /**
223
+ * Whether the `virtual` option is enabled.
224
+ * The {@link Flicking#virtual virtual} option can't be enabled when {@link Flicking#panelsPerView panelsPerView} is less or equal than zero.
225
+ * @ko {@link Flicking#virtual virtual} 옵션이 활성화되었는지 여부를 나타내는 멤버 변수.
226
+ * {@link Flicking#virtual virtual} 옵션은 {@link Flicking#panelsPerView panelsPerView} 옵션의 값이 0보다 같거나 작으면 비활성화됩니다.
227
+ * @type {boolean}
228
+ * @default false
229
+ * @readonly
230
+ */
231
+ public get virtualEnabled() { return this._panelsPerView > 0 && this._virtual != null; }
210
232
  /**
211
233
  * Index number of the {@link Flicking#currentPanel currentPanel}
212
234
  * @ko {@link Flicking#currentPanel currentPanel}의 인덱스 번호
@@ -515,12 +537,45 @@ class Flicking extends Component<FlickingEvents> {
515
537
  public get disableOnInit() { return this._disableOnInit; }
516
538
  // PERFORMANCE
517
539
  /**
518
- * Whether to render visible panels only. This can dramatically increase performance when there're many panels.
519
- * @ko 보이는 패널만 렌더링할지 여부를 설정합니다. 패널이 많을 경우에 퍼포먼스를 크게 향상시킬 수 있습니다.
540
+ * Whether to render visible panels only. This can dramatically increase performance when there're many panels
541
+ * @ko 보이는 패널만 렌더링할지 여부를 설정합니다. 패널이 많을 경우에 퍼포먼스를 크게 향상시킬 수 있습니다
520
542
  * @type {boolean}
521
543
  * @default false
522
544
  */
523
545
  public get renderOnlyVisible() { return this._renderOnlyVisible; }
546
+ /**
547
+ * By enabling this option, it will reduce memory consumption by restricting the number of DOM elements to `panelsPerView + 1`
548
+ * Must be used with `panelsPerview`.
549
+ * After Flicking's initialized, this property can be used to add/remove the panel count.
550
+ * @ko 이 옵션을 활성화할 경우 패널 엘리먼트의 개수를 `panelsPerView + 1` 개로 고정함으로써, 메모리 사용량을 줄일 수 있습니다.
551
+ * `panelsPerView` 옵션과 함께 사용되어야만 합니다.
552
+ * Flicking 초기화 이후에, 이 프로퍼티는 렌더링하는 패널의 개수를 추가/제거하기 위해 사용될 수 있습니다.
553
+ * @type {VirtualManager}
554
+ * @property {function} renderPanel A rendering function for the panel element's innerHTML<ko>패널 엘리먼트의 innerHTML을 렌더링하는 함수</ko>
555
+ * @property {number} initialPanelCount Initial panel count to render<ko>최초로 렌더링할 패널의 개수</ko>
556
+ * @property {boolean} [cache=false] Whether to cache rendered panel's innerHTML<ko>렌더링된 패널의 innerHTML 정보를 캐시할지 여부</ko>
557
+ * @property {string} [panelClass="flicking-panel"] The class name that will be applied to rendered panel elements<ko>렌더링되는 패널 엘리먼트에 적용될 클래스 이름</ko>
558
+ * @example
559
+ * ```ts
560
+ * import Flicking, { VirtualPanel } from "@egjs/flicking";
561
+ *
562
+ * const flicking = new Flicking("#some_el", {
563
+ * panelsPerView: 3,
564
+ * virtual: {
565
+ * renderPanel: (panel: VirtualPanel, index: number) => `Panel ${index}`,
566
+ * initialPanelCount: 100
567
+ * }
568
+ * });
569
+ *
570
+ * // Add 100 virtual panels (at the end)
571
+ * flicking.virtual.append(100);
572
+ *
573
+ * // Remove 100 virtual panels from 0 to 100
574
+ * flicking.virtual.remove(0, 100);
575
+ * ```
576
+ */
577
+ public get virtual() { return this._virtualManager; }
578
+
524
579
  // OTHERS
525
580
  /**
526
581
  * Call {@link Flicking#init init()} automatically when creating Flicking's instance
@@ -531,22 +586,35 @@ class Flicking extends Component<FlickingEvents> {
531
586
  */
532
587
  public get autoInit() { return this._autoInit; }
533
588
  /**
534
- * Attach Flicking's {@link Flicking#resize resize} method to window's resize event.
535
- * Flicking will automatically call {@link Flicking#resize resize} window size and orientation change.
536
- * @ko Flicking의 {@link Flicking#resize resize} 메소드를 window의 resize 이벤트 핸들러로 등록합니다.
537
- * 설정시 window 창 크기 및 orientation 변경에 의해 자동으로 {@link Flicking#resize resize}를 호출합니다.
589
+ * Whether to automatically call {@link Flicking#resize resize()} when the viewport element(.flicking-viewport)'s size is changed
590
+ * @ko 뷰포트 엘리먼트(.flicking-viewport)의 크기 변경시 {@link Flicking#resize resize()} 메소드를 자동으로 호출할지 여부를 설정합니다
538
591
  * @type {boolean}
539
592
  * @default true
540
593
  */
541
594
  public get autoResize() { return this._autoResize; }
595
+ /**
596
+ * Whether to listen {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}'s event instead of Window's {@link https://developer.mozilla.org/ko/docs/Web/API/Window/resize_event resize} event when using the `autoResize` option
597
+ * @ko autoResize 옵션 사용시 {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}의 이벤트를 Window객체의 {@link https://developer.mozilla.org/ko/docs/Web/API/Window/resize_event resize} 이벤트 대신 수신할지 여부를 설정합니다
598
+ * @type {boolean}
599
+ * @default true
600
+ */
601
+ public get useResizeObserver() { return this._useResizeObserver; }
542
602
  /**
543
603
  * This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
544
604
  * @ko 프레임워크(React, Vue, Angular, ...)에서만 사용하는 옵션으로, 자동으로 설정되므로 따로 사용하실 필요 없습니다!
545
- * @type {boolean}
546
- * @default false
605
+ * @default null
547
606
  * @internal
548
607
  * @readonly
549
608
  */
609
+ public get externalRenderer() { return this._externalRenderer; }
610
+ /**
611
+ * This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
612
+ * @ko 프레임워크(React, Vue, Angular, ...)에서만 사용하는 옵션으로, 자동으로 설정되므로 따로 사용하실 필요 없습니다!
613
+ * @default null
614
+ * @internal
615
+ * @readonly
616
+ * @deprecated
617
+ */
550
618
  public get renderExternal() { return this._renderExternal; }
551
619
 
552
620
  // Options Setter
@@ -599,7 +667,23 @@ class Flicking extends Component<FlickingEvents> {
599
667
  // PERFORMANCE
600
668
  public set renderOnlyVisible(val: FlickingOptions["renderOnlyVisible"]) { this._renderOnlyVisible = val; }
601
669
  // OTHERS
602
- public set autoResize(val: FlickingOptions["autoResize"]) { this._autoResize = val; }
670
+ public set autoResize(val: FlickingOptions["autoResize"]) {
671
+ this._autoResize = val;
672
+
673
+ if (val) {
674
+ this._autoResizer.enable();
675
+ } else {
676
+ this._autoResizer.disable();
677
+ }
678
+ }
679
+
680
+ public set useResizeObserver(val: FlickingOptions["useResizeObserver"]) {
681
+ this._useResizeObserver = val;
682
+
683
+ if (this._autoResize) {
684
+ this._autoResizer.enable();
685
+ }
686
+ }
603
687
 
604
688
  /**
605
689
  * @param root A root HTMLElement to initialize Flicking on it. When it's a typeof `string`, it should be a css selector string
@@ -653,8 +737,11 @@ class Flicking extends Component<FlickingEvents> {
653
737
  preventClickOnDrag = true,
654
738
  disableOnInit = false,
655
739
  renderOnlyVisible = false,
740
+ virtual = null,
656
741
  autoInit = true,
657
742
  autoResize = true,
743
+ useResizeObserver = true,
744
+ externalRenderer = null,
658
745
  renderExternal = null
659
746
  }: Partial<FlickingOptions> = {}) {
660
747
  super();
@@ -673,6 +760,7 @@ class Flicking extends Component<FlickingEvents> {
673
760
  this._panelsPerView = panelsPerView;
674
761
  this._noPanelStyleOverride = noPanelStyleOverride;
675
762
  this._resizeOnContentsReady = resizeOnContentsReady;
763
+ this._virtual = virtual;
676
764
  this._needPanelThreshold = needPanelThreshold;
677
765
  this._preventEventsBeforeInit = preventEventsBeforeInit;
678
766
  this._deceleration = deceleration;
@@ -687,17 +775,19 @@ class Flicking extends Component<FlickingEvents> {
687
775
  this._preventClickOnDrag = preventClickOnDrag;
688
776
  this._disableOnInit = disableOnInit;
689
777
  this._renderOnlyVisible = renderOnlyVisible;
690
- this._autoResize = autoResize;
691
778
  this._autoInit = autoInit;
779
+ this._autoResize = autoResize;
780
+ this._useResizeObserver = useResizeObserver;
781
+ this._externalRenderer = externalRenderer;
692
782
  this._renderExternal = renderExternal;
693
783
 
694
784
  // Create core components
695
785
  this._viewport = new Viewport(getElement(root));
786
+ this._autoResizer = new AutoResizer(this);
696
787
  this._renderer = this._createRenderer();
697
788
  this._camera = this._createCamera();
698
789
  this._control = this._createControl();
699
-
700
- this.resize = this.resize.bind(this);
790
+ this._virtualManager = new VirtualManager(this, virtual);
701
791
 
702
792
  if (this._autoInit) {
703
793
  void this.init();
@@ -718,10 +808,12 @@ class Flicking extends Component<FlickingEvents> {
718
808
  const camera = this._camera;
719
809
  const renderer = this._renderer;
720
810
  const control = this._control;
811
+ const virtualManager = this._virtualManager;
721
812
  const originalTrigger = this.trigger;
722
813
  const preventEventsBeforeInit = this._preventEventsBeforeInit;
723
814
 
724
815
  camera.init(this);
816
+ virtualManager.init();
725
817
  renderer.init(this);
726
818
  control.init(this);
727
819
 
@@ -735,7 +827,7 @@ class Flicking extends Component<FlickingEvents> {
735
827
  await this._moveToInitialPanel();
736
828
 
737
829
  if (this._autoResize) {
738
- window.addEventListener("resize", this.resize);
830
+ this._autoResizer.enable();
739
831
  }
740
832
  if (this._preventClickOnDrag) {
741
833
  control.controller.addPreventClickHandler();
@@ -764,8 +856,8 @@ class Flicking extends Component<FlickingEvents> {
764
856
  */
765
857
  public destroy(): void {
766
858
  this.off();
767
- window.removeEventListener("resize", this.resize);
768
859
 
860
+ this._autoResizer.disable();
769
861
  this._control.destroy();
770
862
  this._camera.destroy();
771
863
  this._renderer.destroy();
@@ -951,7 +1043,7 @@ class Flicking extends Component<FlickingEvents> {
951
1043
  * @param {boolean} [options.includePanelHTML=false] Include panel's `outerHTML` to the returning status<ko>패널의 `outerHTML`을 반환값에 포함시킵니다</ko>
952
1044
  * @param {boolean} [options.visiblePanelsOnly=false] Include only {@link Flicking#visiblePanel visiblePanel}'s HTML. This option is available only when the `includePanelHTML` is true
953
1045
  * <ko>현재 보이는 패널({@link Flicking#visiblePanel visiblePanel})의 HTML만 반환합니다. `includePanelHTML`이 `true`일 경우에만 동작합니다.</ko>
954
- * @return {Partial<Status>} An object with current status value information<ko>현재 상태값 정보를 가진 객체.</ko>
1046
+ * @return {Status} An object with current status value information<ko>현재 상태값 정보를 가진 객체.</ko>
955
1047
  */
956
1048
  public getStatus({
957
1049
  index = true,
@@ -1026,8 +1118,8 @@ class Flicking extends Component<FlickingEvents> {
1026
1118
 
1027
1119
  // Can't add/remove panels on external rendering
1028
1120
  if (panels[0]?.html && !this._renderExternal) {
1029
- renderer.batchRemove({ index: 0, deleteCount: this.panels.length });
1030
- renderer.batchInsert({ index: 0, elements: parseElement(panels.map(panel => panel.html!)) });
1121
+ renderer.batchRemove({ index: 0, deleteCount: this.panels.length, hasDOMInElements: true });
1122
+ renderer.batchInsert({ index: 0, elements: parseElement(panels.map(panel => panel.html!)), hasDOMInElements: true });
1031
1123
  }
1032
1124
 
1033
1125
  if (index) {
@@ -1219,7 +1311,7 @@ class Flicking extends Component<FlickingEvents> {
1219
1311
  throw new FlickingError(ERROR.MESSAGE.NOT_ALLOWED_IN_FRAMEWORK, ERROR.CODE.NOT_ALLOWED_IN_FRAMEWORK);
1220
1312
  }
1221
1313
 
1222
- return this._renderer.batchInsert({ index, elements: parseElement(element) });
1314
+ return this._renderer.batchInsert({ index, elements: parseElement(element), hasDOMInElements: true });
1223
1315
  }
1224
1316
 
1225
1317
  /**
@@ -1236,7 +1328,7 @@ class Flicking extends Component<FlickingEvents> {
1236
1328
  throw new FlickingError(ERROR.MESSAGE.NOT_ALLOWED_IN_FRAMEWORK, ERROR.CODE.NOT_ALLOWED_IN_FRAMEWORK);
1237
1329
  }
1238
1330
 
1239
- return this._renderer.batchRemove({ index, deleteCount });
1331
+ return this._renderer.batchRemove({ index, deleteCount, hasDOMInElements: true });
1240
1332
  }
1241
1333
 
1242
1334
  private _createControl(): Control {
@@ -1282,15 +1374,39 @@ class Flicking extends Component<FlickingEvents> {
1282
1374
  }
1283
1375
 
1284
1376
  private _createRenderer(): Renderer {
1285
- const rendererOptions = {
1286
- align: this._align
1287
- };
1377
+ const externalRenderer = this._externalRenderer;
1378
+ if (this._virtual && this._panelsPerView <= 0) {
1379
+ // eslint-disable-next-line no-console
1380
+ console.warn("\"virtual\" and \"panelsPerView\" option should be used together, ignoring virtual.");
1381
+ }
1382
+
1383
+ return externalRenderer
1384
+ ? externalRenderer
1385
+ : this._renderExternal
1386
+ ? this._createExternalRenderer()
1387
+ : this._createVanillaRenderer();
1388
+ }
1389
+
1390
+ private _createExternalRenderer(): ExternalRenderer {
1391
+ const {
1392
+ renderer,
1393
+ rendererOptions
1394
+ } = this._renderExternal!;
1288
1395
 
1289
- const renderExternal = this._renderExternal;
1396
+ return new (renderer)({ align: this._align, ...rendererOptions });
1397
+ }
1398
+
1399
+ private _createVanillaRenderer(): VanillaRenderer {
1400
+ const virtual = this.virtualEnabled;
1290
1401
 
1291
- return renderExternal
1292
- ? new (renderExternal.renderer as any)({ ...rendererOptions, ...renderExternal.rendererOptions })
1293
- : new VanillaRenderer(rendererOptions);
1402
+ return new VanillaRenderer({
1403
+ align: this._align,
1404
+ strategy: virtual
1405
+ ? new VirtualRenderingStrategy()
1406
+ : new NormalRenderingStrategy({
1407
+ providerCtor: VanillaElementProvider
1408
+ })
1409
+ });
1294
1410
  }
1295
1411
 
1296
1412
  private async _moveToInitialPanel(): Promise<void> {
@@ -23,7 +23,7 @@ class BoundCamera extends Camera {
23
23
  * @return {this}
24
24
  */
25
25
  public updateRange() {
26
- const flicking = getFlickingAttached(this._flicking, "Camera");
26
+ const flicking = getFlickingAttached(this._flicking);
27
27
  const renderer = flicking.renderer;
28
28
  const alignPos = this._alignPos;
29
29
 
@@ -61,7 +61,7 @@ class BoundCamera extends Camera {
61
61
  }
62
62
 
63
63
  public updateAnchors(): this {
64
- const flicking = getFlickingAttached(this._flicking, "Camera");
64
+ const flicking = getFlickingAttached(this._flicking);
65
65
  const panels = flicking.renderer.panels;
66
66
 
67
67
  if (panels.length <= 0) {
@@ -10,7 +10,7 @@ import Panel from "../core/panel/Panel";
10
10
  import AnchorPoint from "../core/AnchorPoint";
11
11
  import * as ERROR from "../const/error";
12
12
  import { ALIGN, DIRECTION, EVENTS } from "../const/external";
13
- import { checkExistence, clamp, find, getFlickingAttached, getProgress, includes, parseAlign } from "../utils";
13
+ import { checkExistence, clamp, find, getFlickingAttached, getProgress, includes, parseAlign, toArray } from "../utils";
14
14
 
15
15
  export interface CameraOptions {
16
16
  align: FlickingOptions["align"];
@@ -38,12 +38,19 @@ abstract class Camera {
38
38
 
39
39
  // Internal states getter
40
40
  /**
41
- * The camera(`.flicking-camera`) element
42
- * @ko 카메라(`.flicking-camera`) 엘리먼트
41
+ * The camera element(`.flicking-camera`)
42
+ * @ko 카메라 엘리먼트(`.flicking-camera`)
43
43
  * @type {HTMLElement}
44
44
  * @readonly
45
45
  */
46
46
  public get element() { return this._el; }
47
+ /**
48
+ * An array of the child elements of the camera element(`.flicking-camera`)
49
+ * @ko 카메라 엘리먼트(`.flicking-camera`)의 자식 엘리먼트 배열
50
+ * @type {HTMLElement[]}
51
+ * @readonly
52
+ */
53
+ public get children() { return toArray(this._el.children) as HTMLElement[]; }
47
54
  /**
48
55
  * Current position of the camera
49
56
  * @ko Camera의 현재 좌표
@@ -71,7 +78,7 @@ abstract class Camera {
71
78
  * @ko Camera의 {@link Camera#position position}이 도달 가능한 범위
72
79
  * @type {object}
73
80
  * @property {number} min A minimum position<ko>최소 위치</ko>
74
- * @property {number} min A maximum position<ko>최대 위치</ko>
81
+ * @property {number} max A maximum position<ko>최대 위치</ko>
75
82
  * @readonly
76
83
  */
77
84
  public get range() { return this._range; }
@@ -278,7 +285,7 @@ abstract class Camera {
278
285
  this._refreshVisiblePanels();
279
286
  this._checkNeedPanel();
280
287
  this._checkReachEnd(prevPos, pos);
281
- this._applyTransform();
288
+ this.applyTransform();
282
289
  }
283
290
 
284
291
  /**
@@ -376,7 +383,7 @@ abstract class Camera {
376
383
  * @return {AnchorPoint | null}
377
384
  */
378
385
  public findActiveAnchor(): AnchorPoint | null {
379
- const flicking = getFlickingAttached(this._flicking, "Camera");
386
+ const flicking = getFlickingAttached(this._flicking);
380
387
  const activeIndex = flicking.control.activeIndex;
381
388
 
382
389
  return find(this._anchors, anchor => anchor.panel.index === activeIndex);
@@ -418,7 +425,7 @@ abstract class Camera {
418
425
  public canSee(panel: Panel): boolean {
419
426
  const visibleRange = this.visibleRange;
420
427
  // Should not include margin, as we don't declare what the margin is visible as what the panel is visible.
421
- return panel.includeRange(visibleRange.min, visibleRange.max, false);
428
+ return panel.isVisibleOnRange(visibleRange.min, visibleRange.max);
422
429
  }
423
430
 
424
431
  /**
@@ -449,7 +456,7 @@ abstract class Camera {
449
456
  * @return {this}
450
457
  */
451
458
  public updateAnchors(): this {
452
- const flicking = getFlickingAttached(this._flicking, "Camera");
459
+ const flicking = getFlickingAttached(this._flicking);
453
460
  const panels = flicking.renderer.panels;
454
461
 
455
462
  this._anchors = panels.map((panel, index) => new AnchorPoint({
@@ -471,7 +478,7 @@ abstract class Camera {
471
478
  * @return {this}
472
479
  */
473
480
  public updateAdaptiveHeight() {
474
- const flicking = getFlickingAttached(this._flicking, "Camera");
481
+ const flicking = getFlickingAttached(this._flicking);
475
482
  const activePanel = flicking.control.activePanel;
476
483
 
477
484
  if (!flicking.horizontal || !flicking.adaptive || !activePanel) return;
@@ -481,16 +488,24 @@ abstract class Camera {
481
488
  });
482
489
  }
483
490
 
484
- public updateOffset() {
485
- const flicking = getFlickingAttached(this._flicking, "Camera");
486
- const unRenderedPanels = flicking.panels.filter(panel => !panel.rendered);
491
+ /**
492
+ * Update current offset of the camera
493
+ * @ko 현재 카메라의 오프셋을 업데이트합니다
494
+ * @chainable
495
+ * @return {this}
496
+ */
497
+ public updateOffset(): this {
498
+ const flicking = getFlickingAttached(this._flicking);
487
499
  const position = this._position;
500
+ const unRenderedPanels = flicking.panels.filter(panel => !panel.rendered);
488
501
 
489
502
  this._offset = unRenderedPanels
490
503
  .filter(panel => panel.position + panel.offset < position)
491
504
  .reduce((offset, panel) => offset + panel.sizeIncludingMargin, 0);
492
505
 
493
- this._applyTransform();
506
+ this.applyTransform();
507
+
508
+ return this;
494
509
  }
495
510
 
496
511
  /**
@@ -504,6 +519,25 @@ abstract class Camera {
504
519
  return this;
505
520
  }
506
521
 
522
+ /**
523
+ * Apply "transform" style with the current position to camera element
524
+ * @ko 현재 위치를 기준으로한 transform 스타일을 카메라 엘리먼트에 적용합니다.
525
+ * @chainable
526
+ * @return {this}
527
+ */
528
+ public applyTransform(): this {
529
+ const el = this._el;
530
+ const flicking = getFlickingAttached(this._flicking);
531
+
532
+ const actualPosition = this._position - this._alignPos - this._offset;
533
+
534
+ el.style[this._transform] = flicking.horizontal
535
+ ? `translate(${-actualPosition}px)`
536
+ : `translate(0, ${-actualPosition}px)`;
537
+
538
+ return this;
539
+ }
540
+
507
541
  protected _resetInternalValues() {
508
542
  this._position = 0;
509
543
  this._alignPos = 0;
@@ -515,7 +549,7 @@ abstract class Camera {
515
549
  }
516
550
 
517
551
  protected _refreshVisiblePanels() {
518
- const flicking = getFlickingAttached(this._flicking, "Camera");
552
+ const flicking = getFlickingAttached(this._flicking);
519
553
  const panels = flicking.renderer.panels;
520
554
 
521
555
  const newVisiblePanels = panels.filter(panel => this.canSee(panel));
@@ -541,7 +575,7 @@ abstract class Camera {
541
575
 
542
576
  if (needPanelTriggered.prev && needPanelTriggered.next) return;
543
577
 
544
- const flicking = getFlickingAttached(this._flicking, "Camera");
578
+ const flicking = getFlickingAttached(this._flicking);
545
579
  const panels = flicking.renderer.panels;
546
580
 
547
581
  if (panels.length <= 0) {
@@ -588,7 +622,7 @@ abstract class Camera {
588
622
  }
589
623
 
590
624
  protected _checkReachEnd(prevPos: number, newPos: number): void {
591
- const flicking = getFlickingAttached(this._flicking, "Camera");
625
+ const flicking = getFlickingAttached(this._flicking);
592
626
  const range = this._range;
593
627
 
594
628
  const wasBetweenRange = prevPos > range.min && prevPos < range.max;
@@ -603,17 +637,6 @@ abstract class Camera {
603
637
  }));
604
638
  }
605
639
 
606
- protected _applyTransform(): void {
607
- const el = this._el;
608
- const flicking = getFlickingAttached(this._flicking, "Camera");
609
-
610
- const actualPosition = this._position - this._alignPos - this._offset;
611
-
612
- el.style[this._transform] = flicking.horizontal
613
- ? `translate(${-actualPosition}px)`
614
- : `translate(0, ${-actualPosition}px)`;
615
- }
616
-
617
640
  protected _checkTranslateSupport = () => {
618
641
  const transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
619
642