@egjs/flicking 4.11.5-beta.1 → 4.11.5-beta.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.
@@ -4,13 +4,13 @@ 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.5-beta.1
7
+ version: 4.11.5-beta.2
8
8
  */
9
9
  import Component, { ComponentEvent } from '@egjs/component';
10
10
  import Axes, { PanInput } from '@egjs/axes';
11
11
  import ImReady from '@egjs/imready';
12
12
 
13
- /******************************************************************************
13
+ /*! *****************************************************************************
14
14
  Copyright (c) Microsoft Corporation.
15
15
 
16
16
  Permission to use, copy, modify, and/or distribute this software for any
@@ -24,7 +24,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24
24
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25
25
  PERFORMANCE OF THIS SOFTWARE.
26
26
  ***************************************************************************** */
27
- /* global Reflect, Promise, SuppressedError, Symbol */
27
+ /* global Reflect, Promise */
28
28
 
29
29
  var extendStatics = function (d, b) {
30
30
  extendStatics = Object.setPrototypeOf || {
@@ -109,7 +109,7 @@ function __generator(thisArg, body) {
109
109
  }
110
110
  function step(op) {
111
111
  if (f) throw new TypeError("Generator is already executing.");
112
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
112
+ while (_) try {
113
113
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
114
114
  if (y = 0, t) op = [op[0] & 2, t.value];
115
115
  switch (op[0]) {
@@ -213,10 +213,6 @@ function __spread() {
213
213
  for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
214
214
  return ar;
215
215
  }
216
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
217
- var e = new Error(message);
218
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
219
- };
220
216
 
221
217
  /*
222
218
  * Copyright (c) 2015 NAVER Corp.
@@ -908,10 +904,6 @@ var Viewport = /*#__PURE__*/function () {
908
904
  return Viewport;
909
905
  }();
910
906
 
911
- /**
912
- * A component that detects size change and trigger resize method when the autoResize option is used
913
- * @ko autoResize 옵션을 사용할 때 크기 변화를 감지하고 Flicking의 resize를 호출하는 컴포넌트
914
- */
915
907
  var AutoResizer = /*#__PURE__*/function () {
916
908
  function AutoResizer(flicking) {
917
909
  var _this = this;
@@ -974,13 +966,9 @@ var AutoResizer = /*#__PURE__*/function () {
974
966
  }
975
967
  if (flicking.useResizeObserver && !!window.ResizeObserver) {
976
968
  var viewportSizeNot0 = viewport.width !== 0 || viewport.height !== 0;
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;
969
+ var resizeObserver = viewportSizeNot0 ? new ResizeObserver(this._skipFirstResize) : new ResizeObserver(this._onResize);
970
+ resizeObserver.observe(flicking.viewport.element);
971
+ this._resizeObserver = resizeObserver;
984
972
  } else {
985
973
  window.addEventListener("resize", this._onResize);
986
974
  }
@@ -999,12 +987,6 @@ var AutoResizer = /*#__PURE__*/function () {
999
987
  this._enabled = false;
1000
988
  return this;
1001
989
  };
1002
- __proto.observe = function (element) {
1003
- if (this._resizeObserver) {
1004
- this._resizeObserver.observe(element);
1005
- }
1006
- return this;
1007
- };
1008
990
  return AutoResizer;
1009
991
  }();
1010
992
 
@@ -4084,6 +4066,8 @@ var Camera = /*#__PURE__*/function () {
4084
4066
  */
4085
4067
  __proto.lookAt = function (pos) {
4086
4068
  var _this = this;
4069
+ var prevOffset = this._offset;
4070
+ var isChangedOffset = this._lookedOffset !== prevOffset;
4087
4071
  var flicking = getFlickingAttached(this._flicking);
4088
4072
  var prevPos = this._position;
4089
4073
  this._position = pos;
@@ -4091,10 +4075,15 @@ var Camera = /*#__PURE__*/function () {
4091
4075
  this._refreshVisiblePanels();
4092
4076
  this._checkNeedPanel();
4093
4077
  this._checkReachEnd(prevPos, pos);
4094
- if (toggled) {
4078
+ if (isChangedOffset || toggled) {
4095
4079
  void flicking.renderer.render().then(function () {
4096
4080
  _this.updateOffset();
4081
+ _this._lookedOffset = _this._offset;
4097
4082
  });
4083
+ } else if (isChangedOffset) {
4084
+ // sync offset for renderOnlyVisible on resize
4085
+ this.updateOffset();
4086
+ this._lookedOffset = this._offset;
4098
4087
  } else {
4099
4088
  this.applyTransform();
4100
4089
  }
@@ -4778,11 +4767,6 @@ var Renderer = /*#__PURE__*/function () {
4778
4767
  var activePanel = control.activePanel;
4779
4768
  // Update camera & control
4780
4769
  this._updateCameraAndControl();
4781
- if (flicking.autoResize && flicking.useResizeObserver) {
4782
- panelsAdded.forEach(function (panel) {
4783
- flicking.autoResizer.observe(panel.element);
4784
- });
4785
- }
4786
4770
  void this.render();
4787
4771
  if (!flicking.animating) {
4788
4772
  if (!activePanel || activePanel.removed) {
@@ -6184,19 +6168,6 @@ var Flicking = /*#__PURE__*/function (_super) {
6184
6168
  enumerable: false,
6185
6169
  configurable: true
6186
6170
  });
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
- });
6200
6171
  Object.defineProperty(__proto, "initialized", {
6201
6172
  // Internal States
6202
6173
  /**
@@ -7049,9 +7020,6 @@ var Flicking = /*#__PURE__*/function (_super) {
7049
7020
  // OTHERS
7050
7021
  set: function (val) {
7051
7022
  this._autoResize = val;
7052
- if (!this._initialized) {
7053
- return;
7054
- }
7055
7023
  if (val) {
7056
7024
  this._autoResizer.enable();
7057
7025
  } else {
@@ -7074,7 +7042,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7074
7042
  },
7075
7043
  set: function (val) {
7076
7044
  this._useResizeObserver = val;
7077
- if (this._initialized && this._autoResize) {
7045
+ if (this._autoResize) {
7078
7046
  this._autoResizer.enable();
7079
7047
  }
7080
7048
  },
@@ -7871,7 +7839,7 @@ var Flicking = /*#__PURE__*/function (_super) {
7871
7839
  * Flicking.VERSION; // ex) 4.0.0
7872
7840
  * ```
7873
7841
  */
7874
- Flicking.VERSION = "4.11.5-beta.1";
7842
+ Flicking.VERSION = "4.11.5-beta.2";
7875
7843
  return Flicking;
7876
7844
  }(Component);
7877
7845