@egjs/flicking 4.11.4 → 4.11.5-beta.1

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.
@@ -4,7 +4,7 @@ name: @egjs/flicking
4
4
  license: MIT
5
5
  author: NAVER Corp.
6
6
  repository: https://github.com/naver/egjs-flicking
7
- version: 4.11.4
7
+ version: 4.11.5-beta.1
8
8
  */
9
9
  import Component, { ComponentEvent } from '@egjs/component';
10
10
  import Axes, { PanInput } from '@egjs/axes';
@@ -908,6 +908,10 @@ var Viewport = /*#__PURE__*/function () {
908
908
  return Viewport;
909
909
  }();
910
910
 
911
+ /**
912
+ * A component that detects size change and trigger resize method when the autoResize option is used
913
+ * @ko autoResize 옵션을 사용할 때 크기 변화를 감지하고 Flicking의 resize를 호출하는 컴포넌트
914
+ */
911
915
  var AutoResizer = /*#__PURE__*/function () {
912
916
  function AutoResizer(flicking) {
913
917
  var _this = this;
@@ -970,9 +974,13 @@ var AutoResizer = /*#__PURE__*/function () {
970
974
  }
971
975
  if (flicking.useResizeObserver && !!window.ResizeObserver) {
972
976
  var viewportSizeNot0 = viewport.width !== 0 || viewport.height !== 0;
973
- var resizeObserver = viewportSizeNot0 ? new ResizeObserver(this._skipFirstResize) : new ResizeObserver(this._onResize);
974
- resizeObserver.observe(flicking.viewport.element);
975
- this._resizeObserver = resizeObserver;
977
+ var resizeObserver_1 = viewportSizeNot0 ? new ResizeObserver(this._skipFirstResize) : new ResizeObserver(this._onResize);
978
+ __spread([flicking.viewport.element, flicking.camera.element], flicking.panels.map(function (panel) {
979
+ return panel.element;
980
+ })).forEach(function (element) {
981
+ resizeObserver_1.observe(element);
982
+ });
983
+ this._resizeObserver = resizeObserver_1;
976
984
  } else {
977
985
  window.addEventListener("resize", this._onResize);
978
986
  }
@@ -991,6 +999,12 @@ var AutoResizer = /*#__PURE__*/function () {
991
999
  this._enabled = false;
992
1000
  return this;
993
1001
  };
1002
+ __proto.observe = function (element) {
1003
+ if (this._resizeObserver) {
1004
+ this._resizeObserver.observe(element);
1005
+ }
1006
+ return this;
1007
+ };
994
1008
  return AutoResizer;
995
1009
  }();
996
1010
 
@@ -4764,6 +4778,11 @@ var Renderer = /*#__PURE__*/function () {
4764
4778
  var activePanel = control.activePanel;
4765
4779
  // Update camera & control
4766
4780
  this._updateCameraAndControl();
4781
+ if (flicking.autoResize && flicking.useResizeObserver) {
4782
+ panelsAdded.forEach(function (panel) {
4783
+ flicking.autoResizer.observe(panel.element);
4784
+ });
4785
+ }
4767
4786
  void this.render();
4768
4787
  if (!flicking.animating) {
4769
4788
  if (!activePanel || activePanel.removed) {
@@ -6165,6 +6184,19 @@ var Flicking = /*#__PURE__*/function (_super) {
6165
6184
  enumerable: false,
6166
6185
  configurable: true
6167
6186
  });
6187
+ Object.defineProperty(__proto, "autoResizer", {
6188
+ /**
6189
+ * {@link AutoResizer} instance of the Flicking
6190
+ * @ko 현재 Flicking에 활성화된 {@link AutoResizer} 인스턴스
6191
+ * @internal
6192
+ * @readonly
6193
+ */
6194
+ get: function () {
6195
+ return this._autoResizer;
6196
+ },
6197
+ enumerable: false,
6198
+ configurable: true
6199
+ });
6168
6200
  Object.defineProperty(__proto, "initialized", {
6169
6201
  // Internal States
6170
6202
  /**
@@ -7017,6 +7049,9 @@ var Flicking = /*#__PURE__*/function (_super) {
7017
7049
  // OTHERS
7018
7050
  set: function (val) {
7019
7051
  this._autoResize = val;
7052
+ if (!this._initialized) {
7053
+ return;
7054
+ }
7020
7055
  if (val) {
7021
7056
  this._autoResizer.enable();
7022
7057
  } else {
@@ -7039,7 +7074,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7039
7074
  },
7040
7075
  set: function (val) {
7041
7076
  this._useResizeObserver = val;
7042
- if (this._autoResize) {
7077
+ if (this._initialized && this._autoResize) {
7043
7078
  this._autoResizer.enable();
7044
7079
  }
7045
7080
  },
@@ -7836,7 +7871,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7836
7871
  * Flicking.VERSION; // ex) 4.0.0
7837
7872
  * ```
7838
7873
  */
7839
- Flicking.VERSION = "4.11.4";
7874
+ Flicking.VERSION = "4.11.5-beta.1";
7840
7875
  return Flicking;
7841
7876
  }(Component);
7842
7877