@egjs/flicking 4.12.0-beta.0 → 4.12.0-beta.1

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.
@@ -0,0 +1,29 @@
1
+ import Flicking, { FlickingOptions } from "./Flicking";
2
+ export interface CrossFlickingEvents {
3
+ }
4
+ export interface CrossFlickingOptions {
5
+ verticalOptions: FlickingOptions | undefined;
6
+ }
7
+ export interface VerticalState {
8
+ start: number;
9
+ end: number;
10
+ element: HTMLElement;
11
+ }
12
+ export declare class CrossFlicking extends Flicking {
13
+ private _verticalFlicking;
14
+ private _verticalOptions;
15
+ private _verticalState;
16
+ private _moveDirection;
17
+ private _nextIndex;
18
+ get verticalOptions(): FlickingOptions;
19
+ constructor(root: HTMLElement | string, { verticalOptions }?: Partial<CrossFlickingOptions>);
20
+ init(): Promise<void>;
21
+ private _syncToCategory;
22
+ private _onHorizontalHoldStart;
23
+ private _onHorizontalMove;
24
+ private _onHorizontalMoveEnd;
25
+ private _onVerticalHoldStart;
26
+ private _onVerticalMove;
27
+ private _onVerticalMoveEnd;
28
+ private _onVerticalChanged;
29
+ }
@@ -46,3 +46,7 @@ export declare const ORDER: {
46
46
  readonly LTR: "ltr";
47
47
  readonly RTL: "rtl";
48
48
  };
49
+ export declare const MOVE_DIRECTION: {
50
+ readonly HORIZONTAL: "horizontal";
51
+ readonly VERTICAL: "vertical";
52
+ };
@@ -1,5 +1,6 @@
1
1
  import Flicking from "./Flicking";
2
2
  import type { FlickingOptions, FlickingEvents } from "./Flicking";
3
+ export * from "./CrossFlicking";
3
4
  export * from "./core";
4
5
  export * from "./camera";
5
6
  export * from "./control";
@@ -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.0
7
+ version: 4.12.0-beta.1
8
8
  */
9
9
  'use strict';
10
10
 
@@ -413,6 +413,17 @@ var ORDER = {
413
413
  LTR: "ltr",
414
414
  RTL: "rtl"
415
415
  };
416
+ /**
417
+ * An object that contains the direction that {@link Flicking} is moving
418
+ * @ko {@link Flicking}이 움직이는 방향을 담고 있는 객체
419
+ * @type {object}
420
+ * @property {"horizontal"} HORIZONTAL horizontal<ko>수평 방향</ko>
421
+ * @property {"vertical"} VERTICAL vertical<ko>수직 방향</ko>
422
+ */
423
+ var MOVE_DIRECTION = {
424
+ HORIZONTAL: "horizontal",
425
+ VERTICAL: "vertical"
426
+ };
416
427
 
417
428
  // eslint-disable-next-line @typescript-eslint/ban-types
418
429
  var merge = function (target) {
@@ -7862,10 +7873,184 @@ var Flicking = /*#__PURE__*/function (_super) {
7862
7873
  * Flicking.VERSION; // ex) 4.0.0
7863
7874
  * ```
7864
7875
  */
7865
- Flicking.VERSION = "4.12.0-beta.0";
7876
+ Flicking.VERSION = "4.12.0-beta.1";
7866
7877
  return Flicking;
7867
7878
  }(Component);
7868
7879
 
7880
+ /*
7881
+ * Copyright (c) 2015 NAVER Corp.
7882
+ * egjs projects are licensed under the MIT license
7883
+ */
7884
+ /**
7885
+ * @extends Component
7886
+ * @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
7887
+ * @requires {@link https://github.com/naver/egjs-component|@egjs/component}
7888
+ * @requires {@link https://github.com/naver/egjs-axes|@egjs/axes}
7889
+ */
7890
+ var CrossFlicking = /*#__PURE__*/function (_super) {
7891
+ __extends(CrossFlicking, _super);
7892
+ // Options Setter
7893
+ // UI / LAYOUT
7894
+ // public set align(val: FlickingOptions["align"]) {
7895
+ // this._align = val;
7896
+ // }
7897
+ function CrossFlicking(root, _a) {
7898
+ var _b = (_a === void 0 ? {} : _a).verticalOptions,
7899
+ verticalOptions = _b === void 0 ? undefined : _b;
7900
+ var _this = _super.call(this, root) || this;
7901
+ _this._onHorizontalHoldStart = function () {
7902
+ _this.dragThreshold = 10;
7903
+ _this._moveDirection = null;
7904
+ };
7905
+ _this._onHorizontalMove = function (e) {
7906
+ if (e.isTrusted && !_this._moveDirection) {
7907
+ _this._verticalFlicking.forEach(function (child) {
7908
+ child.dragThreshold = Infinity;
7909
+ });
7910
+ _this._moveDirection = MOVE_DIRECTION.HORIZONTAL;
7911
+ }
7912
+ };
7913
+ _this._onHorizontalMoveEnd = function (e) {
7914
+ var visiblePanels = _this.visiblePanels;
7915
+ _this._verticalFlicking.forEach(function (child) {
7916
+ child.dragThreshold = 10;
7917
+ });
7918
+ _this._moveDirection = null;
7919
+ if (visiblePanels.length > 1) {
7920
+ _this._nextIndex = e.direction === "NEXT" ? visiblePanels[1].index : visiblePanels[0].index;
7921
+ } else {
7922
+ _this._nextIndex = visiblePanels[0].index;
7923
+ }
7924
+ _this._verticalFlicking.forEach(function (child, i) {
7925
+ if (_this._nextIndex !== i) {
7926
+ var _a = _this._verticalState[i],
7927
+ start = _a.start,
7928
+ end = _a.end;
7929
+ if (child.index < start) {
7930
+ child.stopAnimation();
7931
+ void child.moveTo(start, 0);
7932
+ } else if (child.index > end) {
7933
+ child.stopAnimation();
7934
+ void child.moveTo(end, 0);
7935
+ }
7936
+ }
7937
+ });
7938
+ if (e.isTrusted) {
7939
+ _this._syncToCategory(_this._verticalFlicking[_this._nextIndex].index, _this._nextIndex);
7940
+ }
7941
+ };
7942
+ _this._onVerticalHoldStart = function () {
7943
+ _this._verticalFlicking.forEach(function (child) {
7944
+ child.dragThreshold = 10;
7945
+ });
7946
+ _this._moveDirection = null;
7947
+ };
7948
+ _this._onVerticalMove = function (e) {
7949
+ if (e.isTrusted && !_this._moveDirection) {
7950
+ _this.dragThreshold = Infinity;
7951
+ _this._moveDirection = MOVE_DIRECTION.VERTICAL;
7952
+ }
7953
+ };
7954
+ _this._onVerticalMoveEnd = function () {
7955
+ _this.dragThreshold = 10;
7956
+ _this._moveDirection = null;
7957
+ };
7958
+ _this._onVerticalChanged = function (e) {
7959
+ // this.visiblePanels.length 가 2보다 크다면 가로 방향 Flicking이 조작 중이라는 것을 의미합니다.
7960
+ // 이 경우 가로 방향 Flicking의 이동이 완전히 끝난 뒤 _onHorizontalMoveEnd 에서 syncToCategory할 것이므로 여기서는 하지 않습니다.
7961
+ if (_this.visiblePanels.length < 2 && _this._verticalFlicking[_this.index] === e.currentTarget) {
7962
+ _this._syncToCategory(e.index, _this.index);
7963
+ }
7964
+ };
7965
+ // Internal states
7966
+ _this._verticalState = [];
7967
+ _this._moveDirection = null;
7968
+ _this._nextIndex = 0;
7969
+ // Bind options
7970
+ _this._verticalOptions = verticalOptions;
7971
+ return _this;
7972
+ // Create core components
7973
+ // this._viewport = new Viewport(this, getElement(root));
7974
+ }
7975
+ var __proto = CrossFlicking.prototype;
7976
+ Object.defineProperty(__proto, "verticalOptions", {
7977
+ // Components
7978
+ /**
7979
+ * Change active panel index on mouse/touch hold while animating.
7980
+ * `index` of the `willChange`/`willRestore` event will be used as new index.
7981
+ * @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
7982
+ * `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
7983
+ * @type {FlickingOptions}
7984
+ * @default undefined
7985
+ * @see {@link https://naver.github.io/egjs-flicking/Options#changeonhold changeOnHold ( Options )}
7986
+ */
7987
+ get: function () {
7988
+ return this._verticalOptions;
7989
+ },
7990
+ enumerable: false,
7991
+ configurable: true
7992
+ });
7993
+ /**
7994
+ * Initialize Flicking and move to the default index
7995
+ * This is automatically called on Flicking's constructor when `autoInit` is true(default)
7996
+ * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
7997
+ * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
7998
+ * @fires Flicking#ready
7999
+ * @return {Promise<void>}
8000
+ */
8001
+ __proto.init = function () {
8002
+ var _this = this;
8003
+ return _super.prototype.init.call(this).then(function () {
8004
+ // data-index로 분류하기 전에 임시로 모든 children에 대해 vertical flicking으로 해보자.
8005
+ // camera.children들에 대해 갯수 세기
8006
+ var verticalPanels = "";
8007
+ _this._verticalState = _this.camera.children.reduce(function (state, child) {
8008
+ var start = state.length ? +state[state.length - 1].end + 1 : 0;
8009
+ verticalPanels += child.children[0].innerHTML;
8010
+ return __spread(state, [{
8011
+ start: start,
8012
+ end: start + child.children[0].children.length - 1,
8013
+ element: child
8014
+ }]);
8015
+ }, []);
8016
+ _this.camera.children.forEach(function (child) {
8017
+ child.children[0].innerHTML = verticalPanels;
8018
+ });
8019
+ _this._verticalFlicking = _this.camera.children.map(function (child, i) {
8020
+ return new Flicking(child, __assign(__assign({}, _this.verticalOptions), {
8021
+ horizontal: false,
8022
+ panelsPerView: 1,
8023
+ defaultIndex: _this._verticalState[i].start
8024
+ }));
8025
+ });
8026
+ _this.on(EVENTS.HOLD_START, _this._onHorizontalHoldStart);
8027
+ _this.on(EVENTS.MOVE, _this._onHorizontalMove);
8028
+ _this.on(EVENTS.MOVE_END, _this._onHorizontalMoveEnd);
8029
+ _this._verticalFlicking.forEach(function (child) {
8030
+ child.on(EVENTS.HOLD_START, _this._onVerticalHoldStart);
8031
+ child.on(EVENTS.MOVE, _this._onVerticalMove);
8032
+ child.on(EVENTS.MOVE_END, _this._onVerticalMoveEnd);
8033
+ child.on(EVENTS.CHANGED, _this._onVerticalChanged);
8034
+ });
8035
+ });
8036
+ };
8037
+ __proto._syncToCategory = function (index, outerIndex) {
8038
+ var _this = this;
8039
+ this.stopAnimation();
8040
+ this._verticalFlicking.forEach(function (child, i) {
8041
+ var _a = _this._verticalState[i],
8042
+ start = _a.start,
8043
+ end = _a.end;
8044
+ if (start <= index && end >= index && outerIndex !== i) {
8045
+ child.stopAnimation();
8046
+ void child.moveTo(index, 0);
8047
+ void _this.moveTo(i, 0);
8048
+ }
8049
+ });
8050
+ };
8051
+ return CrossFlicking;
8052
+ }(Flicking);
8053
+
7869
8054
  /**
7870
8055
  * Decorator that makes the method of flicking available in the framework.
7871
8056
  * @ko 프레임워크에서 플리킹의 메소드를 사용할 수 있게 하는 데코레이터.
@@ -8083,6 +8268,7 @@ var parseAlign = function (alignVal) {
8083
8268
  var modules = {
8084
8269
  __proto__: null,
8085
8270
  'default': Flicking,
8271
+ CrossFlicking: CrossFlicking,
8086
8272
  VanillaElementProvider: VanillaElementProvider,
8087
8273
  VirtualElementProvider: VirtualElementProvider,
8088
8274
  Panel: Panel,
@@ -8120,6 +8306,7 @@ var modules = {
8120
8306
  CLASS: CLASS,
8121
8307
  CIRCULAR_FALLBACK: CIRCULAR_FALLBACK,
8122
8308
  ORDER: ORDER,
8309
+ MOVE_DIRECTION: MOVE_DIRECTION,
8123
8310
  withFlickingMethods: withFlickingMethods,
8124
8311
  sync: sync,
8125
8312
  getRenderingPanels: getRenderingPanels,
@@ -8174,6 +8361,7 @@ exports.CLASS = CLASS;
8174
8361
  exports.Camera = Camera;
8175
8362
  exports.CircularCameraMode = CircularCameraMode;
8176
8363
  exports.Control = Control;
8364
+ exports.CrossFlicking = CrossFlicking;
8177
8365
  exports.DIRECTION = DIRECTION;
8178
8366
  exports.DisabledState = DisabledState;
8179
8367
  exports.DraggingState = DraggingState;
@@ -8185,6 +8373,7 @@ exports.FreeControl = FreeControl;
8185
8373
  exports.HoldingState = HoldingState;
8186
8374
  exports.IdleState = IdleState;
8187
8375
  exports.LinearCameraMode = LinearCameraMode;
8376
+ exports.MOVE_DIRECTION = MOVE_DIRECTION;
8188
8377
  exports.MOVE_TYPE = MOVE_TYPE;
8189
8378
  exports.NormalRenderingStrategy = NormalRenderingStrategy;
8190
8379
  exports.ORDER = ORDER;