@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.
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: 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(require('@egjs/component'), require('@egjs/axes'), require('@egjs/imready')) :
@@ -7991,7 +7991,7 @@ version: 4.12.0-beta.6
7991
7991
  * Flicking.VERSION; // ex) 4.0.0
7992
7992
  * ```
7993
7993
  */
7994
- Flicking.VERSION = "4.12.0-beta.6";
7994
+ Flicking.VERSION = "4.12.0-beta.8";
7995
7995
  return Flicking;
7996
7996
  }(Component);
7997
7997
 
@@ -7999,21 +7999,16 @@ version: 4.12.0-beta.6
7999
7999
  * Copyright (c) 2015 NAVER Corp.
8000
8000
  * egjs projects are licensed under the MIT license
8001
8001
  */
8002
- /**
8003
- * @extends Component
8004
- * @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
8005
- * @requires {@link https://github.com/naver/egjs-component|@egjs/component}
8006
- * @requires {@link https://github.com/naver/egjs-axes|@egjs/axes}
8007
- */
8008
8002
  var CrossFlicking = /*#__PURE__*/function (_super) {
8009
8003
  __extends(CrossFlicking, _super);
8010
- // Options Setter
8011
- // public set align(val: FlickingOptions["align"]) {
8012
- // this._align = val;
8013
- // }
8014
8004
  function CrossFlicking(root, options) {
8015
8005
  if (options === void 0) {
8016
- options = {};
8006
+ options = {
8007
+ sideOptions: {},
8008
+ preserveIndex: false,
8009
+ disableSlideOnHold: false,
8010
+ disableIndexSync: false
8011
+ };
8017
8012
  }
8018
8013
  var _this = _super.call(this, root, options) || this;
8019
8014
  _this._onHorizontalHoldStart = function () {
@@ -8039,8 +8034,8 @@ version: 4.12.0-beta.6
8039
8034
  } else {
8040
8035
  _this._nextIndex = visiblePanels[0].index;
8041
8036
  }
8042
- // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 timeout으로 처리
8043
- setTimeout(function () {
8037
+ // _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 requestAnimationFrame 처리
8038
+ requestAnimationFrame(function () {
8044
8039
  _this._sideFlicking.forEach(function (child, i) {
8045
8040
  if (_this._nextIndex !== i) {
8046
8041
  var _a = _this._sideState[i],
@@ -8084,28 +8079,19 @@ version: 4.12.0-beta.6
8084
8079
  }
8085
8080
  };
8086
8081
  // Internal states
8087
- _this._sideState = _this._createSideState();
8088
8082
  _this._moveDirection = null;
8089
8083
  _this._nextIndex = 0;
8090
8084
  // Bind options
8091
8085
  _this._sideOptions = options.sideOptions;
8092
- // Create core components
8093
- _this._sideFlicking = _this._createSideFlicking();
8086
+ _this._preserveIndex = options.preserveIndex;
8087
+ _this._disableSlideOnHold = options.disableSlideOnHold;
8088
+ _this._disableIndexSync = options.disableIndexSync;
8094
8089
  return _this;
8090
+ // Create core components
8095
8091
  }
8096
8092
  var __proto = CrossFlicking.prototype;
8097
8093
  Object.defineProperty(__proto, "sideFlicking", {
8098
8094
  // Components
8099
- /**
8100
- * {@link Control} instance of the Flicking
8101
- * @ko 현재 Flicking에 활성화된 {@link Control} 인스턴스
8102
- * @type {Control}
8103
- * @default SnapControl
8104
- * @readonly
8105
- * @see Control
8106
- * @see SnapControl
8107
- * @see FreeControl
8108
- */
8109
8095
  get: function () {
8110
8096
  return this._sideFlicking;
8111
8097
  },
@@ -8113,16 +8099,6 @@ version: 4.12.0-beta.6
8113
8099
  configurable: true
8114
8100
  });
8115
8101
  Object.defineProperty(__proto, "sideState", {
8116
- // Internal States
8117
- /**
8118
- * Whether Flicking's {@link Flicking#init init()} is called.
8119
- * This is `true` when {@link Flicking#init init()} is called, and is `false` after calling {@link Flicking#destroy destroy()}.
8120
- * @ko Flicking의 {@link Flicking#init init()}이 호출되었는지를 나타내는 멤버 변수.
8121
- * 이 값은 {@link Flicking#init init()}이 호출되었으면 `true`로 변하고, {@link Flicking#destroy destroy()}호출 이후에 다시 `false`로 변경됩니다.
8122
- * @type {boolean}
8123
- * @default false
8124
- * @readonly
8125
- */
8126
8102
  get: function () {
8127
8103
  return this._sideState;
8128
8104
  },
@@ -8131,40 +8107,54 @@ version: 4.12.0-beta.6
8131
8107
  });
8132
8108
  Object.defineProperty(__proto, "sideOptions", {
8133
8109
  // Options Getter
8134
- /**
8135
- * Change active panel index on mouse/touch hold while animating.
8136
- * `index` of the `willChange`/`willRestore` event will be used as new index.
8137
- * @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
8138
- * `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
8139
- * @type {FlickingOptions}
8140
- * @default undefined
8141
- * @see {@link https://naver.github.io/egjs-flicking/Options#changeonhold changeOnHold ( Options )}
8142
- */
8143
8110
  get: function () {
8144
8111
  return this._sideOptions;
8145
8112
  },
8113
+ // Options Setter
8114
+ set: function (val) {
8115
+ this._sideOptions = val;
8116
+ },
8117
+ enumerable: false,
8118
+ configurable: true
8119
+ });
8120
+ Object.defineProperty(__proto, "preserveIndex", {
8121
+ get: function () {
8122
+ return this._preserveIndex;
8123
+ },
8124
+ set: function (val) {
8125
+ this._preserveIndex = val;
8126
+ },
8127
+ enumerable: false,
8128
+ configurable: true
8129
+ });
8130
+ Object.defineProperty(__proto, "disableSlideOnHold", {
8131
+ get: function () {
8132
+ return this._disableSlideOnHold;
8133
+ },
8134
+ set: function (val) {
8135
+ this._disableSlideOnHold = val;
8136
+ },
8137
+ enumerable: false,
8138
+ configurable: true
8139
+ });
8140
+ Object.defineProperty(__proto, "disableIndexSync", {
8141
+ get: function () {
8142
+ return this._disableIndexSync;
8143
+ },
8144
+ set: function (val) {
8145
+ this._disableIndexSync = val;
8146
+ },
8146
8147
  enumerable: false,
8147
8148
  configurable: true
8148
8149
  });
8149
- /**
8150
- * Initialize Flicking and move to the default index
8151
- * This is automatically called on Flicking's constructor when `autoInit` is true(default)
8152
- * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
8153
- * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
8154
- * @fires Flicking#ready
8155
- * @return {Promise<void>}
8156
- */
8157
8150
  __proto.init = function () {
8158
8151
  var _this = this;
8159
8152
  return _super.prototype.init.call(this).then(function () {
8160
- return _this._addComponentEvents();
8153
+ _this._sideState = _this._createSideState();
8154
+ _this._sideFlicking = _this._createSideFlicking();
8155
+ _this._addComponentEvents();
8161
8156
  });
8162
8157
  };
8163
- /**
8164
- * Destroy Flicking and remove all event handlers
8165
- * @ko Flicking과 하위 컴포넌트들을 초기 상태로 되돌리고, 부착된 모든 이벤트 핸들러를 제거합니다
8166
- * @return {void}
8167
- */
8168
8158
  __proto.destroy = function () {
8169
8159
  // TODO 모든 child flicking destroy
8170
8160
  _super.prototype.destroy.call(this);
@@ -8181,51 +8171,41 @@ version: 4.12.0-beta.6
8181
8171
  flicking.on(EVENTS.CHANGED, _this._onSideChanged);
8182
8172
  });
8183
8173
  };
8174
+ __proto._getGroupFromAttribute = function (panels) {
8175
+ var groupKeys = [];
8176
+ var groupPanels = {};
8177
+ panels.forEach(function (panel) {
8178
+ var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8179
+ if (groupKey && !includes(groupKeys, groupKey)) {
8180
+ groupKeys.push(groupKey);
8181
+ groupPanels[groupKey] = [panel];
8182
+ } else if (groupKey) {
8183
+ groupPanels[groupKey].push(panel);
8184
+ }
8185
+ });
8186
+ return groupPanels;
8187
+ };
8184
8188
  __proto._createSideState = function () {
8185
8189
  var _this = this;
8186
- // data-index로 분류하기 전에 임시로 모든 children에 대해 side flicking으로 해보자.
8187
- // panels에 data-attributes가 붙어있을 때와 안 붙어있을 때를 다르게 처리
8188
- // 붙어있다면 가상의 viewport들을 index 갯수만큼 만들어줘야 한다
8189
8190
  var viewportEl = this.element;
8190
8191
  var cameraEl = this.camera.element;
8191
8192
  var panels = toArray(cameraEl.children);
8192
8193
  var sideState = [];
8193
8194
  var sidePanels = "";
8194
8195
  // check data attribute exists
8195
- var groupKeys = [];
8196
- var groupPanels = {};
8197
8196
  var sideCamera = document.createElement("div");
8198
8197
  sideCamera.classList.add(CLASS.CAMERA);
8199
8198
  var isCrossStructure = getDataAttributes(viewportEl, "data-cross-").structure;
8200
8199
  if (!isCrossStructure) {
8201
8200
  viewportEl.setAttribute("data-cross-structure", "true");
8202
- panels.forEach(function (panel) {
8203
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8204
- if (groupKey && !includes(groupKeys, groupKey)) {
8205
- groupKeys.push(groupKey);
8206
- groupPanels[groupKey] = [panel];
8207
- } else if (groupKey) {
8208
- groupPanels[groupKey].push(panel);
8209
- }
8210
- });
8201
+ var groupPanels = this._getGroupFromAttribute(panels);
8202
+ var groupKeys = Object.keys(groupPanels);
8211
8203
  if (groupKeys.length) {
8212
- sideState = groupKeys.reduce(function (state, key) {
8213
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
8214
- var element = groupPanels[key].reduce(function (el, panel) {
8215
- sidePanels += panel.outerHTML;
8216
- el.innerHTML += panel.outerHTML;
8217
- return el;
8218
- }, document.createElement("div"));
8219
- return __spread(state, [{
8220
- key: key,
8221
- start: start,
8222
- end: start + groupPanels[key].length - 1,
8223
- element: element
8224
- }]);
8225
- }, []);
8204
+ sideState = this._getSideStateFromGroup(groupPanels);
8226
8205
  this.remove(0, this.panelCount - groupKeys.length);
8227
- sideState.forEach(function (_, i) {
8206
+ sideState.forEach(function (state, i) {
8228
8207
  var panel = _this.camera.children[i];
8208
+ sidePanels += state.element.innerHTML;
8229
8209
  Array.from(panel.attributes).forEach(function (attribute) {
8230
8210
  return panel.removeAttribute(attribute.name);
8231
8211
  });
@@ -8253,38 +8233,38 @@ version: 4.12.0-beta.6
8253
8233
  panel.innerHTML = sideCamera.outerHTML;
8254
8234
  });
8255
8235
  } else {
8256
- toArray(panels[0].children[0].children).forEach(function (panel) {
8257
- var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
8258
- if (groupKey && !includes(groupKeys, groupKey)) {
8259
- groupKeys.push(groupKey);
8260
- groupPanels[groupKey] = [panel];
8261
- } else if (groupKey) {
8262
- groupPanels[groupKey].push(panel);
8263
- }
8264
- });
8265
- sideState = groupKeys.reduce(function (state, key) {
8266
- var start = state.length ? +state[state.length - 1].end + 1 : 0;
8267
- var element = groupPanels[key].reduce(function (el, panel) {
8268
- el.innerHTML += panel.outerHTML;
8269
- return el;
8270
- }, document.createElement("div"));
8271
- return __spread(state, [{
8272
- key: key,
8273
- start: start,
8274
- end: start + groupPanels[key].length - 1,
8275
- element: element
8276
- }]);
8277
- }, []);
8236
+ sideState = this._getSideStateFromPanels(panels);
8278
8237
  }
8238
+ void this.resize();
8279
8239
  return sideState;
8280
8240
  };
8241
+ __proto._getSideStateFromGroup = function (groupPanels) {
8242
+ return Object.keys(groupPanels).reduce(function (state, key) {
8243
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
8244
+ var element = groupPanels[key].reduce(function (el, panel) {
8245
+ el.innerHTML += panel.outerHTML;
8246
+ return el;
8247
+ }, document.createElement("div"));
8248
+ return __spread(state, [{
8249
+ key: key,
8250
+ start: start,
8251
+ end: start + groupPanels[key].length - 1,
8252
+ element: element
8253
+ }]);
8254
+ }, []);
8255
+ };
8256
+ __proto._getSideStateFromPanels = function (panels) {
8257
+ var groupPanels = this._getGroupFromAttribute(panels);
8258
+ return this._getSideStateFromGroup(groupPanels);
8259
+ };
8281
8260
  __proto._createSideFlicking = function () {
8282
8261
  var _this = this;
8283
8262
  return this.sideState.map(function (state, i) {
8284
8263
  return new Flicking(_this.camera.children[i], __assign(__assign({}, _this.sideOptions), {
8285
8264
  horizontal: false,
8286
8265
  panelsPerView: 1,
8287
- defaultIndex: state.start
8266
+ defaultIndex: state.start,
8267
+ moveType: "strict"
8288
8268
  }));
8289
8269
  });
8290
8270
  };