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