@egjs/flicking 4.12.0-beta.6 → 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.6
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.6
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.6
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.6
13026
13026
  * Flicking.VERSION; // ex) 4.0.0
13027
13027
  * ```
13028
13028
  */
13029
- Flicking.VERSION = "4.12.0-beta.6";
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.6
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,8 +13069,8 @@ version: 4.12.0-beta.6
13074
13069
  } else {
13075
13070
  _this._nextIndex = visiblePanels[0].index;
13076
13071
  }
13077
- // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 timeout으로 처리
13078
- setTimeout(function () {
13072
+ // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 requestAnimationFrame 처리
13073
+ requestAnimationFrame(function () {
13079
13074
  _this._sideFlicking.forEach(function (child, i) {
13080
13075
  if (_this._nextIndex !== i) {
13081
13076
  var _a = _this._sideState[i],
@@ -13119,28 +13114,19 @@ version: 4.12.0-beta.6
13119
13114
  }
13120
13115
  };
13121
13116
  // Internal states
13122
- _this._sideState = _this._createSideState();
13123
13117
  _this._moveDirection = null;
13124
13118
  _this._nextIndex = 0;
13125
13119
  // Bind options
13126
13120
  _this._sideOptions = options.sideOptions;
13127
- // Create core components
13128
- _this._sideFlicking = _this._createSideFlicking();
13121
+ _this._preserveIndex = options.preserveIndex;
13122
+ _this._disableSlideOnHold = options.disableSlideOnHold;
13123
+ _this._disableIndexSync = options.disableIndexSync;
13129
13124
  return _this;
13125
+ // Create core components
13130
13126
  }
13131
13127
  var __proto = CrossFlicking.prototype;
13132
13128
  Object.defineProperty(__proto, "sideFlicking", {
13133
13129
  // Components
13134
- /**
13135
- * {@link Control} instance of the Flicking
13136
- * @ko 현재 Flicking에 활성화된 {@link Control} 인스턴스
13137
- * @type {Control}
13138
- * @default SnapControl
13139
- * @readonly
13140
- * @see Control
13141
- * @see SnapControl
13142
- * @see FreeControl
13143
- */
13144
13130
  get: function () {
13145
13131
  return this._sideFlicking;
13146
13132
  },
@@ -13148,16 +13134,6 @@ version: 4.12.0-beta.6
13148
13134
  configurable: true
13149
13135
  });
13150
13136
  Object.defineProperty(__proto, "sideState", {
13151
- // Internal States
13152
- /**
13153
- * Whether Flicking's {@link Flicking#init init()} is called.
13154
- * This is `true` when {@link Flicking#init init()} is called, and is `false` after calling {@link Flicking#destroy destroy()}.
13155
- * @ko Flicking의 {@link Flicking#init init()}이 호출되었는지를 나타내는 멤버 변수.
13156
- * 이 값은 {@link Flicking#init init()}이 호출되었으면 `true`로 변하고, {@link Flicking#destroy destroy()}호출 이후에 다시 `false`로 변경됩니다.
13157
- * @type {boolean}
13158
- * @default false
13159
- * @readonly
13160
- */
13161
13137
  get: function () {
13162
13138
  return this._sideState;
13163
13139
  },
@@ -13166,40 +13142,54 @@ version: 4.12.0-beta.6
13166
13142
  });
13167
13143
  Object.defineProperty(__proto, "sideOptions", {
13168
13144
  // Options Getter
13169
- /**
13170
- * Change active panel index on mouse/touch hold while animating.
13171
- * `index` of the `willChange`/`willRestore` event will be used as new index.
13172
- * @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
13173
- * `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
13174
- * @type {FlickingOptions}
13175
- * @default undefined
13176
- * @see {@link https://naver.github.io/egjs-flicking/Options#changeonhold changeOnHold ( Options )}
13177
- */
13178
13145
  get: function () {
13179
13146
  return this._sideOptions;
13180
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
+ },
13181
13182
  enumerable: false,
13182
13183
  configurable: true
13183
13184
  });
13184
- /**
13185
- * Initialize Flicking and move to the default index
13186
- * This is automatically called on Flicking's constructor when `autoInit` is true(default)
13187
- * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
13188
- * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
13189
- * @fires Flicking#ready
13190
- * @return {Promise<void>}
13191
- */
13192
13185
  __proto.init = function () {
13193
13186
  var _this = this;
13194
13187
  return _super.prototype.init.call(this).then(function () {
13195
- return _this._addComponentEvents();
13188
+ _this._sideState = _this._createSideState();
13189
+ _this._sideFlicking = _this._createSideFlicking();
13190
+ _this._addComponentEvents();
13196
13191
  });
13197
13192
  };
13198
- /**
13199
- * Destroy Flicking and remove all event handlers
13200
- * @ko Flicking과 하위 컴포넌트들을 초기 상태로 되돌리고, 부착된 모든 이벤트 핸들러를 제거합니다
13201
- * @return {void}
13202
- */
13203
13193
  __proto.destroy = function () {
13204
13194
  // TODO 모든 child flicking destroy
13205
13195
  _super.prototype.destroy.call(this);
@@ -13216,51 +13206,41 @@ version: 4.12.0-beta.6
13216
13206
  flicking.on(EVENTS.CHANGED, _this._onSideChanged);
13217
13207
  });
13218
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
+ };
13219
13223
  __proto._createSideState = function () {
13220
13224
  var _this = this;
13221
- // data-index로 분류하기 전에 임시로 모든 children에 대해 side flicking으로 해보자.
13222
- // panels에 data-attributes가 붙어있을 때와 안 붙어있을 때를 다르게 처리
13223
- // 붙어있다면 가상의 viewport들을 index 갯수만큼 만들어줘야 한다
13224
13225
  var viewportEl = this.element;
13225
13226
  var cameraEl = this.camera.element;
13226
13227
  var panels = toArray$2(cameraEl.children);
13227
13228
  var sideState = [];
13228
13229
  var sidePanels = "";
13229
13230
  // check data attribute exists
13230
- var groupKeys = [];
13231
- var groupPanels = {};
13232
13231
  var sideCamera = document.createElement("div");
13233
13232
  sideCamera.classList.add(CLASS.CAMERA);
13234
13233
  var isCrossStructure = getDataAttributes(viewportEl, "data-cross-").structure;
13235
13234
  if (!isCrossStructure) {
13236
13235
  viewportEl.setAttribute("data-cross-structure", "true");
13237
- panels.forEach(function (panel) {
13238
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
13239
- if (groupKey && !includes(groupKeys, groupKey)) {
13240
- groupKeys.push(groupKey);
13241
- groupPanels[groupKey] = [panel];
13242
- } else if (groupKey) {
13243
- groupPanels[groupKey].push(panel);
13244
- }
13245
- });
13236
+ var groupPanels = this._getGroupFromAttribute(panels);
13237
+ var groupKeys = Object.keys(groupPanels);
13246
13238
  if (groupKeys.length) {
13247
- sideState = groupKeys.reduce(function (state, key) {
13248
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
13249
- var element = groupPanels[key].reduce(function (el, panel) {
13250
- sidePanels += panel.outerHTML;
13251
- el.innerHTML += panel.outerHTML;
13252
- return el;
13253
- }, document.createElement("div"));
13254
- return __spread$1(state, [{
13255
- key: key,
13256
- start: start,
13257
- end: start + groupPanels[key].length - 1,
13258
- element: element
13259
- }]);
13260
- }, []);
13239
+ sideState = this._getSideStateFromGroup(groupPanels);
13261
13240
  this.remove(0, this.panelCount - groupKeys.length);
13262
- sideState.forEach(function (_, i) {
13241
+ sideState.forEach(function (state, i) {
13263
13242
  var panel = _this.camera.children[i];
13243
+ sidePanels += state.element.innerHTML;
13264
13244
  Array.from(panel.attributes).forEach(function (attribute) {
13265
13245
  return panel.removeAttribute(attribute.name);
13266
13246
  });
@@ -13288,38 +13268,38 @@ version: 4.12.0-beta.6
13288
13268
  panel.innerHTML = sideCamera.outerHTML;
13289
13269
  });
13290
13270
  } else {
13291
- toArray$2(panels[0].children[0].children).forEach(function (panel) {
13292
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
13293
- if (groupKey && !includes(groupKeys, groupKey)) {
13294
- groupKeys.push(groupKey);
13295
- groupPanels[groupKey] = [panel];
13296
- } else if (groupKey) {
13297
- groupPanels[groupKey].push(panel);
13298
- }
13299
- });
13300
- sideState = groupKeys.reduce(function (state, key) {
13301
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
13302
- var element = groupPanels[key].reduce(function (el, panel) {
13303
- el.innerHTML += panel.outerHTML;
13304
- return el;
13305
- }, document.createElement("div"));
13306
- return __spread$1(state, [{
13307
- key: key,
13308
- start: start,
13309
- end: start + groupPanels[key].length - 1,
13310
- element: element
13311
- }]);
13312
- }, []);
13271
+ sideState = this._getSideStateFromPanels(panels);
13313
13272
  }
13273
+ void this.resize();
13314
13274
  return sideState;
13315
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
+ };
13316
13295
  __proto._createSideFlicking = function () {
13317
13296
  var _this = this;
13318
13297
  return this.sideState.map(function (state, i) {
13319
13298
  return new Flicking(_this.camera.children[i], __assign$2(__assign$2({}, _this.sideOptions), {
13320
13299
  horizontal: false,
13321
13300
  panelsPerView: 1,
13322
- defaultIndex: state.start
13301
+ defaultIndex: state.start,
13302
+ moveType: "strict"
13323
13303
  }));
13324
13304
  });
13325
13305
  };