@egjs/flicking 4.12.0-beta.7 → 4.12.0-beta.8

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.12.0-beta.7
7
+ version: 4.12.0-beta.8
8
8
  */
9
9
  (function (global, factory) {
10
10
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -2899,7 +2899,7 @@ version: 4.12.0-beta.7
2899
2899
  * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
2900
2900
  * @private
2901
2901
  */
2902
- var requestAnimationFrame = function (fp) {
2902
+ var requestAnimationFrame$1 = function (fp) {
2903
2903
  return raf(fp);
2904
2904
  };
2905
2905
  /**
@@ -4447,7 +4447,7 @@ version: 4.12.0-beta.7
4447
4447
  } else if (isCanceled) {
4448
4448
  _this.finish(false);
4449
4449
  } else {
4450
- _this._raf = requestAnimationFrame(loop_1);
4450
+ _this._raf = requestAnimationFrame$1(loop_1);
4451
4451
  }
4452
4452
  };
4453
4453
  loop_1();
@@ -13026,7 +13026,7 @@ version: 4.12.0-beta.7
13026
13026
  * Flicking.VERSION; // ex) 4.0.0
13027
13027
  * ```
13028
13028
  */
13029
- Flicking.VERSION = "4.12.0-beta.7";
13029
+ Flicking.VERSION = "4.12.0-beta.8";
13030
13030
  return Flicking;
13031
13031
  }(Component);
13032
13032
 
@@ -13034,21 +13034,16 @@ version: 4.12.0-beta.7
13034
13034
  * Copyright (c) 2015 NAVER Corp.
13035
13035
  * egjs projects are licensed under the MIT license
13036
13036
  */
13037
- /**
13038
- * @extends Component
13039
- * @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
13040
- * @requires {@link https://github.com/naver/egjs-component|@egjs/component}
13041
- * @requires {@link https://github.com/naver/egjs-axes|@egjs/axes}
13042
- */
13043
13037
  var CrossFlicking = /*#__PURE__*/function (_super) {
13044
13038
  __extends$3(CrossFlicking, _super);
13045
- // Options Setter
13046
- // public set align(val: FlickingOptions["align"]) {
13047
- // this._align = val;
13048
- // }
13049
13039
  function CrossFlicking(root, options) {
13050
13040
  if (options === void 0) {
13051
- options = {};
13041
+ options = {
13042
+ sideOptions: {},
13043
+ preserveIndex: false,
13044
+ disableSlideOnHold: false,
13045
+ disableIndexSync: false
13046
+ };
13052
13047
  }
13053
13048
  var _this = _super.call(this, root, options) || this;
13054
13049
  _this._onHorizontalHoldStart = function () {
@@ -13074,20 +13069,22 @@ version: 4.12.0-beta.7
13074
13069
  } else {
13075
13070
  _this._nextIndex = visiblePanels[0].index;
13076
13071
  }
13077
- // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 timeout으로 처리
13078
- _this._sideFlicking.forEach(function (child, i) {
13079
- if (_this._nextIndex !== i) {
13080
- var _a = _this._sideState[i],
13081
- start = _a.start,
13082
- end = _a.end;
13083
- if (child.index < start) {
13084
- child.stopAnimation();
13085
- void child.moveTo(start, 0);
13086
- } else if (child.index > end) {
13087
- child.stopAnimation();
13088
- void child.moveTo(end, 0);
13072
+ // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 requestAnimationFrame 처리
13073
+ requestAnimationFrame(function () {
13074
+ _this._sideFlicking.forEach(function (child, i) {
13075
+ if (_this._nextIndex !== i) {
13076
+ var _a = _this._sideState[i],
13077
+ start = _a.start,
13078
+ end = _a.end;
13079
+ if (child.index < start) {
13080
+ child.stopAnimation();
13081
+ void child.moveTo(start, 0);
13082
+ } else if (child.index > end) {
13083
+ child.stopAnimation();
13084
+ void child.moveTo(end, 0);
13085
+ }
13089
13086
  }
13090
- }
13087
+ });
13091
13088
  });
13092
13089
  if (e.isTrusted) {
13093
13090
  _this._syncToCategory(_this._sideFlicking[_this._nextIndex].index, _this._nextIndex);
@@ -13117,28 +13114,19 @@ version: 4.12.0-beta.7
13117
13114
  }
13118
13115
  };
13119
13116
  // Internal states
13120
- _this._sideState = _this._createSideState();
13121
13117
  _this._moveDirection = null;
13122
13118
  _this._nextIndex = 0;
13123
13119
  // Bind options
13124
13120
  _this._sideOptions = options.sideOptions;
13125
- // Create core components
13126
- _this._sideFlicking = _this._createSideFlicking();
13121
+ _this._preserveIndex = options.preserveIndex;
13122
+ _this._disableSlideOnHold = options.disableSlideOnHold;
13123
+ _this._disableIndexSync = options.disableIndexSync;
13127
13124
  return _this;
13125
+ // Create core components
13128
13126
  }
13129
13127
  var __proto = CrossFlicking.prototype;
13130
13128
  Object.defineProperty(__proto, "sideFlicking", {
13131
13129
  // Components
13132
- /**
13133
- * {@link Control} instance of the Flicking
13134
- * @ko 현재 Flicking에 활성화된 {@link Control} 인스턴스
13135
- * @type {Control}
13136
- * @default SnapControl
13137
- * @readonly
13138
- * @see Control
13139
- * @see SnapControl
13140
- * @see FreeControl
13141
- */
13142
13130
  get: function () {
13143
13131
  return this._sideFlicking;
13144
13132
  },
@@ -13146,16 +13134,6 @@ version: 4.12.0-beta.7
13146
13134
  configurable: true
13147
13135
  });
13148
13136
  Object.defineProperty(__proto, "sideState", {
13149
- // Internal States
13150
- /**
13151
- * Whether Flicking's {@link Flicking#init init()} is called.
13152
- * This is `true` when {@link Flicking#init init()} is called, and is `false` after calling {@link Flicking#destroy destroy()}.
13153
- * @ko Flicking의 {@link Flicking#init init()}이 호출되었는지를 나타내는 멤버 변수.
13154
- * 이 값은 {@link Flicking#init init()}이 호출되었으면 `true`로 변하고, {@link Flicking#destroy destroy()}호출 이후에 다시 `false`로 변경됩니다.
13155
- * @type {boolean}
13156
- * @default false
13157
- * @readonly
13158
- */
13159
13137
  get: function () {
13160
13138
  return this._sideState;
13161
13139
  },
@@ -13164,40 +13142,54 @@ version: 4.12.0-beta.7
13164
13142
  });
13165
13143
  Object.defineProperty(__proto, "sideOptions", {
13166
13144
  // Options Getter
13167
- /**
13168
- * Change active panel index on mouse/touch hold while animating.
13169
- * `index` of the `willChange`/`willRestore` event will be used as new index.
13170
- * @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
13171
- * `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
13172
- * @type {FlickingOptions}
13173
- * @default undefined
13174
- * @see {@link https://naver.github.io/egjs-flicking/Options#changeonhold changeOnHold ( Options )}
13175
- */
13176
13145
  get: function () {
13177
13146
  return this._sideOptions;
13178
13147
  },
13148
+ // Options Setter
13149
+ set: function (val) {
13150
+ this._sideOptions = val;
13151
+ },
13152
+ enumerable: false,
13153
+ configurable: true
13154
+ });
13155
+ Object.defineProperty(__proto, "preserveIndex", {
13156
+ get: function () {
13157
+ return this._preserveIndex;
13158
+ },
13159
+ set: function (val) {
13160
+ this._preserveIndex = val;
13161
+ },
13162
+ enumerable: false,
13163
+ configurable: true
13164
+ });
13165
+ Object.defineProperty(__proto, "disableSlideOnHold", {
13166
+ get: function () {
13167
+ return this._disableSlideOnHold;
13168
+ },
13169
+ set: function (val) {
13170
+ this._disableSlideOnHold = val;
13171
+ },
13172
+ enumerable: false,
13173
+ configurable: true
13174
+ });
13175
+ Object.defineProperty(__proto, "disableIndexSync", {
13176
+ get: function () {
13177
+ return this._disableIndexSync;
13178
+ },
13179
+ set: function (val) {
13180
+ this._disableIndexSync = val;
13181
+ },
13179
13182
  enumerable: false,
13180
13183
  configurable: true
13181
13184
  });
13182
- /**
13183
- * Initialize Flicking and move to the default index
13184
- * This is automatically called on Flicking's constructor when `autoInit` is true(default)
13185
- * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
13186
- * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
13187
- * @fires Flicking#ready
13188
- * @return {Promise<void>}
13189
- */
13190
13185
  __proto.init = function () {
13191
13186
  var _this = this;
13192
13187
  return _super.prototype.init.call(this).then(function () {
13193
- return _this._addComponentEvents();
13188
+ _this._sideState = _this._createSideState();
13189
+ _this._sideFlicking = _this._createSideFlicking();
13190
+ _this._addComponentEvents();
13194
13191
  });
13195
13192
  };
13196
- /**
13197
- * Destroy Flicking and remove all event handlers
13198
- * @ko Flicking과 하위 컴포넌트들을 초기 상태로 되돌리고, 부착된 모든 이벤트 핸들러를 제거합니다
13199
- * @return {void}
13200
- */
13201
13193
  __proto.destroy = function () {
13202
13194
  // TODO 모든 child flicking destroy
13203
13195
  _super.prototype.destroy.call(this);
@@ -13214,51 +13206,41 @@ version: 4.12.0-beta.7
13214
13206
  flicking.on(EVENTS.CHANGED, _this._onSideChanged);
13215
13207
  });
13216
13208
  };
13209
+ __proto._getGroupFromAttribute = function (panels) {
13210
+ var groupKeys = [];
13211
+ var groupPanels = {};
13212
+ panels.forEach(function (panel) {
13213
+ var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
13214
+ if (groupKey && !includes(groupKeys, groupKey)) {
13215
+ groupKeys.push(groupKey);
13216
+ groupPanels[groupKey] = [panel];
13217
+ } else if (groupKey) {
13218
+ groupPanels[groupKey].push(panel);
13219
+ }
13220
+ });
13221
+ return groupPanels;
13222
+ };
13217
13223
  __proto._createSideState = function () {
13218
13224
  var _this = this;
13219
- // data-index로 분류하기 전에 임시로 모든 children에 대해 side flicking으로 해보자.
13220
- // panels에 data-attributes가 붙어있을 때와 안 붙어있을 때를 다르게 처리
13221
- // 붙어있다면 가상의 viewport들을 index 갯수만큼 만들어줘야 한다
13222
13225
  var viewportEl = this.element;
13223
13226
  var cameraEl = this.camera.element;
13224
13227
  var panels = toArray$2(cameraEl.children);
13225
13228
  var sideState = [];
13226
13229
  var sidePanels = "";
13227
13230
  // check data attribute exists
13228
- var groupKeys = [];
13229
- var groupPanels = {};
13230
13231
  var sideCamera = document.createElement("div");
13231
13232
  sideCamera.classList.add(CLASS.CAMERA);
13232
13233
  var isCrossStructure = getDataAttributes(viewportEl, "data-cross-").structure;
13233
13234
  if (!isCrossStructure) {
13234
13235
  viewportEl.setAttribute("data-cross-structure", "true");
13235
- panels.forEach(function (panel) {
13236
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
13237
- if (groupKey && !includes(groupKeys, groupKey)) {
13238
- groupKeys.push(groupKey);
13239
- groupPanels[groupKey] = [panel];
13240
- } else if (groupKey) {
13241
- groupPanels[groupKey].push(panel);
13242
- }
13243
- });
13236
+ var groupPanels = this._getGroupFromAttribute(panels);
13237
+ var groupKeys = Object.keys(groupPanels);
13244
13238
  if (groupKeys.length) {
13245
- sideState = groupKeys.reduce(function (state, key) {
13246
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
13247
- var element = groupPanels[key].reduce(function (el, panel) {
13248
- sidePanels += panel.outerHTML;
13249
- el.innerHTML += panel.outerHTML;
13250
- return el;
13251
- }, document.createElement("div"));
13252
- return __spread$1(state, [{
13253
- key: key,
13254
- start: start,
13255
- end: start + groupPanels[key].length - 1,
13256
- element: element
13257
- }]);
13258
- }, []);
13239
+ sideState = this._getSideStateFromGroup(groupPanels);
13259
13240
  this.remove(0, this.panelCount - groupKeys.length);
13260
- sideState.forEach(function (_, i) {
13241
+ sideState.forEach(function (state, i) {
13261
13242
  var panel = _this.camera.children[i];
13243
+ sidePanels += state.element.innerHTML;
13262
13244
  Array.from(panel.attributes).forEach(function (attribute) {
13263
13245
  return panel.removeAttribute(attribute.name);
13264
13246
  });
@@ -13286,38 +13268,38 @@ version: 4.12.0-beta.7
13286
13268
  panel.innerHTML = sideCamera.outerHTML;
13287
13269
  });
13288
13270
  } else {
13289
- toArray$2(panels[0].children[0].children).forEach(function (panel) {
13290
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
13291
- if (groupKey && !includes(groupKeys, groupKey)) {
13292
- groupKeys.push(groupKey);
13293
- groupPanels[groupKey] = [panel];
13294
- } else if (groupKey) {
13295
- groupPanels[groupKey].push(panel);
13296
- }
13297
- });
13298
- sideState = groupKeys.reduce(function (state, key) {
13299
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
13300
- var element = groupPanels[key].reduce(function (el, panel) {
13301
- el.innerHTML += panel.outerHTML;
13302
- return el;
13303
- }, document.createElement("div"));
13304
- return __spread$1(state, [{
13305
- key: key,
13306
- start: start,
13307
- end: start + groupPanels[key].length - 1,
13308
- element: element
13309
- }]);
13310
- }, []);
13271
+ sideState = this._getSideStateFromPanels(panels);
13311
13272
  }
13273
+ void this.resize();
13312
13274
  return sideState;
13313
13275
  };
13276
+ __proto._getSideStateFromGroup = function (groupPanels) {
13277
+ return Object.keys(groupPanels).reduce(function (state, key) {
13278
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
13279
+ var element = groupPanels[key].reduce(function (el, panel) {
13280
+ el.innerHTML += panel.outerHTML;
13281
+ return el;
13282
+ }, document.createElement("div"));
13283
+ return __spread$1(state, [{
13284
+ key: key,
13285
+ start: start,
13286
+ end: start + groupPanels[key].length - 1,
13287
+ element: element
13288
+ }]);
13289
+ }, []);
13290
+ };
13291
+ __proto._getSideStateFromPanels = function (panels) {
13292
+ var groupPanels = this._getGroupFromAttribute(panels);
13293
+ return this._getSideStateFromGroup(groupPanels);
13294
+ };
13314
13295
  __proto._createSideFlicking = function () {
13315
13296
  var _this = this;
13316
13297
  return this.sideState.map(function (state, i) {
13317
13298
  return new Flicking(_this.camera.children[i], __assign$2(__assign$2({}, _this.sideOptions), {
13318
13299
  horizontal: false,
13319
13300
  panelsPerView: 1,
13320
- defaultIndex: state.start
13301
+ defaultIndex: state.start,
13302
+ moveType: "strict"
13321
13303
  }));
13322
13304
  });
13323
13305
  };