@egjs/flicking 4.12.0-beta.1 → 4.12.0-beta.10
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/declaration/CrossFlicking.d.ts +62 -14
- package/declaration/camera/Camera.d.ts +1 -0
- package/declaration/const/external.d.ts +2 -0
- package/declaration/index.d.ts +2 -1
- package/declaration/utils.d.ts +2 -0
- package/dist/flicking.cjs.js +319 -122
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +313 -122
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +316 -122
- package/dist/flicking.js.map +1 -1
- package/dist/flicking.min.js +2 -2
- package/dist/flicking.min.js.map +1 -1
- package/dist/flicking.pkgd.js +1083 -882
- package/dist/flicking.pkgd.js.map +1 -1
- package/dist/flicking.pkgd.min.js +2 -2
- package/dist/flicking.pkgd.min.js.map +1 -1
- package/package.json +3 -2
- package/sass/flicking.sass +13 -0
- package/src/CrossFlicking.ts +330 -143
- package/src/camera/Camera.ts +24 -4
- package/src/const/external.ts +2 -0
- package/src/index.ts +2 -1
- package/src/utils.ts +21 -0
- package/dist/flicking-inline.css +0 -45
- package/dist/flicking-inline.min.css +0 -1
- package/dist/flicking.css +0 -44
- package/dist/flicking.min.css +0 -1
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
|
+
version: 4.12.0-beta.10
|
|
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')) :
|
|
@@ -387,6 +387,8 @@ version: 4.12.0-beta.1
|
|
|
387
387
|
STRICT: "strict"
|
|
388
388
|
};
|
|
389
389
|
var CLASS = {
|
|
390
|
+
VIEWPORT: "flicking-viewport",
|
|
391
|
+
CAMERA: "flicking-camera",
|
|
390
392
|
VERTICAL: "vertical",
|
|
391
393
|
HIDDEN: "flicking-hidden",
|
|
392
394
|
DEFAULT_VIRTUAL: "flicking-panel"
|
|
@@ -751,6 +753,26 @@ version: 4.12.0-beta.1
|
|
|
751
753
|
obj.__proto__ = proto;
|
|
752
754
|
return obj;
|
|
753
755
|
};
|
|
756
|
+
var camelize = function (str) {
|
|
757
|
+
return str.replace(/[\s-_]([a-z])/g, function (all, letter) {
|
|
758
|
+
return letter.toUpperCase();
|
|
759
|
+
});
|
|
760
|
+
};
|
|
761
|
+
var getDataAttributes = function (element, attributePrefix) {
|
|
762
|
+
var dataAttributes = {};
|
|
763
|
+
var attributes = element.attributes;
|
|
764
|
+
var length = attributes.length;
|
|
765
|
+
for (var i = 0; i < length; ++i) {
|
|
766
|
+
var attribute = attributes[i];
|
|
767
|
+
var name_1 = attribute.name,
|
|
768
|
+
value = attribute.value;
|
|
769
|
+
if (name_1.indexOf(attributePrefix) === -1) {
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
dataAttributes[camelize(name_1.replace(attributePrefix, ""))] = value;
|
|
773
|
+
}
|
|
774
|
+
return dataAttributes;
|
|
775
|
+
};
|
|
754
776
|
|
|
755
777
|
var Utils = {
|
|
756
778
|
__proto__: null,
|
|
@@ -782,7 +804,9 @@ version: 4.12.0-beta.1
|
|
|
782
804
|
circulateIndex: circulateIndex,
|
|
783
805
|
range: range,
|
|
784
806
|
getElementSize: getElementSize,
|
|
785
|
-
setPrototypeOf: setPrototypeOf
|
|
807
|
+
setPrototypeOf: setPrototypeOf,
|
|
808
|
+
camelize: camelize,
|
|
809
|
+
getDataAttributes: getDataAttributes
|
|
786
810
|
};
|
|
787
811
|
|
|
788
812
|
/*
|
|
@@ -3791,6 +3815,7 @@ version: 4.12.0-beta.1
|
|
|
3791
3815
|
var _this = this;
|
|
3792
3816
|
var _b = (_a === void 0 ? {} : _a).align,
|
|
3793
3817
|
align = _b === void 0 ? ALIGN.CENTER : _b;
|
|
3818
|
+
this._lookedOffset = 0;
|
|
3794
3819
|
this._checkTranslateSupport = function () {
|
|
3795
3820
|
var e_1, _a;
|
|
3796
3821
|
var transforms = ["webkitTransform", "msTransform", "MozTransform", "OTransform", "transform"];
|
|
@@ -4150,6 +4175,8 @@ version: 4.12.0-beta.1
|
|
|
4150
4175
|
*/
|
|
4151
4176
|
__proto.lookAt = function (pos) {
|
|
4152
4177
|
var _this = this;
|
|
4178
|
+
var prevOffset = this._offset;
|
|
4179
|
+
var isChangedOffset = this._lookedOffset !== prevOffset;
|
|
4153
4180
|
var flicking = getFlickingAttached(this._flicking);
|
|
4154
4181
|
var prevPos = this._position;
|
|
4155
4182
|
this._position = pos;
|
|
@@ -4160,7 +4187,12 @@ version: 4.12.0-beta.1
|
|
|
4160
4187
|
if (toggled) {
|
|
4161
4188
|
void flicking.renderer.render().then(function () {
|
|
4162
4189
|
_this.updateOffset();
|
|
4190
|
+
_this._lookedOffset = _this._offset;
|
|
4163
4191
|
});
|
|
4192
|
+
} else if (isChangedOffset) {
|
|
4193
|
+
// sync offset for renderOnlyVisible on resize
|
|
4194
|
+
this.updateOffset();
|
|
4195
|
+
this._lookedOffset = this._offset;
|
|
4164
4196
|
} else {
|
|
4165
4197
|
this.applyTransform();
|
|
4166
4198
|
}
|
|
@@ -4335,8 +4367,8 @@ version: 4.12.0-beta.1
|
|
|
4335
4367
|
return this;
|
|
4336
4368
|
};
|
|
4337
4369
|
/**
|
|
4338
|
-
* Update Viewport's height to
|
|
4339
|
-
* @ko 현재
|
|
4370
|
+
* Update Viewport's height to visible panel's max height
|
|
4371
|
+
* @ko 현재 활성화된 패널과 보이는 패널의 최대 높이와 동일하도록 뷰포트의 높이를 업데이트합니다
|
|
4340
4372
|
* @throws {FlickingError}
|
|
4341
4373
|
* {@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} When {@link Camera#init init} is not called before
|
|
4342
4374
|
* <ko>{@link ERROR_CODE NOT_ATTACHED_TO_FLICKING} {@link Camera#init init}이 이전에 호출되지 않은 경우</ko>
|
|
@@ -4346,9 +4378,17 @@ version: 4.12.0-beta.1
|
|
|
4346
4378
|
__proto.updateAdaptiveHeight = function () {
|
|
4347
4379
|
var flicking = getFlickingAttached(this._flicking);
|
|
4348
4380
|
var activePanel = flicking.control.activePanel;
|
|
4349
|
-
|
|
4381
|
+
var visiblePanels = flicking.visiblePanels;
|
|
4382
|
+
var selectedPanels = __spread(visiblePanels);
|
|
4383
|
+
if (activePanel) {
|
|
4384
|
+
selectedPanels.push(activePanel);
|
|
4385
|
+
}
|
|
4386
|
+
if (!flicking.horizontal || !flicking.adaptive || !selectedPanels.length) return;
|
|
4387
|
+
var maxHeight = Math.max.apply(Math, __spread(selectedPanels.map(function (panel) {
|
|
4388
|
+
return panel.height;
|
|
4389
|
+
})));
|
|
4350
4390
|
flicking.viewport.setSize({
|
|
4351
|
-
height:
|
|
4391
|
+
height: maxHeight
|
|
4352
4392
|
});
|
|
4353
4393
|
};
|
|
4354
4394
|
/**
|
|
@@ -4419,6 +4459,7 @@ version: 4.12.0-beta.1
|
|
|
4419
4459
|
};
|
|
4420
4460
|
__proto._resetInternalValues = function () {
|
|
4421
4461
|
this._position = 0;
|
|
4462
|
+
this._lookedOffset = 0;
|
|
4422
4463
|
this._alignPos = 0;
|
|
4423
4464
|
this._offset = 0;
|
|
4424
4465
|
this._circularOffset = 0;
|
|
@@ -7967,186 +8008,339 @@ version: 4.12.0-beta.1
|
|
|
7967
8008
|
* Flicking.VERSION; // ex) 4.0.0
|
|
7968
8009
|
* ```
|
|
7969
8010
|
*/
|
|
7970
|
-
Flicking.VERSION = "4.12.0-beta.
|
|
8011
|
+
Flicking.VERSION = "4.12.0-beta.10";
|
|
7971
8012
|
return Flicking;
|
|
7972
8013
|
}(Component);
|
|
7973
8014
|
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
*/
|
|
8015
|
+
var SIDE_EVENTS = {
|
|
8016
|
+
HOLD_START: "sideHoldStart",
|
|
8017
|
+
HOLD_END: "sideHoldEnd",
|
|
8018
|
+
MOVE_START: "sideMoveStart",
|
|
8019
|
+
MOVE: "sideMove",
|
|
8020
|
+
MOVE_END: "sideMoveEnd",
|
|
8021
|
+
WILL_CHANGE: "sideWillChange",
|
|
8022
|
+
CHANGED: "sideChanged"
|
|
8023
|
+
};
|
|
7984
8024
|
var CrossFlicking = /*#__PURE__*/function (_super) {
|
|
7985
8025
|
__extends(CrossFlicking, _super);
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
8026
|
+
function CrossFlicking(root, options) {
|
|
8027
|
+
var _this = _super.call(this, root, options) || this;
|
|
8028
|
+
_this._syncToCategory = function (index, outerIndex) {
|
|
8029
|
+
if (_this._disableIndexSync) {
|
|
8030
|
+
return;
|
|
8031
|
+
}
|
|
8032
|
+
_this.stopAnimation();
|
|
8033
|
+
_this._sideFlicking.forEach(function (child, i) {
|
|
8034
|
+
var _a = _this._sideState[i],
|
|
8035
|
+
start = _a.start,
|
|
8036
|
+
end = _a.end;
|
|
8037
|
+
if (start <= index && end >= index && outerIndex !== i) {
|
|
8038
|
+
child.stopAnimation();
|
|
8039
|
+
void child.moveTo(index, 0);
|
|
8040
|
+
void _this.moveTo(i, 0);
|
|
8041
|
+
}
|
|
8042
|
+
});
|
|
8043
|
+
};
|
|
8044
|
+
_this._setDraggable = function (direction, draggable) {
|
|
8045
|
+
if (!_this._disableSlideOnHold) {
|
|
8046
|
+
return;
|
|
8047
|
+
}
|
|
8048
|
+
var dragThreshold = _this._originalDragThreshold;
|
|
8049
|
+
var threshold = draggable ? dragThreshold && dragThreshold >= 10 ? dragThreshold : 10 : Infinity;
|
|
8050
|
+
if (direction === MOVE_DIRECTION.HORIZONTAL === _this.horizontal) {
|
|
8051
|
+
_this.dragThreshold = threshold;
|
|
8052
|
+
} else if (direction === MOVE_DIRECTION.VERTICAL === _this.horizontal) {
|
|
8053
|
+
_this._sideFlicking.forEach(function (child) {
|
|
8054
|
+
child.dragThreshold = threshold;
|
|
8055
|
+
});
|
|
8056
|
+
}
|
|
8057
|
+
};
|
|
8058
|
+
_this._setPreviousSideIndex = function () {
|
|
8059
|
+
_this._sideFlicking.forEach(function (child, i) {
|
|
8060
|
+
var _a = _this._sideState[i],
|
|
8061
|
+
start = _a.start,
|
|
8062
|
+
end = _a.end;
|
|
8063
|
+
if (_this._preserveIndex) {
|
|
8064
|
+
if (_this._nextIndex !== i) {
|
|
8065
|
+
if (child.index < start) {
|
|
8066
|
+
child.stopAnimation();
|
|
8067
|
+
void child.moveTo(start, 0);
|
|
8068
|
+
} else if (child.index > end) {
|
|
8069
|
+
child.stopAnimation();
|
|
8070
|
+
void child.moveTo(end, 0);
|
|
8071
|
+
}
|
|
8072
|
+
}
|
|
8073
|
+
} else {
|
|
8074
|
+
if (_this._nextIndex !== i) {
|
|
8075
|
+
void child.moveTo(start, 0);
|
|
8076
|
+
}
|
|
8077
|
+
}
|
|
8078
|
+
});
|
|
8079
|
+
};
|
|
7995
8080
|
_this._onHorizontalHoldStart = function () {
|
|
7996
|
-
_this.
|
|
8081
|
+
_this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
|
|
7997
8082
|
_this._moveDirection = null;
|
|
7998
8083
|
};
|
|
7999
8084
|
_this._onHorizontalMove = function (e) {
|
|
8000
8085
|
if (e.isTrusted && !_this._moveDirection) {
|
|
8001
|
-
_this.
|
|
8002
|
-
child.dragThreshold = Infinity;
|
|
8003
|
-
});
|
|
8086
|
+
_this._setDraggable(MOVE_DIRECTION.VERTICAL, false);
|
|
8004
8087
|
_this._moveDirection = MOVE_DIRECTION.HORIZONTAL;
|
|
8005
8088
|
}
|
|
8006
8089
|
};
|
|
8007
8090
|
_this._onHorizontalMoveEnd = function (e) {
|
|
8008
8091
|
var visiblePanels = _this.visiblePanels;
|
|
8009
|
-
_this._verticalFlicking.forEach(function (child) {
|
|
8010
|
-
child.dragThreshold = 10;
|
|
8011
|
-
});
|
|
8012
|
-
_this._moveDirection = null;
|
|
8013
8092
|
if (visiblePanels.length > 1) {
|
|
8014
8093
|
_this._nextIndex = e.direction === "NEXT" ? visiblePanels[1].index : visiblePanels[0].index;
|
|
8015
8094
|
} else {
|
|
8016
8095
|
_this._nextIndex = visiblePanels[0].index;
|
|
8017
8096
|
}
|
|
8018
|
-
_this.
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
if (child.index < start) {
|
|
8024
|
-
child.stopAnimation();
|
|
8025
|
-
void child.moveTo(start, 0);
|
|
8026
|
-
} else if (child.index > end) {
|
|
8027
|
-
child.stopAnimation();
|
|
8028
|
-
void child.moveTo(end, 0);
|
|
8029
|
-
}
|
|
8030
|
-
}
|
|
8097
|
+
_this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
|
|
8098
|
+
_this._moveDirection = null;
|
|
8099
|
+
// _syncToCategory에서 완전히 가로 이동이 이루어지기 전에 세로 방향 index가 변하는 경우가 있어 requestAnimationFrame 처리
|
|
8100
|
+
requestAnimationFrame(function () {
|
|
8101
|
+
return _this._setPreviousSideIndex();
|
|
8031
8102
|
});
|
|
8032
8103
|
if (e.isTrusted) {
|
|
8033
|
-
_this._syncToCategory(_this.
|
|
8104
|
+
_this._syncToCategory(_this._sideFlicking[_this._nextIndex].index, _this._nextIndex);
|
|
8034
8105
|
}
|
|
8035
8106
|
};
|
|
8036
|
-
_this.
|
|
8037
|
-
_this.
|
|
8038
|
-
child.dragThreshold = 10;
|
|
8039
|
-
});
|
|
8107
|
+
_this._onSideHoldStart = function () {
|
|
8108
|
+
_this._setDraggable(MOVE_DIRECTION.VERTICAL, true);
|
|
8040
8109
|
_this._moveDirection = null;
|
|
8041
8110
|
};
|
|
8042
|
-
_this.
|
|
8111
|
+
_this._onSideMove = function (e) {
|
|
8043
8112
|
if (e.isTrusted && !_this._moveDirection) {
|
|
8044
|
-
_this.
|
|
8113
|
+
_this._setDraggable(MOVE_DIRECTION.HORIZONTAL, false);
|
|
8045
8114
|
_this._moveDirection = MOVE_DIRECTION.VERTICAL;
|
|
8046
8115
|
}
|
|
8047
8116
|
};
|
|
8048
|
-
_this.
|
|
8049
|
-
_this.
|
|
8117
|
+
_this._onSideMoveEnd = function () {
|
|
8118
|
+
_this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
|
|
8050
8119
|
_this._moveDirection = null;
|
|
8051
8120
|
};
|
|
8052
|
-
_this.
|
|
8053
|
-
// this.visiblePanels.length
|
|
8054
|
-
//
|
|
8055
|
-
if (_this.visiblePanels.length < 2 && _this.
|
|
8121
|
+
_this._onSideChanged = function (e) {
|
|
8122
|
+
// If this.visiblePanels.length >= 2, it means that horizontal flicking is being dragged.
|
|
8123
|
+
// In this case, syncToCategory in _onHorizontalMoveEnd will fire after moving finishes, so we don't fire it here.
|
|
8124
|
+
if (_this.visiblePanels.length < 2 && _this._sideFlicking[_this.index] === e.currentTarget) {
|
|
8056
8125
|
_this._syncToCategory(e.index, _this.index);
|
|
8057
8126
|
}
|
|
8058
8127
|
};
|
|
8128
|
+
var _a = options.sideOptions,
|
|
8129
|
+
sideOptions = _a === void 0 ? {} : _a,
|
|
8130
|
+
_b = options.preserveIndex,
|
|
8131
|
+
preserveIndex = _b === void 0 ? true : _b,
|
|
8132
|
+
_c = options.disableSlideOnHold,
|
|
8133
|
+
disableSlideOnHold = _c === void 0 ? true : _c,
|
|
8134
|
+
_d = options.disableIndexSync,
|
|
8135
|
+
disableIndexSync = _d === void 0 ? false : _d;
|
|
8059
8136
|
// Internal states
|
|
8060
|
-
_this._verticalState = [];
|
|
8061
8137
|
_this._moveDirection = null;
|
|
8062
8138
|
_this._nextIndex = 0;
|
|
8139
|
+
_this._originalDragThreshold = _this.dragThreshold;
|
|
8063
8140
|
// Bind options
|
|
8064
|
-
_this.
|
|
8141
|
+
_this._sideOptions = sideOptions;
|
|
8142
|
+
_this._preserveIndex = preserveIndex;
|
|
8143
|
+
_this._disableSlideOnHold = disableSlideOnHold;
|
|
8144
|
+
_this._disableIndexSync = disableIndexSync;
|
|
8065
8145
|
return _this;
|
|
8066
|
-
// Create core components
|
|
8067
|
-
// this._viewport = new Viewport(this, getElement(root));
|
|
8068
8146
|
}
|
|
8069
8147
|
var __proto = CrossFlicking.prototype;
|
|
8070
|
-
Object.defineProperty(__proto, "
|
|
8148
|
+
Object.defineProperty(__proto, "sideFlicking", {
|
|
8071
8149
|
// Components
|
|
8072
|
-
/**
|
|
8073
|
-
* Change active panel index on mouse/touch hold while animating.
|
|
8074
|
-
* `index` of the `willChange`/`willRestore` event will be used as new index.
|
|
8075
|
-
* @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
|
|
8076
|
-
* `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
|
|
8077
|
-
* @type {FlickingOptions}
|
|
8078
|
-
* @default undefined
|
|
8079
|
-
* @see {@link https://naver.github.io/egjs-flicking/Options#changeonhold changeOnHold ( Options )}
|
|
8080
|
-
*/
|
|
8081
8150
|
get: function () {
|
|
8082
|
-
return this.
|
|
8151
|
+
return this._sideFlicking;
|
|
8152
|
+
},
|
|
8153
|
+
enumerable: false,
|
|
8154
|
+
configurable: true
|
|
8155
|
+
});
|
|
8156
|
+
Object.defineProperty(__proto, "sideState", {
|
|
8157
|
+
get: function () {
|
|
8158
|
+
return this._sideState;
|
|
8159
|
+
},
|
|
8160
|
+
enumerable: false,
|
|
8161
|
+
configurable: true
|
|
8162
|
+
});
|
|
8163
|
+
Object.defineProperty(__proto, "sideOptions", {
|
|
8164
|
+
// Options Getter
|
|
8165
|
+
get: function () {
|
|
8166
|
+
return this._sideOptions;
|
|
8167
|
+
},
|
|
8168
|
+
// Options Setter
|
|
8169
|
+
set: function (val) {
|
|
8170
|
+
this._sideOptions = val;
|
|
8171
|
+
},
|
|
8172
|
+
enumerable: false,
|
|
8173
|
+
configurable: true
|
|
8174
|
+
});
|
|
8175
|
+
Object.defineProperty(__proto, "preserveIndex", {
|
|
8176
|
+
get: function () {
|
|
8177
|
+
return this._preserveIndex;
|
|
8178
|
+
},
|
|
8179
|
+
set: function (val) {
|
|
8180
|
+
this._preserveIndex = val;
|
|
8181
|
+
},
|
|
8182
|
+
enumerable: false,
|
|
8183
|
+
configurable: true
|
|
8184
|
+
});
|
|
8185
|
+
Object.defineProperty(__proto, "disableSlideOnHold", {
|
|
8186
|
+
get: function () {
|
|
8187
|
+
return this._disableSlideOnHold;
|
|
8188
|
+
},
|
|
8189
|
+
set: function (val) {
|
|
8190
|
+
this._disableSlideOnHold = val;
|
|
8191
|
+
},
|
|
8192
|
+
enumerable: false,
|
|
8193
|
+
configurable: true
|
|
8194
|
+
});
|
|
8195
|
+
Object.defineProperty(__proto, "disableIndexSync", {
|
|
8196
|
+
get: function () {
|
|
8197
|
+
return this._disableIndexSync;
|
|
8198
|
+
},
|
|
8199
|
+
set: function (val) {
|
|
8200
|
+
this._disableIndexSync = val;
|
|
8083
8201
|
},
|
|
8084
8202
|
enumerable: false,
|
|
8085
8203
|
configurable: true
|
|
8086
8204
|
});
|
|
8087
|
-
/**
|
|
8088
|
-
* Initialize Flicking and move to the default index
|
|
8089
|
-
* This is automatically called on Flicking's constructor when `autoInit` is true(default)
|
|
8090
|
-
* @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
|
|
8091
|
-
* 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
|
|
8092
|
-
* @fires Flicking#ready
|
|
8093
|
-
* @return {Promise<void>}
|
|
8094
|
-
*/
|
|
8095
8205
|
__proto.init = function () {
|
|
8096
8206
|
var _this = this;
|
|
8097
8207
|
return _super.prototype.init.call(this).then(function () {
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8208
|
+
_this._sideState = _this._createSideState();
|
|
8209
|
+
_this._sideFlicking = _this._createSideFlicking();
|
|
8210
|
+
_this._addComponentEvents();
|
|
8211
|
+
});
|
|
8212
|
+
};
|
|
8213
|
+
__proto.destroy = function () {
|
|
8214
|
+
this._sideFlicking.forEach(function (flicking) {
|
|
8215
|
+
flicking.destroy();
|
|
8216
|
+
});
|
|
8217
|
+
_super.prototype.destroy.call(this);
|
|
8218
|
+
};
|
|
8219
|
+
__proto._addComponentEvents = function () {
|
|
8220
|
+
var _this = this;
|
|
8221
|
+
this.on(EVENTS.HOLD_START, this._onHorizontalHoldStart);
|
|
8222
|
+
this.on(EVENTS.MOVE, this._onHorizontalMove);
|
|
8223
|
+
this.on(EVENTS.MOVE_END, this._onHorizontalMoveEnd);
|
|
8224
|
+
this._sideFlicking.forEach(function (flicking, mainIndex) {
|
|
8225
|
+
flicking.on(EVENTS.HOLD_START, _this._onSideHoldStart);
|
|
8226
|
+
flicking.on(EVENTS.MOVE, _this._onSideMove);
|
|
8227
|
+
flicking.on(EVENTS.MOVE_END, _this._onSideMoveEnd);
|
|
8228
|
+
flicking.on(EVENTS.CHANGED, _this._onSideChanged);
|
|
8229
|
+
Object.keys(SIDE_EVENTS).forEach(function (name) {
|
|
8230
|
+
flicking.on(EVENTS[name], function (event) {
|
|
8231
|
+
_this.trigger(new Component.ComponentEvent(SIDE_EVENTS[name], __assign({
|
|
8232
|
+
mainIndex: mainIndex
|
|
8233
|
+
}, event)));
|
|
8234
|
+
});
|
|
8112
8235
|
});
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8236
|
+
});
|
|
8237
|
+
};
|
|
8238
|
+
__proto._createSideState = function () {
|
|
8239
|
+
var viewportEl = this.element;
|
|
8240
|
+
var cameraEl = this.camera.element;
|
|
8241
|
+
var panels = toArray(cameraEl.children);
|
|
8242
|
+
var isCrossStructure = getDataAttributes(viewportEl, "data-cross-").structure;
|
|
8243
|
+
var sideState = [];
|
|
8244
|
+
if (!isCrossStructure) {
|
|
8245
|
+
var groupPanels = this._getGroupFromAttribute(panels);
|
|
8246
|
+
var groupKeys = Object.keys(groupPanels);
|
|
8247
|
+
if (groupKeys.length) {
|
|
8248
|
+
sideState = this._getSideStateFromGroup(groupPanels);
|
|
8249
|
+
this.remove(0, this.panelCount - groupKeys.length);
|
|
8250
|
+
} else {
|
|
8251
|
+
sideState = this._getSideStateFromPanels(panels);
|
|
8252
|
+
}
|
|
8253
|
+
this._createCrossStructure(sideState);
|
|
8254
|
+
} else {
|
|
8255
|
+
sideState = this._getSideStateFromCrossStructure(panels);
|
|
8256
|
+
}
|
|
8257
|
+
void this.resize();
|
|
8258
|
+
return sideState;
|
|
8259
|
+
};
|
|
8260
|
+
__proto._createCrossStructure = function (sideState) {
|
|
8261
|
+
var _this = this;
|
|
8262
|
+
var sideCamera = document.createElement("div");
|
|
8263
|
+
var sidePanels = "";
|
|
8264
|
+
sideCamera.classList.add(CLASS.CAMERA);
|
|
8265
|
+
sideState.forEach(function (state, i) {
|
|
8266
|
+
var panel = _this.camera.children[i];
|
|
8267
|
+
sidePanels += state.element.innerHTML;
|
|
8268
|
+
Array.from(panel.attributes).forEach(function (attribute) {
|
|
8269
|
+
return panel.removeAttribute(attribute.name);
|
|
8119
8270
|
});
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
_this.
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8271
|
+
});
|
|
8272
|
+
sideCamera.innerHTML = sidePanels;
|
|
8273
|
+
sideState.forEach(function (_, i) {
|
|
8274
|
+
var panel = _this.camera.children[i];
|
|
8275
|
+
[CLASS.VIEWPORT, CLASS.VERTICAL].forEach(function (className) {
|
|
8276
|
+
if (!panel.classList.contains(className)) {
|
|
8277
|
+
panel.classList.add(className);
|
|
8278
|
+
}
|
|
8128
8279
|
});
|
|
8280
|
+
panel.innerHTML = sideCamera.outerHTML;
|
|
8129
8281
|
});
|
|
8282
|
+
this.element.setAttribute("data-cross-structure", "true");
|
|
8130
8283
|
};
|
|
8131
|
-
__proto.
|
|
8132
|
-
var
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
var
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
void _this.moveTo(i, 0);
|
|
8284
|
+
__proto._getGroupFromAttribute = function (panels) {
|
|
8285
|
+
var groupKeys = [];
|
|
8286
|
+
var groupPanels = {};
|
|
8287
|
+
panels.forEach(function (panel) {
|
|
8288
|
+
var groupKey = getDataAttributes(panel, "data-cross-").groupkey;
|
|
8289
|
+
if (groupKey && !includes(groupKeys, groupKey)) {
|
|
8290
|
+
groupKeys.push(groupKey);
|
|
8291
|
+
groupPanels[groupKey] = [panel];
|
|
8292
|
+
} else if (groupKey) {
|
|
8293
|
+
groupPanels[groupKey].push(panel);
|
|
8142
8294
|
}
|
|
8143
8295
|
});
|
|
8296
|
+
return groupPanels;
|
|
8297
|
+
};
|
|
8298
|
+
__proto._getSideStateFromGroup = function (groupPanels) {
|
|
8299
|
+
return Object.keys(groupPanels).reduce(function (state, key) {
|
|
8300
|
+
var start = state.length ? +state[state.length - 1].end + 1 : 0;
|
|
8301
|
+
var element = groupPanels[key].reduce(function (el, panel) {
|
|
8302
|
+
el.innerHTML += panel.outerHTML;
|
|
8303
|
+
return el;
|
|
8304
|
+
}, document.createElement("div"));
|
|
8305
|
+
return __spread(state, [{
|
|
8306
|
+
key: key,
|
|
8307
|
+
start: start,
|
|
8308
|
+
end: start + groupPanels[key].length - 1,
|
|
8309
|
+
element: element
|
|
8310
|
+
}]);
|
|
8311
|
+
}, []);
|
|
8312
|
+
};
|
|
8313
|
+
__proto._getSideStateFromPanels = function (panels) {
|
|
8314
|
+
return panels.reduce(function (state, panel, i) {
|
|
8315
|
+
var start = state.length ? +state[state.length - 1].end + 1 : 0;
|
|
8316
|
+
return __spread(state, [{
|
|
8317
|
+
key: i.toString(),
|
|
8318
|
+
start: start,
|
|
8319
|
+
end: start + panel.children.length - 1,
|
|
8320
|
+
element: panel
|
|
8321
|
+
}]);
|
|
8322
|
+
}, []);
|
|
8323
|
+
};
|
|
8324
|
+
__proto._getSideStateFromCrossStructure = function (panels) {
|
|
8325
|
+
var groupPanels = this._getGroupFromAttribute(panels);
|
|
8326
|
+
return this._getSideStateFromGroup(groupPanels);
|
|
8327
|
+
};
|
|
8328
|
+
__proto._createSideFlicking = function () {
|
|
8329
|
+
var _this = this;
|
|
8330
|
+
return this.sideState.map(function (state, i) {
|
|
8331
|
+
return new Flicking(_this.camera.children[i], __assign(__assign({}, _this.sideOptions), {
|
|
8332
|
+
horizontal: false,
|
|
8333
|
+
panelsPerView: 1,
|
|
8334
|
+
defaultIndex: state.start
|
|
8335
|
+
}));
|
|
8336
|
+
});
|
|
8144
8337
|
};
|
|
8145
8338
|
return CrossFlicking;
|
|
8146
8339
|
}(Flicking);
|
|
8147
8340
|
|
|
8148
8341
|
var CrossFlicking$1 = {
|
|
8149
8342
|
__proto__: null,
|
|
8343
|
+
SIDE_EVENTS: SIDE_EVENTS,
|
|
8150
8344
|
CrossFlicking: CrossFlicking
|
|
8151
8345
|
};
|
|
8152
8346
|
|