@egjs/flicking 3.8.3 → 3.9.2-beta.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.
Files changed (58) hide show
  1. package/declaration/Flicking.d.ts +2 -1
  2. package/declaration/components/AutoResizer.d.ts +12 -0
  3. package/declaration/types.d.ts +1 -0
  4. package/dist/flicking.esm.js +99 -23
  5. package/dist/flicking.esm.js.map +1 -1
  6. package/dist/flicking.js +99 -23
  7. package/dist/flicking.js.map +1 -1
  8. package/dist/flicking.min.js +2 -2
  9. package/dist/flicking.min.js.map +1 -1
  10. package/dist/flicking.pkgd.js +99 -23
  11. package/dist/flicking.pkgd.js.map +1 -1
  12. package/dist/flicking.pkgd.min.js +2 -2
  13. package/dist/flicking.pkgd.min.js.map +1 -1
  14. package/doc/eg.Flicking.html +102 -39
  15. package/doc/global.html +1 -1
  16. package/doc/index.html +1 -1
  17. package/doc/node_modules_@egjs_component_src_Component.ts.html +1 -1
  18. package/doc/src_Flicking.ts.html +13 -17
  19. package/doc/src_types.ts.html +2 -1
  20. package/docs/build/release/3.8.4/dist/flicking.esm.js +5055 -0
  21. package/docs/build/release/3.8.4/dist/flicking.esm.js.map +1 -0
  22. package/docs/build/release/3.8.4/dist/flicking.js +5062 -0
  23. package/docs/build/release/3.8.4/dist/flicking.js.map +1 -0
  24. package/docs/build/release/3.8.4/dist/flicking.min.js +10 -0
  25. package/docs/build/release/3.8.4/dist/flicking.min.js.map +1 -0
  26. package/docs/build/release/3.8.4/dist/flicking.pkgd.js +11391 -0
  27. package/docs/build/release/3.8.4/dist/flicking.pkgd.js.map +1 -0
  28. package/docs/build/release/3.8.4/dist/flicking.pkgd.min.js +10 -0
  29. package/docs/build/release/3.8.4/dist/flicking.pkgd.min.js.map +1 -0
  30. package/docs/build/release/3.9.0/dist/flicking.esm.js +5124 -0
  31. package/docs/build/release/3.9.0/dist/flicking.esm.js.map +1 -0
  32. package/docs/build/release/3.9.0/dist/flicking.js +5131 -0
  33. package/docs/build/release/3.9.0/dist/flicking.js.map +1 -0
  34. package/docs/build/release/3.9.0/dist/flicking.min.js +10 -0
  35. package/docs/build/release/3.9.0/dist/flicking.min.js.map +1 -0
  36. package/docs/build/release/3.9.0/dist/flicking.pkgd.js +11460 -0
  37. package/docs/build/release/3.9.0/dist/flicking.pkgd.js.map +1 -0
  38. package/docs/build/release/3.9.0/dist/flicking.pkgd.min.js +10 -0
  39. package/docs/build/release/3.9.0/dist/flicking.pkgd.min.js.map +1 -0
  40. package/docs/build/release/3.9.1/dist/flicking.esm.js +5124 -0
  41. package/docs/build/release/3.9.1/dist/flicking.esm.js.map +1 -0
  42. package/docs/build/release/3.9.1/dist/flicking.js +5131 -0
  43. package/docs/build/release/3.9.1/dist/flicking.js.map +1 -0
  44. package/docs/build/release/3.9.1/dist/flicking.min.js +10 -0
  45. package/docs/build/release/3.9.1/dist/flicking.min.js.map +1 -0
  46. package/docs/build/release/3.9.1/dist/flicking.pkgd.js +11460 -0
  47. package/docs/build/release/3.9.1/dist/flicking.pkgd.js.map +1 -0
  48. package/docs/build/release/3.9.1/dist/flicking.pkgd.min.js +10 -0
  49. package/docs/build/release/3.9.1/dist/flicking.pkgd.min.js.map +1 -0
  50. package/package.json +8 -12
  51. package/rollup.config.development.js +26 -0
  52. package/src/Flicking.ts +12 -16
  53. package/src/components/AutoResizer.ts +80 -0
  54. package/src/components/Viewport.ts +14 -6
  55. package/src/consts.ts +1 -0
  56. package/src/types.ts +1 -0
  57. package/src/utils.ts +1 -1
  58. package/tsconfig.test.json +1 -0
package/dist/flicking.js CHANGED
@@ -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: 3.8.3
7
+ version: 3.9.2-beta.0
8
8
  */
9
9
  (function (global, factory) {
10
10
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@egjs/component'), require('@egjs/imready'), require('@egjs/axes')) :
@@ -115,7 +115,8 @@ version: 3.8.3
115
115
  renderExternal: false,
116
116
  resizeOnContentsReady: false,
117
117
  iOSEdgeSwipeThreshold: 30,
118
- collectStatistics: true
118
+ collectStatistics: true,
119
+ useResizeObserver: true
119
120
  };
120
121
  var DEFAULT_VIEWPORT_CSS = {
121
122
  position: "relative",
@@ -377,7 +378,7 @@ version: 3.8.3
377
378
  for (var i = 0; i < iterable.length; i += 1) {
378
379
  var element = iterable[i];
379
380
 
380
- if (element && callback(element)) {
381
+ if (element != null && callback(element)) {
381
382
  return i;
382
383
  }
383
384
  }
@@ -2514,7 +2515,12 @@ version: 3.8.3
2514
2515
  __proto.disable = function () {
2515
2516
  if (this.panInput) {
2516
2517
  this.panInput.destroy();
2517
- this.panInput = null;
2518
+ this.panInput = null; // Refresh Axes instance
2519
+
2520
+ this.axes.destroy();
2521
+ this.setAxesInstance();
2522
+ this.updateScrollArea();
2523
+ this.updateAxesPosition(this.state.position);
2518
2524
  this.stateMachine.transitTo(STATE_TYPE.IDLE);
2519
2525
  }
2520
2526
  };
@@ -3213,6 +3219,7 @@ version: 3.8.3
3213
3219
  this.applyCSSValue();
3214
3220
  this.setMoveType();
3215
3221
  this.setAxesInstance();
3222
+ this.createPanInput();
3216
3223
  this.refreshPanels();
3217
3224
  this.setDefaultPanel();
3218
3225
  this.resize();
@@ -3324,7 +3331,6 @@ version: 3.8.3
3324
3331
  deceleration: options.deceleration,
3325
3332
  interruptable: true
3326
3333
  });
3327
- this.createPanInput();
3328
3334
  };
3329
3335
 
3330
3336
  __proto.refreshPanels = function () {
@@ -3368,11 +3374,12 @@ version: 3.8.3
3368
3374
  var panels = panelManager.originalPanels();
3369
3375
  var reversedPanels = panels.concat().reverse();
3370
3376
  var sumOriginalPanelSize = lastPanel.getPosition() + lastPanel.getSize() - firstPanel.getPosition() + gap;
3377
+ if (sumOriginalPanelSize <= 0) return;
3371
3378
  var relativeAnchorPosition = firstPanel.getRelativeAnchorPosition();
3372
3379
  var relativeHangerPosition = this.getRelativeHangerPosition();
3373
3380
  var areaPrev = (relativeHangerPosition - relativeAnchorPosition) % sumOriginalPanelSize;
3374
3381
  var sizeSum = 0;
3375
- var panelAtLeftBoundary;
3382
+ var panelAtLeftBoundary = null;
3376
3383
 
3377
3384
  for (var _i = 0, reversedPanels_1 = reversedPanels; _i < reversedPanels_1.length; _i++) {
3378
3385
  var panel = reversedPanels_1[_i];
@@ -3391,7 +3398,7 @@ version: 3.8.3
3391
3398
 
3392
3399
  var areaNext = (viewportSize - relativeHangerPosition + relativeAnchorPosition) % sumOriginalPanelSize;
3393
3400
  sizeSum = 0;
3394
- var panelAtRightBoundary;
3401
+ var panelAtRightBoundary = null;
3395
3402
 
3396
3403
  for (var _a = 0, panels_1 = panels; _a < panels_1.length; _a++) {
3397
3404
  var panel = panels_1[_a];
@@ -3409,7 +3416,7 @@ version: 3.8.3
3409
3416
  } // Need one more set of clones on prev area of original panel 0
3410
3417
 
3411
3418
 
3412
- var needCloneOnPrev = panelAtLeftBoundary.getIndex() !== 0 && panelAtLeftBoundary.getIndex() <= panelAtRightBoundary.getIndex(); // Visible count of panel 0 on first screen
3419
+ var needCloneOnPrev = panelAtLeftBoundary && panelAtRightBoundary && panelAtLeftBoundary.getIndex() !== 0 && panelAtLeftBoundary.getIndex() <= panelAtRightBoundary.getIndex(); // Visible count of panel 0 on first screen
3413
3420
 
3414
3421
  var panel0OnFirstscreen = Math.ceil((relativeHangerPosition + firstPanel.getSize() - relativeAnchorPosition) / sumOriginalPanelSize) + Math.ceil((viewportSize - relativeHangerPosition + relativeAnchorPosition) / sumOriginalPanelSize) - 1; // duplication
3415
3422
 
@@ -4041,6 +4048,77 @@ version: 3.8.3
4041
4048
  return Viewport;
4042
4049
  }();
4043
4050
 
4051
+ var AutoResizer =
4052
+ /*#__PURE__*/
4053
+ function () {
4054
+ function AutoResizer(flicking) {
4055
+ var _this = this;
4056
+
4057
+ this.skipFirstResize = function () {
4058
+ var isFirstResize = true;
4059
+ return function () {
4060
+ if (isFirstResize) {
4061
+ isFirstResize = false;
4062
+ return;
4063
+ }
4064
+
4065
+ _this.onResize();
4066
+ };
4067
+ }();
4068
+
4069
+ this.onResize = function () {
4070
+ _this.flicking.resize();
4071
+ };
4072
+
4073
+ this.flicking = flicking;
4074
+ this.enabled = false;
4075
+ this.resizeObserver = null;
4076
+ }
4077
+
4078
+ var __proto = AutoResizer.prototype;
4079
+
4080
+ __proto.enable = function () {
4081
+ var flicking = this.flicking;
4082
+
4083
+ if (this.enabled) {
4084
+ this.disable();
4085
+ }
4086
+
4087
+ if (flicking.options.useResizeObserver && !!window.ResizeObserver) {
4088
+ var flickingEl = flicking.getElement();
4089
+ var viewportSizeNot0 = flickingEl.clientWidth !== 0 || flickingEl.clientHeight !== 0;
4090
+ var resizeObserver = viewportSizeNot0 ? new ResizeObserver(this.skipFirstResize) : new ResizeObserver(this.onResize);
4091
+ resizeObserver.observe(flickingEl);
4092
+ this.resizeObserver = resizeObserver;
4093
+ } else {
4094
+ window.addEventListener("resize", this.onResize);
4095
+ }
4096
+
4097
+ this.enabled = true;
4098
+ return this;
4099
+ };
4100
+
4101
+ __proto.disable = function () {
4102
+ if (!this.enabled) {
4103
+ return this;
4104
+ }
4105
+
4106
+ var resizeObserver = this.resizeObserver;
4107
+
4108
+ if (resizeObserver) {
4109
+ resizeObserver.disconnect();
4110
+ this.resizeObserver = null;
4111
+ } else {
4112
+ window.removeEventListener("resize", this.onResize);
4113
+ }
4114
+
4115
+ this.enabled = false;
4116
+ return this;
4117
+ };
4118
+
4119
+ return AutoResizer;
4120
+ }();
4121
+
4044
4122
  /**
4045
4123
  * Copyright (c) 2015 NAVER Corp.
4046
4124
  * egjs projects are licensed under the MIT license
@@ -4090,6 +4168,7 @@ version: 3.8.3
4090
4168
  * @param {boolean} [options.isConstantSize=false] Whether all panels have a constant size that won't be changed after resize. Enabling this option can increase performance while recalculating panel size.<ko>모든 패널의 크기가 불변인지의 여부. 이 옵션을 'true'로 설정하면 패널 크기 재설정시에 성능을 높일 수 있다.</ko>
4091
4169
  * @param {boolean} [options.renderExternal=false] Whether to use external rendering. It will delegate DOM manipulation and can synchronize the rendered state by calling `sync()` method. You can use this option to use in frameworks like React, Vue, Angular, which has its states and rendering methods.<ko>외부 렌더링을 사용할 지의 여부. 이 옵션을 사용시 렌더링을 외부에 위임할 수 있고, `sync()`를 호출하여 그 상태를 동기화할 수 있다. 이 옵션을 사용하여, React, Vue, Angular 등 자체적인 상태와 렌더링 방법을 갖는 프레임워크에 대응할 수 있다.</ko>
4092
4170
  * @param {boolean} [options.resizeOnContentsReady=false] Whether to resize the Flicking after the image/video elements inside viewport are ready.<br/>Use this property to prevent wrong Flicking layout caused by dynamic image / video sizes.<ko>Flicking 내부의 이미지 / 비디오 엘리먼트들이 전부 로드되었을 때 Flicking의 크기를 재계산하기 위한 옵션.<br/>이미지 / 비디오 크기가 고정 크기가 아닐 경우 사용하여 레이아웃이 잘못되는 것을 방지할 수 있다.</ko>
4171
+ * @param {boolean} [options.useResizeObserver=true] 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<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} 이벤트 대신 수신할지 여부를 설정합니다</ko>
4093
4172
  * @param {boolean} [options.collectStatistics=true] Whether to collect statistics on how you are using `Flicking`. These statistical data do not contain any personal information and are used only as a basis for the development of a user-friendly product.<ko>어떻게 `Flicking`을 사용하고 있는지에 대한 통계 수집 여부를 나타낸다. 이 통계자료는 개인정보를 포함하고 있지 않으며 오직 사용자 친화적인 제품으로 발전시키기 위한 근거자료로서 활용한다.</ko>
4094
4173
  */
4095
4174
 
@@ -4257,18 +4336,13 @@ version: 3.8.3
4257
4336
 
4258
4337
 
4259
4338
  _this.viewport = new Viewport(_this, _this.options, _this.triggerEvent);
4339
+ _this.autoResizer = new AutoResizer(_this);
4260
4340
 
4261
4341
  _this.listenInput();
4262
4342
 
4263
4343
  _this.listenResize();
4264
4344
 
4265
- return _this; // if (this.options.collectStatistics) {
4266
- // sendEvent(
4267
- // "usage",
4268
- // "options",
4269
- // options,
4270
- // );
4271
- // }
4345
+ return _this;
4272
4346
  }
4273
4347
  /**
4274
4348
  * Move to the previous panel if it exists.
@@ -4602,11 +4676,7 @@ version: 3.8.3
4602
4676
  }
4603
4677
 
4604
4678
  this.off();
4605
-
4606
- if (this.options.autoResize) {
4607
- window.removeEventListener("resize", this.resize);
4608
- }
4609
-
4679
+ this.autoResizer.disable();
4610
4680
  this.viewport.destroy(option);
4611
4681
  (_a = this.contentsReadyChecker) === null || _a === void 0 ? void 0 : _a.destroy(); // release resources
4612
4682
 
@@ -4759,6 +4829,8 @@ version: 3.8.3
4759
4829
  __proto.beforeSync = function (diffInfo) {
4760
4830
  var _this = this;
4761
4831
 
4832
+ var _a;
4833
+
4762
4834
  var maintained = diffInfo.maintained,
4763
4835
  added = diffInfo.added,
4764
4836
  changed = diffInfo.changed,
@@ -4850,8 +4922,12 @@ version: 3.8.3
4850
4922
  }
4851
4923
 
4852
4924
  panelManager.replacePanels(newPanels, newClones);
4925
+ var currentPanelIndex = (_a = currentPanel === null || currentPanel === void 0 ? void 0 : currentPanel.getIndex()) !== null && _a !== void 0 ? _a : -1;
4926
+ var currentPanelIsRemoved = findIndex(removed, function (index) {
4927
+ return index === currentPanelIndex;
4928
+ }) >= 0;
4853
4929
 
4854
- if (!currentPanel && newPanels.length > 0) {
4930
+ if ((!currentPanel || currentPanelIsRemoved) && newPanels.length > 0) {
4855
4931
  viewport.setCurrentPanel(newPanels[0]);
4856
4932
  } else if (newPanels.length <= 0) {
4857
4933
  viewport.setCurrentPanel(undefined);
@@ -4972,7 +5048,7 @@ version: 3.8.3
4972
5048
  var options = this.options;
4973
5049
 
4974
5050
  if (options.autoResize) {
4975
- window.addEventListener("resize", this.resize);
5051
+ this.autoResizer.enable();
4976
5052
  }
4977
5053
 
4978
5054
  if (options.resizeOnContentsReady) {
@@ -5012,7 +5088,7 @@ version: 3.8.3
5012
5088
  */
5013
5089
 
5014
5090
 
5015
- Flicking.VERSION = "3.8.3";
5091
+ Flicking.VERSION = "3.9.2-beta.0";
5016
5092
  /**
5017
5093
  * Direction constant - "PREV" or "NEXT"
5018
5094
  * @ko 방향 상수 - "PREV" 또는 "NEXT"