@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/src/Flicking.ts CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  FreeControl,
18
18
  StrictControl,
19
19
  FreeControlOptions,
20
- StrictControlOptions,
20
+ StrictControlOptions
21
21
  } from "./control";
22
22
  import { Camera } from "./camera";
23
23
  import {
@@ -26,14 +26,14 @@ import {
26
26
  ExternalRenderer,
27
27
  RendererOptions,
28
28
  NormalRenderingStrategy,
29
- VirtualRenderingStrategy,
29
+ VirtualRenderingStrategy
30
30
  } from "./renderer";
31
31
  import {
32
32
  EVENTS,
33
33
  ALIGN,
34
34
  MOVE_TYPE,
35
35
  DIRECTION,
36
- CIRCULAR_FALLBACK,
36
+ CIRCULAR_FALLBACK
37
37
  } from "./const/external";
38
38
  import * as ERROR from "./const/error";
39
39
  import { findIndex, getElement, includes, parseElement } from "./utils";
@@ -54,7 +54,7 @@ import {
54
54
  BeforeResizeEvent,
55
55
  ChangedEvent,
56
56
  RestoredEvent,
57
- PanelChangeEvent,
57
+ PanelChangeEvent
58
58
  } from "./type/event";
59
59
  import { LiteralUnion, ValueOf } from "./type/internal";
60
60
  import { ElementLike, Plugin, Status, MoveTypeOptions } from "./type/external";
@@ -88,9 +88,9 @@ export interface FlickingEvents {
88
88
  export interface FlickingOptions {
89
89
  // UI / LAYOUT
90
90
  align:
91
- | LiteralUnion<ValueOf<typeof ALIGN>>
92
- | number
93
- | { panel: number | string; camera: number | string };
91
+ | LiteralUnion<ValueOf<typeof ALIGN>>
92
+ | number
93
+ | { panel: number | string; camera: number | string };
94
94
  defaultIndex: number;
95
95
  horizontal: boolean;
96
96
  circular: boolean;
@@ -114,8 +114,8 @@ export interface FlickingOptions {
114
114
  // INPUT
115
115
  inputType: string[];
116
116
  moveType:
117
- | ValueOf<typeof MOVE_TYPE>
118
- | MoveTypeOptions<ValueOf<typeof MOVE_TYPE>>;
117
+ | ValueOf<typeof MOVE_TYPE>
118
+ | MoveTypeOptions<ValueOf<typeof MOVE_TYPE>>;
119
119
  threshold: number;
120
120
  dragThreshold: number;
121
121
  interruptable: boolean;
@@ -135,6 +135,7 @@ export interface FlickingOptions {
135
135
  autoResize: boolean;
136
136
  useResizeObserver: boolean;
137
137
  resizeDebounce: number;
138
+ observePanelResize: boolean;
138
139
  maxResizeDebounce: number;
139
140
  useFractionalSize: boolean;
140
141
  externalRenderer: ExternalRenderer | null;
@@ -213,6 +214,7 @@ class Flicking extends Component<FlickingEvents> {
213
214
  private _autoResize: FlickingOptions["autoResize"];
214
215
  private _useResizeObserver: FlickingOptions["useResizeObserver"];
215
216
  private _resizeDebounce: FlickingOptions["resizeDebounce"];
217
+ private _observePanelResize: FlickingOptions["observePanelResize"];
216
218
  private _maxResizeDebounce: FlickingOptions["maxResizeDebounce"];
217
219
  private _useFractionalSize: FlickingOptions["useFractionalSize"];
218
220
  private _externalRenderer: FlickingOptions["externalRenderer"];
@@ -238,6 +240,7 @@ class Flicking extends Component<FlickingEvents> {
238
240
  public get control() {
239
241
  return this._control;
240
242
  }
243
+
241
244
  /**
242
245
  * {@link Camera} instance of the Flicking
243
246
  * @ko 현재 Flicking에 활성화된 {@link Camera} 인스턴스
@@ -252,6 +255,7 @@ class Flicking extends Component<FlickingEvents> {
252
255
  public get camera() {
253
256
  return this._camera;
254
257
  }
258
+
255
259
  /**
256
260
  * {@link Renderer} instance of the Flicking
257
261
  * @ko 현재 Flicking에 활성화된 {@link Renderer} 인스턴스
@@ -265,6 +269,7 @@ class Flicking extends Component<FlickingEvents> {
265
269
  public get renderer() {
266
270
  return this._renderer;
267
271
  }
272
+
268
273
  /**
269
274
  * A component that manages viewport size
270
275
  * @ko 뷰포트 크기 정보를 담당하는 컴포넌트
@@ -272,9 +277,14 @@ class Flicking extends Component<FlickingEvents> {
272
277
  * @readonly
273
278
  * @see Viewport
274
279
  */
275
- public get viewport() {
276
- return this._viewport;
277
- }
280
+ public get viewport() { return this._viewport; }
281
+ /**
282
+ * {@link AutoResizer} instance of the Flicking
283
+ * @ko 현재 Flicking에 활성화된 {@link AutoResizer} 인스턴스
284
+ * @internal
285
+ * @readonly
286
+ */
287
+ public get autoResizer() { return this._autoResizer; }
278
288
  // Internal States
279
289
  /**
280
290
  * Whether Flicking's {@link Flicking#init init()} is called.
@@ -288,6 +298,7 @@ class Flicking extends Component<FlickingEvents> {
288
298
  public get initialized() {
289
299
  return this._initialized;
290
300
  }
301
+
291
302
  /**
292
303
  * Whether the `circular` option is enabled.
293
304
  * The {@link Flicking#circular circular} option can't be enabled when sum of the panel sizes are too small.
@@ -300,6 +311,7 @@ class Flicking extends Component<FlickingEvents> {
300
311
  public get circularEnabled() {
301
312
  return this._camera.circularEnabled;
302
313
  }
314
+
303
315
  /**
304
316
  * Whether the `virtual` option is enabled.
305
317
  * The {@link Flicking#virtual virtual} option can't be enabled when {@link Flicking#panelsPerView panelsPerView} is less or equal than zero.
@@ -312,6 +324,7 @@ class Flicking extends Component<FlickingEvents> {
312
324
  public get virtualEnabled() {
313
325
  return this._panelsPerView > 0 && this._virtual != null;
314
326
  }
327
+
315
328
  /**
316
329
  * Index number of the {@link Flicking#currentPanel currentPanel}
317
330
  * @ko {@link Flicking#currentPanel currentPanel}의 인덱스 번호
@@ -322,6 +335,7 @@ class Flicking extends Component<FlickingEvents> {
322
335
  public get index() {
323
336
  return this._control.activeIndex;
324
337
  }
338
+
325
339
  /**
326
340
  * The root(`.flicking-viewport`) element
327
341
  * @ko root(`.flicking-viewport`) 엘리먼트
@@ -331,6 +345,7 @@ class Flicking extends Component<FlickingEvents> {
331
345
  public get element() {
332
346
  return this._viewport.element;
333
347
  }
348
+
334
349
  /**
335
350
  * Currently active panel
336
351
  * @ko 현재 선택된 패널
@@ -341,6 +356,7 @@ class Flicking extends Component<FlickingEvents> {
341
356
  public get currentPanel() {
342
357
  return this._control.activePanel;
343
358
  }
359
+
344
360
  /**
345
361
  * Array of panels
346
362
  * @ko 전체 패널들의 배열
@@ -351,6 +367,7 @@ class Flicking extends Component<FlickingEvents> {
351
367
  public get panels() {
352
368
  return this._renderer.panels;
353
369
  }
370
+
354
371
  /**
355
372
  * Count of panels
356
373
  * @ko 전체 패널의 개수
@@ -360,6 +377,7 @@ class Flicking extends Component<FlickingEvents> {
360
377
  public get panelCount() {
361
378
  return this._renderer.panelCount;
362
379
  }
380
+
363
381
  /**
364
382
  * Array of panels that is visible at the current position
365
383
  * @ko 현재 보이는 패널의 배열
@@ -370,6 +388,7 @@ class Flicking extends Component<FlickingEvents> {
370
388
  public get visiblePanels() {
371
389
  return this._camera.visiblePanels;
372
390
  }
391
+
373
392
  /**
374
393
  * Whether Flicking's animating
375
394
  * @ko 현재 애니메이션 동작 여부
@@ -379,6 +398,7 @@ class Flicking extends Component<FlickingEvents> {
379
398
  public get animating() {
380
399
  return this._control.animating;
381
400
  }
401
+
382
402
  /**
383
403
  * Whether user is clicking or touching
384
404
  * @ko 현재 사용자가 클릭/터치중인지 여부
@@ -388,6 +408,7 @@ class Flicking extends Component<FlickingEvents> {
388
408
  public get holding() {
389
409
  return this._control.holding;
390
410
  }
411
+
391
412
  /**
392
413
  * A current list of activated plugins
393
414
  * @ko 현재 활성화된 플러그인 목록
@@ -431,6 +452,7 @@ class Flicking extends Component<FlickingEvents> {
431
452
  public get align() {
432
453
  return this._align;
433
454
  }
455
+
434
456
  /**
435
457
  * Index of the panel to move when Flicking's {@link Flicking#init init()} is called. A zero-based integer
436
458
  * @ko Flicking의 {@link Flicking#init init()}이 호출될 때 이동할 디폴트 패널의 인덱스로, 0부터 시작하는 정수입니다.
@@ -441,6 +463,7 @@ class Flicking extends Component<FlickingEvents> {
441
463
  public get defaultIndex() {
442
464
  return this._defaultIndex;
443
465
  }
466
+
444
467
  /**
445
468
  * Direction of panel movement (true: horizontal, false: vertical)
446
469
  * @ko 패널 이동 방향 (true: 가로방향, false: 세로방향)
@@ -451,6 +474,7 @@ class Flicking extends Component<FlickingEvents> {
451
474
  public get horizontal() {
452
475
  return this._horizontal;
453
476
  }
477
+
454
478
  /**
455
479
  * Enables circular(continuous loop) mode, which connects first/last panel for continuous scrolling.
456
480
  * @ko 순환 모드를 활성화합니다. 순환 모드에서는 양 끝의 패널이 서로 연결되어 끊김없는 스크롤이 가능합니다.
@@ -461,6 +485,7 @@ class Flicking extends Component<FlickingEvents> {
461
485
  public get circular() {
462
486
  return this._circular;
463
487
  }
488
+
464
489
  /**
465
490
  * Set panel control mode for the case when circular cannot be enabled.
466
491
  * "linear" will set the view's range from the top of the first panel to the top of the last panel.
@@ -476,6 +501,7 @@ class Flicking extends Component<FlickingEvents> {
476
501
  public get circularFallback() {
477
502
  return this._circularFallback;
478
503
  }
504
+
479
505
  /**
480
506
  * Prevent the view(camera element) from going out of the first/last panel, so it won't show empty spaces before/after the first/last panel
481
507
  * Only can be enabled when `circular=false`
@@ -488,6 +514,7 @@ class Flicking extends Component<FlickingEvents> {
488
514
  public get bound() {
489
515
  return this._bound;
490
516
  }
517
+
491
518
  /**
492
519
  * Update height of the viewport element after movement same to the height of the panel below. This can be only enabled when `horizontal=true`
493
520
  * @ko 이동한 후 뷰포트 엘리먼트의 크기를 현재 패널의 높이와 동일하게 설정합니다. `horizontal=true`인 경우에만 사용할 수 있습니다.
@@ -498,6 +525,7 @@ class Flicking extends Component<FlickingEvents> {
498
525
  public get adaptive() {
499
526
  return this._adaptive;
500
527
  }
528
+
501
529
  /**
502
530
  * A visible number of panels on viewport. Enabling this option will automatically resize panel size
503
531
  * @ko 한 화면에 보이는 패널의 개수. 이 옵션을 활성화할 경우 패널의 크기를 강제로 재조정합니다
@@ -508,6 +536,7 @@ class Flicking extends Component<FlickingEvents> {
508
536
  public get panelsPerView() {
509
537
  return this._panelsPerView;
510
538
  }
539
+
511
540
  /**
512
541
  * Enabling this option will not change `width/height` style of the panels if {@link Flicking#panelsPerView} is enabled.
513
542
  * This behavior can be useful in terms of performance when you're manually managing all panel sizes
@@ -519,6 +548,7 @@ class Flicking extends Component<FlickingEvents> {
519
548
  public get noPanelStyleOverride() {
520
549
  return this._noPanelStyleOverride;
521
550
  }
551
+
522
552
  /**
523
553
  * Enabling this option will automatically call {@link Flicking#resize} when all image/video inside panels are loaded.
524
554
  * This can be useful when you have contents inside Flicking that changes its size when it's loaded
@@ -531,6 +561,7 @@ class Flicking extends Component<FlickingEvents> {
531
561
  public get resizeOnContentsReady() {
532
562
  return this._resizeOnContentsReady;
533
563
  }
564
+
534
565
  /**
535
566
  * If you enable this option on child Flicking when the Flicking is placed inside the Flicking, the parent Flicking will move in the same direction after the child Flicking reaches the first/last panel.
536
567
  * If the parent Flicking and child Flicking have different horizontal option, you do not need to set this option.
@@ -543,6 +574,7 @@ class Flicking extends Component<FlickingEvents> {
543
574
  public get nested() {
544
575
  return this._nested;
545
576
  }
577
+
546
578
  // EVENTS
547
579
  /**
548
580
  * A Threshold from viewport edge before triggering `needPanel` event
@@ -554,6 +586,7 @@ class Flicking extends Component<FlickingEvents> {
554
586
  public get needPanelThreshold() {
555
587
  return this._needPanelThreshold;
556
588
  }
589
+
557
590
  /**
558
591
  * When enabled, events are not triggered before `ready` when initializing
559
592
  * @ko 활성화할 경우 초기화시 `ready` 이벤트 이전의 이벤트가 발생하지 않습니다.
@@ -564,6 +597,7 @@ class Flicking extends Component<FlickingEvents> {
564
597
  public get preventEventsBeforeInit() {
565
598
  return this._preventEventsBeforeInit;
566
599
  }
600
+
567
601
  // ANIMATION
568
602
  /**
569
603
  * Deceleration value for panel movement animation which is triggered by user input. A higher value means a shorter animation time
@@ -575,6 +609,7 @@ class Flicking extends Component<FlickingEvents> {
575
609
  public get deceleration() {
576
610
  return this._deceleration;
577
611
  }
612
+
578
613
  /**
579
614
  * An easing function applied to the panel movement animation. Default value is `easeOutCubic`
580
615
  * @ko 패널 이동 애니메이션에 적용할 easing 함수. 기본값은 `easeOutCubic`이다
@@ -586,6 +621,7 @@ class Flicking extends Component<FlickingEvents> {
586
621
  public get easing() {
587
622
  return this._easing;
588
623
  }
624
+
589
625
  /**
590
626
  * Default duration of the animation (ms)
591
627
  * @ko 디폴트 애니메이션 재생 시간 (ms)
@@ -596,6 +632,7 @@ class Flicking extends Component<FlickingEvents> {
596
632
  public get duration() {
597
633
  return this._duration;
598
634
  }
635
+
599
636
  // INPUT
600
637
  /**
601
638
  * Types of input devices to enable
@@ -609,6 +646,7 @@ class Flicking extends Component<FlickingEvents> {
609
646
  public get inputType() {
610
647
  return this._inputType;
611
648
  }
649
+
612
650
  /**
613
651
  * Movement style by user input. This will change instance type of {@link Flicking#control}
614
652
  * You can use the values of the constant {@link MOVE_TYPE}
@@ -643,6 +681,7 @@ class Flicking extends Component<FlickingEvents> {
643
681
  public get moveType() {
644
682
  return this._moveType;
645
683
  }
684
+
646
685
  /**
647
686
  * Movement threshold to change panel (unit: px). It should be dragged above the threshold to change the current panel.
648
687
  * @ko 패널 변경을 위한 이동 임계값 (단위: px). 주어진 값 이상으로 스크롤해야만 패널 변경이 가능합니다.
@@ -653,6 +692,7 @@ class Flicking extends Component<FlickingEvents> {
653
692
  public get threshold() {
654
693
  return this._threshold;
655
694
  }
695
+
656
696
  /**
657
697
  * Minimal distance of user input before recognizing (unit: px). It should be dragged above the dragThreshold to move the panel.
658
698
  * @ko 사용자의 입력을 인식하기 위한 최소한의 거리 (단위: px). 주어진 값 이상으로 스크롤해야만 패널이 움직입니다.
@@ -663,6 +703,7 @@ class Flicking extends Component<FlickingEvents> {
663
703
  public get dragThreshold() {
664
704
  return this._dragThreshold;
665
705
  }
706
+
666
707
  /**
667
708
  * Set animation to be interruptable by click/touch.
668
709
  * @ko 사용자의 클릭/터치로 인해 애니메이션을 도중에 멈출 수 있도록 설정합니다.
@@ -673,6 +714,7 @@ class Flicking extends Component<FlickingEvents> {
673
714
  public get interruptable() {
674
715
  return this._interruptable;
675
716
  }
717
+
676
718
  /**
677
719
  * The size value of the bounce area. Only can be enabled when `circular=false`.
678
720
  * You can set different bounce value for prev/next direction by using array.
@@ -708,6 +750,7 @@ class Flicking extends Component<FlickingEvents> {
708
750
  public get bounce() {
709
751
  return this._bounce;
710
752
  }
753
+
711
754
  /**
712
755
  * Size of the area from the right edge in iOS safari (in px) which enables swipe-back or swipe-forward
713
756
  * @ko iOS Safari에서 swipe를 통한 뒤로가기/앞으로가기를 활성화하는 오른쪽 끝으로부터의 영역의 크기 (px)
@@ -718,6 +761,7 @@ class Flicking extends Component<FlickingEvents> {
718
761
  public get iOSEdgeSwipeThreshold() {
719
762
  return this._iOSEdgeSwipeThreshold;
720
763
  }
764
+
721
765
  /**
722
766
  * Automatically prevent `click` event if the user has dragged at least a single pixel on the viewport element
723
767
  * @ko 사용자가 뷰포트 영역을 1픽셀이라도 드래그했을 경우 자동으로 {@link https://developer.mozilla.org/ko/docs/Web/API/Element/click_event click} 이벤트를 취소합니다
@@ -728,6 +772,7 @@ class Flicking extends Component<FlickingEvents> {
728
772
  public get preventClickOnDrag() {
729
773
  return this._preventClickOnDrag;
730
774
  }
775
+
731
776
  /**
732
777
  * Whether to use the {@link https://developer.mozilla.org/ko/docs/Web/API/Event/preventDefault preventDefault} when the user starts dragging
733
778
  * @ko 사용자가 드래그를 시작할 때 {@link https://developer.mozilla.org/ko/docs/Web/API/Event/preventDefault preventDefault} 실행 여부
@@ -738,6 +783,7 @@ class Flicking extends Component<FlickingEvents> {
738
783
  public get preventDefaultOnDrag() {
739
784
  return this._preventDefaultOnDrag;
740
785
  }
786
+
741
787
  /**
742
788
  * Automatically call {@link Flicking#disableInput disableInput()} on initialization
743
789
  * @ko Flicking init시에 {@link Flicking#disableInput disableInput()}을 바로 호출합니다
@@ -748,6 +794,7 @@ class Flicking extends Component<FlickingEvents> {
748
794
  public get disableOnInit() {
749
795
  return this._disableOnInit;
750
796
  }
797
+
751
798
  /**
752
799
  * Change active panel index on mouse/touch hold while animating.
753
800
  * `index` of the `willChange`/`willRestore` event will be used as new index.
@@ -760,6 +807,7 @@ class Flicking extends Component<FlickingEvents> {
760
807
  public get changeOnHold() {
761
808
  return this._changeOnHold;
762
809
  }
810
+
763
811
  // PERFORMANCE
764
812
  /**
765
813
  * Whether to render visible panels only. This can dramatically increase performance when there're many panels
@@ -771,6 +819,7 @@ class Flicking extends Component<FlickingEvents> {
771
819
  public get renderOnlyVisible() {
772
820
  return this._renderOnlyVisible;
773
821
  }
822
+
774
823
  /**
775
824
  * By enabling this option, it will reduce memory consumption by restricting the number of DOM elements to `panelsPerView + 1`
776
825
  * Must be used with `panelsPerview`.
@@ -819,6 +868,7 @@ class Flicking extends Component<FlickingEvents> {
819
868
  public get autoInit() {
820
869
  return this._autoInit;
821
870
  }
871
+
822
872
  /**
823
873
  * Whether to automatically call {@link Flicking#resize resize()} when the viewport element(.flicking-viewport)'s size is changed
824
874
  * @ko 뷰포트 엘리먼트(.flicking-viewport)의 크기 변경시 {@link Flicking#resize resize()} 메소드를 자동으로 호출할지 여부를 설정합니다
@@ -828,6 +878,7 @@ class Flicking extends Component<FlickingEvents> {
828
878
  public get autoResize() {
829
879
  return this._autoResize;
830
880
  }
881
+
831
882
  /**
832
883
  * 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
833
884
  * @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} 이벤트 대신 수신할지 여부를 설정합니다
@@ -835,9 +886,16 @@ class Flicking extends Component<FlickingEvents> {
835
886
  * @default true
836
887
  * @see {@link https://naver.github.io/egjs-flicking/Options#useresizeobserver useResizeObserver ( Options )}
837
888
  */
838
- public get useResizeObserver() {
839
- return this._useResizeObserver;
840
- }
889
+ public get useResizeObserver() { return this._useResizeObserver; }
890
+ /**
891
+ * Whether to use {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver} to observe the size of the panel element
892
+ * This is only available when `useResizeObserver` is enabled.
893
+ * This option garantees that the resize event is triggered when the size of the panel element is changed.
894
+ * @ko 이 옵션을 활성화할 경우, {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ResizeObserver}를 사용하여 패널 엘리먼트의 크기를 추적합니다.
895
+ * 이 옵션은 `useResizeObserver` 옵션이 활성화된 경우에만 사용할 수 있습니다.
896
+ * 이 옵션은 패널 엘리먼트의 크기가 변경될 경우 resize 이벤트가 발생하도록 보장합니다.
897
+ */
898
+ public get observePanelResize() { return this._observePanelResize; }
841
899
  /**
842
900
  * Delays size recalculation from `autoResize` by the given time in milisecond.
843
901
  * If the size is changed again while being delayed, it cancels the previous one and delays from the beginning again.
@@ -852,6 +910,7 @@ class Flicking extends Component<FlickingEvents> {
852
910
  public get resizeDebounce() {
853
911
  return this._resizeDebounce;
854
912
  }
913
+
855
914
  /**
856
915
  * The maximum time for size recalculation delay when using `resizeDebounce`, in milisecond.
857
916
  * This guarantees that size recalculation is performed at least once every (n)ms.
@@ -864,6 +923,7 @@ class Flicking extends Component<FlickingEvents> {
864
923
  public get maxResizeDebounce() {
865
924
  return this._maxResizeDebounce;
866
925
  }
926
+
867
927
  /**
868
928
  * By enabling this, Flicking will calculate all internal size with CSS width computed with getComputedStyle.
869
929
  * This can prevent 1px offset issue in some cases where panel size has the fractional part.
@@ -878,6 +938,7 @@ class Flicking extends Component<FlickingEvents> {
878
938
  public get useFractionalSize() {
879
939
  return this._useFractionalSize;
880
940
  }
941
+
881
942
  /**
882
943
  * This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
883
944
  * @ko 프레임워크(React, Vue, Angular, ...)에서만 사용하는 옵션으로, 자동으로 설정되므로 따로 사용하실 필요 없습니다!
@@ -888,6 +949,7 @@ class Flicking extends Component<FlickingEvents> {
888
949
  public get externalRenderer() {
889
950
  return this._externalRenderer;
890
951
  }
952
+
891
953
  /**
892
954
  * This is an option for the frameworks(React, Vue, Angular, ...). Don't set it as it's automatically managed by Flicking.
893
955
  * @ko 프레임워크(React, Vue, Angular, ...)에서만 사용하는 옵션으로, 자동으로 설정되므로 따로 사용하실 필요 없습니다!
@@ -900,6 +962,24 @@ class Flicking extends Component<FlickingEvents> {
900
962
  return this._renderExternal;
901
963
  }
902
964
 
965
+ /**
966
+ * This option works only when autoResize is set to true.
967
+ * By default, autoResize listens to changes in both the viewport's width and height, updating all panel sizes accordingly.
968
+ * When optimizeSizeUpdate is enabled, the update behavior is optimized based on the flicking direction:
969
+ * If direction is "horizontal", only changes in width will trigger panel size updates.
970
+ * If direction is "vertical", only changes in height will do so.
971
+ * This option is useful when panel heights vary and unwanted flickering occurs due to frequent size recalculations during flicking. Enabling optimizeSizeUpdate prevents unnecessary updates and helps maintain visual stability.
972
+ * @ko optimizeSizeUpdate는 autoResize가 true일 때만 동작합니다.
973
+ * 기본적으로 autoResize는 뷰포트의 width와 height 변화를 모두 감지하여 패널들의 사이즈를 업데이트합니다.
974
+ * 이 옵션을 활성화하면 플리킹 방향에 따라 필요한 차원(horizontal → width, vertical → height)에 대해서만 사이즈를 업데이트합니다.
975
+ * 내부 패널의 높이가 서로 다를 때, 플리킹 중 과도한 리사이징으로 인한 깜빡임 현상을 줄이는 데 유용합니다.
976
+ * @type {boolean}
977
+ * @default false
978
+ */
979
+ public get optimizeSizeUpdate() {
980
+ return this._optimizeSizeUpdate;
981
+ }
982
+
903
983
  // Options Setter
904
984
  // UI / LAYOUT
905
985
  public set align(val: FlickingOptions["align"]) {
@@ -912,6 +992,7 @@ class Flicking extends Component<FlickingEvents> {
912
992
  public set defaultIndex(val: FlickingOptions["defaultIndex"]) {
913
993
  this._defaultIndex = val;
914
994
  }
995
+
915
996
  public set horizontal(val: FlickingOptions["horizontal"]) {
916
997
  this._horizontal = val;
917
998
  this._control.controller.updateDirection();
@@ -967,11 +1048,13 @@ class Flicking extends Component<FlickingEvents> {
967
1048
  public set needPanelThreshold(val: FlickingOptions["needPanelThreshold"]) {
968
1049
  this._needPanelThreshold = val;
969
1050
  }
1051
+
970
1052
  public set preventEventsBeforeInit(
971
1053
  val: FlickingOptions["preventEventsBeforeInit"]
972
1054
  ) {
973
1055
  this._preventEventsBeforeInit = val;
974
1056
  }
1057
+
975
1058
  // ANIMATION
976
1059
  public set deceleration(val: FlickingOptions["deceleration"]) {
977
1060
  this._deceleration = val;
@@ -994,6 +1077,7 @@ class Flicking extends Component<FlickingEvents> {
994
1077
  public set duration(val: FlickingOptions["duration"]) {
995
1078
  this._duration = val;
996
1079
  }
1080
+
997
1081
  // INPUT
998
1082
  public set inputType(val: FlickingOptions["inputType"]) {
999
1083
  this._inputType = val;
@@ -1090,9 +1174,11 @@ class Flicking extends Component<FlickingEvents> {
1090
1174
  public set disableOnInit(val: FlickingOptions["disableOnInit"]) {
1091
1175
  this._disableOnInit = val;
1092
1176
  }
1177
+
1093
1178
  public set changeOnHold(val: FlickingOptions["changeOnHold"]) {
1094
1179
  this._changeOnHold = val;
1095
1180
  }
1181
+
1096
1182
  // PERFORMANCE
1097
1183
  public set renderOnlyVisible(val: FlickingOptions["renderOnlyVisible"]) {
1098
1184
  this._renderOnlyVisible = val;
@@ -1103,6 +1189,10 @@ class Flicking extends Component<FlickingEvents> {
1103
1189
  public set autoResize(val: FlickingOptions["autoResize"]) {
1104
1190
  this._autoResize = val;
1105
1191
 
1192
+ if (!this._initialized) {
1193
+ return;
1194
+ }
1195
+
1106
1196
  if (val) {
1107
1197
  this._autoResizer.enable();
1108
1198
  } else {
@@ -1113,11 +1203,27 @@ class Flicking extends Component<FlickingEvents> {
1113
1203
  public set useResizeObserver(val: FlickingOptions["useResizeObserver"]) {
1114
1204
  this._useResizeObserver = val;
1115
1205
 
1116
- if (this._autoResize) {
1206
+ if (this._initialized && this._autoResize) {
1117
1207
  this._autoResizer.enable();
1118
1208
  }
1119
1209
  }
1120
1210
 
1211
+ public set observePanelResize(val: FlickingOptions["observePanelResize"]) {
1212
+ this._observePanelResize = val;
1213
+
1214
+ if (this._initialized && this._autoResize) {
1215
+ if (val) {
1216
+ this._autoResizer.observePanels();
1217
+ } else {
1218
+ this._autoResizer.unobservePanels();
1219
+ }
1220
+ }
1221
+ }
1222
+
1223
+ public set optimizeSizeUpdate(val: FlickingOptions["optimizeSizeUpdate"]) {
1224
+ this._optimizeSizeUpdate = val;
1225
+ }
1226
+
1121
1227
  /**
1122
1228
  * @param root A root HTMLElement to initialize Flicking on it. When it's a typeof `string`, it should be a css selector string
1123
1229
  * <ko>Flicking을 초기화할 HTMLElement로, `string` 타입으로 지정시 css 선택자 문자열을 지정해야 합니다.</ko>
@@ -1146,49 +1252,47 @@ class Flicking extends Component<FlickingEvents> {
1146
1252
  * const flicking2 = new Flicking(".flicking-viewport", { circular: true });
1147
1253
  * ```
1148
1254
  */
1149
- public constructor(
1150
- root: HTMLElement | string,
1151
- {
1152
- align = ALIGN.CENTER,
1153
- defaultIndex = 0,
1154
- horizontal = true,
1155
- circular = false,
1156
- circularFallback = CIRCULAR_FALLBACK.LINEAR,
1157
- bound = false,
1158
- adaptive = false,
1159
- panelsPerView = -1,
1160
- noPanelStyleOverride = false,
1161
- resizeOnContentsReady = false,
1162
- nested = false,
1163
- needPanelThreshold = 0,
1164
- preventEventsBeforeInit = true,
1165
- deceleration = 0.0075,
1166
- duration = 500,
1167
- easing = (x) => 1 - Math.pow(1 - x, 3),
1168
- inputType = ["mouse", "touch"],
1169
- moveType = "snap",
1170
- threshold = 40,
1171
- dragThreshold = 1,
1172
- interruptable = true,
1173
- bounce = "20%",
1174
- iOSEdgeSwipeThreshold = 30,
1175
- preventClickOnDrag = true,
1176
- preventDefaultOnDrag = false,
1177
- disableOnInit = false,
1178
- changeOnHold = false,
1179
- renderOnlyVisible = false,
1180
- virtual = null,
1181
- autoInit = true,
1182
- autoResize = true,
1183
- useResizeObserver = true,
1184
- resizeDebounce = 0,
1185
- maxResizeDebounce = 100,
1186
- useFractionalSize = false,
1187
- externalRenderer = null,
1188
- renderExternal = null,
1189
- optimizeSizeUpdate = false,
1190
- }: Partial<FlickingOptions> = {}
1191
- ) {
1255
+ public constructor(root: HTMLElement | string, {
1256
+ align = ALIGN.CENTER,
1257
+ defaultIndex = 0,
1258
+ horizontal = true,
1259
+ circular = false,
1260
+ circularFallback = CIRCULAR_FALLBACK.LINEAR,
1261
+ bound = false,
1262
+ adaptive = false,
1263
+ panelsPerView = -1,
1264
+ noPanelStyleOverride = false,
1265
+ resizeOnContentsReady = false,
1266
+ nested = false,
1267
+ needPanelThreshold = 0,
1268
+ preventEventsBeforeInit = true,
1269
+ deceleration = 0.0075,
1270
+ duration = 500,
1271
+ easing = x => 1 - Math.pow(1 - x, 3),
1272
+ inputType = ["mouse", "touch"],
1273
+ moveType = "snap",
1274
+ threshold = 40,
1275
+ dragThreshold = 1,
1276
+ interruptable = true,
1277
+ bounce = "20%",
1278
+ iOSEdgeSwipeThreshold = 30,
1279
+ preventClickOnDrag = true,
1280
+ preventDefaultOnDrag = false,
1281
+ disableOnInit = false,
1282
+ changeOnHold = false,
1283
+ renderOnlyVisible = false,
1284
+ virtual = null,
1285
+ autoInit = true,
1286
+ autoResize = true,
1287
+ useResizeObserver = true,
1288
+ resizeDebounce = 0,
1289
+ observePanelResize = false,
1290
+ maxResizeDebounce = 100,
1291
+ useFractionalSize = false,
1292
+ externalRenderer = null,
1293
+ renderExternal = null,
1294
+ optimizeSizeUpdate = false
1295
+ }: Partial<FlickingOptions> = {}) {
1192
1296
  super();
1193
1297
 
1194
1298
  // Internal states
@@ -1231,6 +1335,7 @@ class Flicking extends Component<FlickingEvents> {
1231
1335
  this._useResizeObserver = useResizeObserver;
1232
1336
  this._resizeDebounce = resizeDebounce;
1233
1337
  this._maxResizeDebounce = maxResizeDebounce;
1338
+ this._observePanelResize = observePanelResize;
1234
1339
  this._useFractionalSize = useFractionalSize;
1235
1340
  this._externalRenderer = externalRenderer;
1236
1341
  this._renderExternal = renderExternal;
@@ -1474,7 +1579,7 @@ class Flicking extends Component<FlickingEvents> {
1474
1579
 
1475
1580
  return this._control.moveToPanel(panel, {
1476
1581
  duration,
1477
- direction,
1582
+ direction
1478
1583
  });
1479
1584
  }
1480
1585
 
@@ -1578,7 +1683,7 @@ class Flicking extends Component<FlickingEvents> {
1578
1683
  index = true,
1579
1684
  position = true,
1580
1685
  includePanelHTML = false,
1581
- visiblePanelsOnly = false,
1686
+ visiblePanelsOnly = false
1582
1687
  }: Partial<{
1583
1688
  index: boolean;
1584
1689
  position: boolean;
@@ -1597,7 +1702,7 @@ class Flicking extends Component<FlickingEvents> {
1597
1702
  }
1598
1703
 
1599
1704
  return panelInfo;
1600
- }),
1705
+ })
1601
1706
  };
1602
1707
 
1603
1708
  if (index) {
@@ -1609,7 +1714,7 @@ class Flicking extends Component<FlickingEvents> {
1609
1714
  if (nearestAnchor) {
1610
1715
  status.position = {
1611
1716
  panel: nearestAnchor.panel.index,
1612
- progressInPanel: camera.getProgressInPanel(nearestAnchor.panel),
1717
+ progressInPanel: camera.getProgressInPanel(nearestAnchor.panel)
1613
1718
  };
1614
1719
  }
1615
1720
  }
@@ -1647,12 +1752,12 @@ class Flicking extends Component<FlickingEvents> {
1647
1752
  renderer.batchRemove({
1648
1753
  index: 0,
1649
1754
  deleteCount: this.panels.length,
1650
- hasDOMInElements: true,
1755
+ hasDOMInElements: true
1651
1756
  });
1652
1757
  renderer.batchInsert({
1653
1758
  index: 0,
1654
1759
  elements: parseElement(panels.map((panel) => panel.html!)),
1655
- hasDOMInElements: true,
1760
+ hasDOMInElements: true
1656
1761
  });
1657
1762
  }
1658
1763
 
@@ -1720,7 +1825,7 @@ class Flicking extends Component<FlickingEvents> {
1720
1825
  */
1721
1826
  public async resize(): Promise<void> {
1722
1827
  if (this._isResizing) return;
1723
-
1828
+
1724
1829
  this._isResizing = true;
1725
1830
 
1726
1831
  const viewport = this._viewport;
@@ -1739,20 +1844,23 @@ class Flicking extends Component<FlickingEvents> {
1739
1844
  new ComponentEvent(EVENTS.BEFORE_RESIZE, {
1740
1845
  width: prevWidth,
1741
1846
  height: prevHeight,
1742
- element: viewport.element,
1847
+ element: viewport.element
1743
1848
  })
1744
1849
  );
1745
1850
 
1746
1851
  viewport.resize();
1747
1852
 
1853
+ // 뷰포트 사이즈가 변경되었을 때 내부의 패널 사이즈들도 전부 업데이트 되어야 하므로 패널들을 전부 리렌더링한다.
1854
+ // optimizeSizeUpdate가 true일 경우에는 플리킹 방향에 대응되는 뷰포트 사이즈 요소가 변경되었을 때만 패널들을 리렌더링한다.
1855
+ // 자세한 사항은 optimizeSizeUpdate 옵션의 설명을 참고.
1748
1856
  if (this._optimizeSizeUpdate) {
1749
1857
  if ((this.horizontal && viewport.width !== prevWidth) || (!this.horizontal && viewport.height !== prevHeight)) {
1750
- await renderer.forceRenderAllPanels(); // Render all panel elements, to update sizes
1858
+ await renderer.forceRenderAllPanels();
1751
1859
  }
1752
1860
  } else {
1753
1861
  await renderer.forceRenderAllPanels(); // Render all panel elements, to update sizes
1754
1862
  }
1755
-
1863
+
1756
1864
  if (!this._initialized) {
1757
1865
  return;
1758
1866
  }
@@ -1785,10 +1893,10 @@ class Flicking extends Component<FlickingEvents> {
1785
1893
  height: viewport.height,
1786
1894
  prev: {
1787
1895
  width: prevWidth,
1788
- height: prevHeight,
1896
+ height: prevHeight
1789
1897
  },
1790
1898
  sizeChanged,
1791
- element: viewport.element,
1899
+ element: viewport.element
1792
1900
  })
1793
1901
  );
1794
1902
 
@@ -1875,7 +1983,7 @@ class Flicking extends Component<FlickingEvents> {
1875
1983
  return this._renderer.batchInsert({
1876
1984
  index,
1877
1985
  elements: parseElement(element),
1878
- hasDOMInElements: true,
1986
+ hasDOMInElements: true
1879
1987
  });
1880
1988
  }
1881
1989
 
@@ -1899,7 +2007,7 @@ class Flicking extends Component<FlickingEvents> {
1899
2007
  return this._renderer.batchRemove({
1900
2008
  index,
1901
2009
  deleteCount,
1902
- hasDOMInElements: true,
2010
+ hasDOMInElements: true
1903
2011
  });
1904
2012
  }
1905
2013
 
@@ -1934,12 +2042,12 @@ class Flicking extends Component<FlickingEvents> {
1934
2042
  if (this._circular && this._bound) {
1935
2043
  // eslint-disable-next-line no-console
1936
2044
  console.warn(
1937
- '"circular" and "bound" option cannot be used together, ignoring bound.'
2045
+ "\"circular\" and \"bound\" option cannot be used together, ignoring bound."
1938
2046
  );
1939
2047
  }
1940
2048
 
1941
2049
  return new Camera(this, {
1942
- align: this._align,
2050
+ align: this._align
1943
2051
  });
1944
2052
  }
1945
2053
 
@@ -1948,15 +2056,15 @@ class Flicking extends Component<FlickingEvents> {
1948
2056
  if (this._virtual && this._panelsPerView <= 0) {
1949
2057
  // eslint-disable-next-line no-console
1950
2058
  console.warn(
1951
- '"virtual" and "panelsPerView" option should be used together, ignoring virtual.'
2059
+ "\"virtual\" and \"panelsPerView\" option should be used together, ignoring virtual."
1952
2060
  );
1953
2061
  }
1954
2062
 
1955
2063
  return externalRenderer
1956
2064
  ? externalRenderer
1957
2065
  : this._renderExternal
1958
- ? this._createExternalRenderer()
1959
- : this._createVanillaRenderer();
2066
+ ? this._createExternalRenderer()
2067
+ : this._createVanillaRenderer();
1960
2068
  }
1961
2069
 
1962
2070
  private _createExternalRenderer(): ExternalRenderer {
@@ -1973,8 +2081,8 @@ class Flicking extends Component<FlickingEvents> {
1973
2081
  strategy: virtual
1974
2082
  ? new VirtualRenderingStrategy()
1975
2083
  : new NormalRenderingStrategy({
1976
- providerCtor: VanillaElementProvider,
1977
- }),
2084
+ providerCtor: VanillaElementProvider
2085
+ })
1978
2086
  });
1979
2087
  }
1980
2088
 
@@ -2024,7 +2132,7 @@ class Flicking extends Component<FlickingEvents> {
2024
2132
  new ComponentEvent(EVENTS.BEFORE_RESIZE, {
2025
2133
  width: 0,
2026
2134
  height: 0,
2027
- element: viewport.element,
2135
+ element: viewport.element
2028
2136
  })
2029
2137
  );
2030
2138
 
@@ -2046,10 +2154,10 @@ class Flicking extends Component<FlickingEvents> {
2046
2154
  height: viewport.height,
2047
2155
  prev: {
2048
2156
  width: 0,
2049
- height: 0,
2157
+ height: 0
2050
2158
  },
2051
2159
  sizeChanged,
2052
- element: viewport.element,
2160
+ element: viewport.element
2053
2161
  })
2054
2162
  );
2055
2163
  }