@egjs/flicking 4.12.0-beta.2 → 4.12.0-beta.4

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.
Files changed (77) hide show
  1. package/declaration/Flicking.d.ts +244 -244
  2. package/declaration/camera/Camera.d.ts +90 -89
  3. package/declaration/camera/index.d.ts +4 -4
  4. package/declaration/camera/mode/BoundCameraMode.d.ts +13 -13
  5. package/declaration/camera/mode/CameraMode.d.ts +20 -20
  6. package/declaration/camera/mode/CircularCameraMode.d.ts +19 -19
  7. package/declaration/camera/mode/LinearCameraMode.d.ts +9 -9
  8. package/declaration/camera/mode/index.d.ts +6 -6
  9. package/declaration/cfc/getDefaultCameraTransform.d.ts +3 -3
  10. package/declaration/cfc/getRenderingPanels.d.ts +4 -4
  11. package/declaration/cfc/index.d.ts +5 -5
  12. package/declaration/cfc/sync.d.ts +4 -4
  13. package/declaration/cfc/withFlickingMethods.d.ts +2 -2
  14. package/declaration/const/axes.d.ts +8 -8
  15. package/declaration/const/error.d.ts +34 -34
  16. package/declaration/const/external.d.ts +48 -54
  17. package/declaration/control/AxesController.d.ts +44 -44
  18. package/declaration/control/Control.d.ts +45 -45
  19. package/declaration/control/FreeControl.d.ts +14 -14
  20. package/declaration/control/SnapControl.d.ts +16 -16
  21. package/declaration/control/StateMachine.d.ts +14 -14
  22. package/declaration/control/StrictControl.d.ts +20 -20
  23. package/declaration/control/index.d.ts +14 -14
  24. package/declaration/control/states/AnimatingState.d.ts +9 -9
  25. package/declaration/control/states/DisabledState.d.ts +9 -9
  26. package/declaration/control/states/DraggingState.d.ts +8 -8
  27. package/declaration/control/states/HoldingState.d.ts +10 -10
  28. package/declaration/control/states/IdleState.d.ts +9 -9
  29. package/declaration/control/states/State.d.ts +47 -47
  30. package/declaration/core/AnchorPoint.d.ts +15 -15
  31. package/declaration/core/AutoResizer.d.ts +16 -16
  32. package/declaration/core/FlickingError.d.ts +5 -5
  33. package/declaration/core/ResizeWatcher.d.ts +33 -33
  34. package/declaration/core/Viewport.d.ts +25 -25
  35. package/declaration/core/VirtualManager.d.ts +37 -37
  36. package/declaration/core/index.d.ts +6 -6
  37. package/declaration/core/panel/Panel.d.ts +89 -89
  38. package/declaration/core/panel/VirtualPanel.d.ts +19 -19
  39. package/declaration/core/panel/index.d.ts +5 -5
  40. package/declaration/core/panel/provider/ElementProvider.d.ts +8 -8
  41. package/declaration/core/panel/provider/VanillaElementProvider.d.ts +12 -12
  42. package/declaration/core/panel/provider/VirtualElementProvider.d.ts +15 -15
  43. package/declaration/core/panel/provider/index.d.ts +5 -5
  44. package/declaration/index.cjs.d.ts +3 -3
  45. package/declaration/index.d.ts +13 -14
  46. package/declaration/index.umd.d.ts +2 -2
  47. package/declaration/renderer/ExternalRenderer.d.ts +7 -7
  48. package/declaration/renderer/Renderer.d.ts +59 -59
  49. package/declaration/renderer/VanillaRenderer.d.ts +10 -10
  50. package/declaration/renderer/index.d.ts +6 -6
  51. package/declaration/renderer/strategy/NormalRenderingStrategy.d.ts +23 -23
  52. package/declaration/renderer/strategy/RenderingStrategy.d.ts +15 -15
  53. package/declaration/renderer/strategy/VirtualRenderingStrategy.d.ts +17 -17
  54. package/declaration/renderer/strategy/index.d.ts +5 -5
  55. package/declaration/type/event.d.ts +88 -88
  56. package/declaration/type/external.d.ts +31 -31
  57. package/declaration/type/internal.d.ts +13 -13
  58. package/declaration/utils.d.ts +45 -45
  59. package/dist/flicking.cjs.js +14 -254
  60. package/dist/flicking.cjs.js.map +1 -1
  61. package/dist/flicking.esm.js +15 -251
  62. package/dist/flicking.esm.js.map +1 -1
  63. package/dist/flicking.js +14 -257
  64. package/dist/flicking.js.map +1 -1
  65. package/dist/flicking.min.js +2 -2
  66. package/dist/flicking.min.js.map +1 -1
  67. package/dist/flicking.pkgd.js +772 -1022
  68. package/dist/flicking.pkgd.js.map +1 -1
  69. package/dist/flicking.pkgd.min.js +2 -2
  70. package/dist/flicking.pkgd.min.js.map +1 -1
  71. package/package.json +2 -2
  72. package/src/camera/Camera.ts +9 -0
  73. package/src/const/external.ts +0 -14
  74. package/src/index.ts +0 -2
  75. package/src/index.umd.ts +0 -2
  76. package/declaration/CrossFlicking.d.ts +0 -34
  77. package/src/CrossFlicking.ts +0 -296
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egjs/flicking",
3
- "version": "4.12.0-beta.2",
3
+ "version": "4.12.0-beta.4",
4
4
  "description": "Everyday 30 million people experience. It's reliable, flexible and extendable carousel.",
5
5
  "main": "dist/flicking.cjs.js",
6
6
  "module": "dist/flicking.esm.js",
@@ -139,7 +139,7 @@
139
139
  "typescript-transform-paths": "^2.2.3"
140
140
  },
141
141
  "dependencies": {
142
- "@egjs/axes": "^3.9.0",
142
+ "@egjs/axes": "^3.9.1",
143
143
  "@egjs/component": "^3.0.1",
144
144
  "@egjs/imready": "^1.3.1",
145
145
  "@egjs/list-differ": "^1.0.1"
@@ -32,6 +32,7 @@ class Camera {
32
32
  private _mode: CameraMode;
33
33
  private _el: HTMLElement;
34
34
  private _transform: string;
35
+ private _lookedOffset = 0;
35
36
  private _position: number;
36
37
  private _alignPos: number;
37
38
  private _offset: number;
@@ -292,6 +293,8 @@ class Camera {
292
293
  * @return {this}
293
294
  */
294
295
  public lookAt(pos: number): void {
296
+ const prevOffset = this._offset;
297
+ const isChangedOffset = this._lookedOffset !== prevOffset;
295
298
  const flicking = getFlickingAttached(this._flicking);
296
299
  const prevPos = this._position;
297
300
 
@@ -304,7 +307,12 @@ class Camera {
304
307
  if (toggled) {
305
308
  void flicking.renderer.render().then(() => {
306
309
  this.updateOffset();
310
+ this._lookedOffset = this._offset;
307
311
  });
312
+ } else if (isChangedOffset) {
313
+ // sync offset for renderOnlyVisible on resize
314
+ this.updateOffset();
315
+ this._lookedOffset = this._offset;
308
316
  } else {
309
317
  this.applyTransform();
310
318
  }
@@ -599,6 +607,7 @@ class Camera {
599
607
 
600
608
  private _resetInternalValues() {
601
609
  this._position = 0;
610
+ this._lookedOffset = 0;
602
611
  this._alignPos = 0;
603
612
  this._offset = 0;
604
613
  this._circularOffset = 0;
@@ -94,8 +94,6 @@ export const MOVE_TYPE = {
94
94
  } as const;
95
95
 
96
96
  export const CLASS = {
97
- VIEWPORT: "flicking-viewport",
98
- CAMERA: "flicking-camera",
99
97
  VERTICAL: "vertical",
100
98
  HIDDEN: "flicking-hidden",
101
99
  DEFAULT_VIRTUAL: "flicking-panel"
@@ -124,15 +122,3 @@ export const ORDER = {
124
122
  LTR: "ltr",
125
123
  RTL: "rtl"
126
124
  } as const;
127
-
128
- /**
129
- * An object that contains the direction that {@link Flicking} is moving
130
- * @ko {@link Flicking}이 움직이는 방향을 담고 있는 객체
131
- * @type {object}
132
- * @property {"horizontal"} HORIZONTAL horizontal<ko>수평 방향</ko>
133
- * @property {"vertical"} VERTICAL vertical<ko>수직 방향</ko>
134
- */
135
- export const MOVE_DIRECTION = {
136
- HORIZONTAL: "horizontal",
137
- VERTICAL: "vertical"
138
- } as const;
package/src/index.ts CHANGED
@@ -5,8 +5,6 @@
5
5
  import Flicking from "./Flicking";
6
6
  import type { FlickingOptions, FlickingEvents } from "./Flicking";
7
7
 
8
- export * from "./CrossFlicking";
9
-
10
8
  export * from "./core";
11
9
  export * from "./camera";
12
10
  export * from "./control";
package/src/index.umd.ts CHANGED
@@ -3,7 +3,6 @@
3
3
  * egjs projects are licensed under the MIT license
4
4
  */
5
5
  import Flicking from "./Flicking";
6
- import * as CrossFlicking from "./CrossFlicking";
7
6
  import * as Core from "./core";
8
7
  import * as Camera from "./camera";
9
8
  import * as Control from "./control";
@@ -20,6 +19,5 @@ merge(Flicking, Renderer);
20
19
  merge(Flicking, Constants);
21
20
  merge(Flicking, CFC);
22
21
  merge(Flicking, Utils);
23
- merge(Flicking, CrossFlicking);
24
22
 
25
23
  export default Flicking;
@@ -1,34 +0,0 @@
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 verticalFlicking(): Flicking[];
19
- get verticalState(): VerticalState[];
20
- get verticalOptions(): FlickingOptions;
21
- constructor(root: HTMLElement | string, { verticalOptions }?: Partial<CrossFlickingOptions>);
22
- init(): Promise<void>;
23
- private _addComponentEvents;
24
- private _createVerticalState;
25
- private _createVerticalFlicking;
26
- private _syncToCategory;
27
- private _onHorizontalHoldStart;
28
- private _onHorizontalMove;
29
- private _onHorizontalMoveEnd;
30
- private _onVerticalHoldStart;
31
- private _onVerticalMove;
32
- private _onVerticalMoveEnd;
33
- private _onVerticalChanged;
34
- }
@@ -1,296 +0,0 @@
1
- /*
2
- * Copyright (c) 2015 NAVER Corp.
3
- * egjs projects are licensed under the MIT license
4
- */
5
-
6
- import Flicking, { FlickingOptions } from "./Flicking";
7
- import { ChangedEvent, MoveEndEvent, MoveEvent } from "./type/event";
8
- import { LiteralUnion, ValueOf } from "./type/internal";
9
- import { CLASS, EVENTS, MOVE_DIRECTION } from "./const/external";
10
- import { getElement, toArray } from "./utils";
11
-
12
- /**
13
- * @interface
14
- */
15
- export interface CrossFlickingEvents {
16
- // FlickingEvent 들을 확장하자...
17
- }
18
-
19
- /**
20
- * @interface
21
- */
22
- export interface CrossFlickingOptions {
23
- verticalOptions: FlickingOptions | undefined;
24
- // 한쪽 움직이면 다른 한쪽 움직임을 막을지 여부
25
- // 이전 패널 기억 여부
26
- }
27
-
28
- /**
29
- * Flicking Status returned by {@link Flicking#getStatus}
30
- * @ko {@link Flicking#getStatus}에 의해 반환된 Flicking 상태 객체
31
- * @interface
32
- * @property {number} index An index of the active panel<ko>활성화된 패널의 인덱스</ko>
33
- * @property {object} position A info to restore camera {@link Camera#position position}<ko>카메라 {@link Camera#position position}을 설정하기 위한 정보들</ko>
34
- * @property {number} [position.panel] An index of the panel camera is located at<ko>카메라가 위치한 패널의 인덱스</ko>
35
- * @property {number} [position.progressInPanel] A progress of the camera position inside the panel<ko>패널 내에서의 카메라 위치의 진행도</ko>
36
- * @property {number} visibleOffset An offset to visible panel's original index. This value is available only when `visiblePanelsOnly` is `true`
37
- * <ko>현재 보이는 패널들을 저장했을 때, 원래의 인덱스 대비 offset. `visiblePanelsOnly` 옵션을 사용했을 때만 사용 가능합니다</ko>
38
- * @property {object[]} panels A data array of panels<ko>패널의 정보를 담은 배열</ko>
39
- * @property {index} [panels.index] An index of the panel<ko>패널의 인덱스</ko>
40
- * @property {string | undefined} [panels.html] An `outerHTML` of the panel element<ko>패널 엘리먼트의 `outerHTML`</ko>
41
- */
42
- export interface VerticalState {
43
- start: number;
44
- end: number;
45
- element: HTMLElement;
46
- }
47
-
48
- /**
49
- * @extends Component
50
- * @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
51
- * @requires {@link https://github.com/naver/egjs-component|@egjs/component}
52
- * @requires {@link https://github.com/naver/egjs-axes|@egjs/axes}
53
- */
54
- export class CrossFlicking extends Flicking {
55
- // Core components
56
- private _verticalFlicking: Flicking[];
57
-
58
- // Options
59
- private _verticalOptions: CrossFlickingOptions["verticalOptions"];
60
-
61
- // Internal State
62
- private _verticalState: VerticalState[];
63
- private _moveDirection: LiteralUnion<ValueOf<typeof MOVE_DIRECTION>> | null;
64
- private _nextIndex: number;
65
-
66
- // Components
67
- /**
68
- * {@link Control} instance of the Flicking
69
- * @ko 현재 Flicking에 활성화된 {@link Control} 인스턴스
70
- * @type {Control}
71
- * @default SnapControl
72
- * @readonly
73
- * @see Control
74
- * @see SnapControl
75
- * @see FreeControl
76
- */
77
- public get verticalFlicking() { return this._verticalFlicking; }
78
- // Internal States
79
- /**
80
- * Whether Flicking's {@link Flicking#init init()} is called.
81
- * This is `true` when {@link Flicking#init init()} is called, and is `false` after calling {@link Flicking#destroy destroy()}.
82
- * @ko Flicking의 {@link Flicking#init init()}이 호출되었는지를 나타내는 멤버 변수.
83
- * 이 값은 {@link Flicking#init init()}이 호출되었으면 `true`로 변하고, {@link Flicking#destroy destroy()}호출 이후에 다시 `false`로 변경됩니다.
84
- * @type {boolean}
85
- * @default false
86
- * @readonly
87
- */
88
- public get verticalState() { return this._verticalState; }
89
- // Options Getter
90
- /**
91
- * Change active panel index on mouse/touch hold while animating.
92
- * `index` of the `willChange`/`willRestore` event will be used as new index.
93
- * @ko 애니메이션 도중 마우스/터치 입력시 현재 활성화된 패널의 인덱스를 변경합니다.
94
- * `willChange`/`willRestore` 이벤트의 `index`값이 새로운 인덱스로 사용될 것입니다.
95
- * @type {FlickingOptions}
96
- * @default undefined
97
- * @see {@link https://naver.github.io/egjs-flicking/Options#changeonhold changeOnHold ( Options )}
98
- */
99
- public get verticalOptions() {
100
- return this._verticalOptions;
101
- }
102
-
103
- // Options Setter
104
- // public set align(val: FlickingOptions["align"]) {
105
- // this._align = val;
106
- // }
107
-
108
- public constructor(
109
- root: HTMLElement | string,
110
- { verticalOptions = undefined }: Partial<CrossFlickingOptions> = {}
111
- ) {
112
- super(root);
113
-
114
- const horizontalPanels = toArray(getElement(root).children[0].children) as HTMLElement[];
115
-
116
- // Internal states
117
- this._verticalState = this._createVerticalState(horizontalPanels);
118
- this._moveDirection = null;
119
- this._nextIndex = 0;
120
-
121
- // Bind options
122
- this._verticalOptions = verticalOptions;
123
-
124
- // Create core components
125
- this._verticalFlicking = this._createVerticalFlicking(horizontalPanels);
126
- }
127
-
128
- /**
129
- * Initialize Flicking and move to the default index
130
- * This is automatically called on Flicking's constructor when `autoInit` is true(default)
131
- * @ko Flicking을 초기화하고, 디폴트 인덱스로 이동합니다
132
- * 이 메소드는 `autoInit` 옵션이 true(default)일 경우 Flicking이 생성될 때 자동으로 호출됩니다
133
- * @fires Flicking#ready
134
- * @return {Promise<void>}
135
- */
136
- public init(): Promise<void> {
137
- return super.init().then(() => this._addComponentEvents());
138
- }
139
-
140
- private _addComponentEvents(): void {
141
- this.on(EVENTS.HOLD_START, this._onHorizontalHoldStart);
142
- this.on(EVENTS.MOVE, this._onHorizontalMove);
143
- this.on(EVENTS.MOVE_END, this._onHorizontalMoveEnd);
144
-
145
- this._verticalFlicking.forEach((flicking) => {
146
- flicking.on(EVENTS.HOLD_START, this._onVerticalHoldStart);
147
- flicking.on(EVENTS.MOVE, this._onVerticalMove);
148
- flicking.on(EVENTS.MOVE_END, this._onVerticalMoveEnd);
149
- flicking.on(EVENTS.CHANGED, this._onVerticalChanged);
150
- });
151
- }
152
-
153
- private _createVerticalState(panels: HTMLElement[]): VerticalState[] {
154
- // data-index로 분류하기 전에 임시로 모든 children에 대해 vertical flicking으로 해보자.
155
- // panels에 data-attributes가 붙어있을 때와 안 붙어있을 때를 다르게 처리
156
- // 붙어있다면 가상의 viewport들을 index 갯수만큼 만들어줘야 한다
157
- let verticalPanels = "";
158
-
159
- const verticalState = panels.reduce(
160
- (state: VerticalState[], panel: HTMLElement) => {
161
- const start = state.length ? +state[state.length - 1].end + 1 : 0;
162
- verticalPanels += panel.innerHTML;
163
- return [
164
- ...state,
165
- {
166
- start,
167
- end: start + panel.children.length - 1,
168
- element: panel
169
- }
170
- ];
171
- },
172
- []
173
- );
174
-
175
- const verticalCamera = document.createElement("div");
176
- verticalCamera.classList.add(CLASS.CAMERA);
177
- verticalCamera.innerHTML = verticalPanels;
178
- panels.forEach((panel) => {
179
- [CLASS.VIEWPORT, CLASS.VERTICAL].forEach((className) => {
180
- if (!panel.classList.contains(className)) {
181
- panel.classList.add(className);
182
- }
183
- });
184
- panel.innerHTML = verticalCamera.outerHTML;
185
- });
186
-
187
- return verticalState;
188
- }
189
-
190
- private _createVerticalFlicking(panels: HTMLElement[]): Flicking[] {
191
- return panels.map((panel, i) => {
192
- return new Flicking(panel, {
193
- ...this.verticalOptions,
194
- horizontal: false,
195
- panelsPerView: 1,
196
- defaultIndex: this._verticalState[i].start
197
- });
198
- });
199
- }
200
-
201
- private _syncToCategory(index: number, outerIndex: number): void {
202
- this.stopAnimation();
203
- this._verticalFlicking.forEach((child, i) => {
204
- const { start, end } = this._verticalState[i];
205
-
206
- if (start <= index && end >= index && outerIndex !== i) {
207
- child.stopAnimation();
208
- void child.moveTo(index, 0);
209
- void this.moveTo(i, 0);
210
- }
211
- });
212
- }
213
-
214
- private _onHorizontalHoldStart = (): void => {
215
- this.dragThreshold = 10;
216
- this._moveDirection = null;
217
- };
218
-
219
- private _onHorizontalMove = (e: MoveEvent): void => {
220
- if (e.isTrusted && !this._moveDirection) {
221
- this._verticalFlicking.forEach((child) => {
222
- child.dragThreshold = Infinity;
223
- });
224
- this._moveDirection = MOVE_DIRECTION.HORIZONTAL;
225
- }
226
- };
227
-
228
- private _onHorizontalMoveEnd = (e: MoveEndEvent): void => {
229
- const visiblePanels = this.visiblePanels;
230
-
231
- this._verticalFlicking.forEach((child) => {
232
- child.dragThreshold = 10;
233
- });
234
- this._moveDirection = null;
235
-
236
- if (visiblePanels.length > 1) {
237
- this._nextIndex =
238
- e.direction === "NEXT"
239
- ? visiblePanels[1].index
240
- : visiblePanels[0].index;
241
- } else {
242
- this._nextIndex = visiblePanels[0].index;
243
- }
244
-
245
- this._verticalFlicking.forEach((child, i) => {
246
- if (this._nextIndex !== i) {
247
- const { start, end } = this._verticalState[i];
248
-
249
- if (child.index < start) {
250
- child.stopAnimation();
251
- void child.moveTo(start, 0);
252
- } else if (child.index > end) {
253
- child.stopAnimation();
254
- void child.moveTo(end, 0);
255
- }
256
- }
257
- });
258
-
259
- if (e.isTrusted) {
260
- this._syncToCategory(
261
- this._verticalFlicking[this._nextIndex].index,
262
- this._nextIndex
263
- );
264
- }
265
- };
266
-
267
- private _onVerticalHoldStart = (): void => {
268
- this._verticalFlicking.forEach((child) => {
269
- child.dragThreshold = 10;
270
- });
271
- this._moveDirection = null;
272
- };
273
-
274
- private _onVerticalMove = (e: MoveEvent): void => {
275
- if (e.isTrusted && !this._moveDirection) {
276
- this.dragThreshold = Infinity;
277
- this._moveDirection = MOVE_DIRECTION.VERTICAL;
278
- }
279
- };
280
-
281
- private _onVerticalMoveEnd = (): void => {
282
- this.dragThreshold = 10;
283
- this._moveDirection = null;
284
- };
285
-
286
- private _onVerticalChanged = (e: ChangedEvent): void => {
287
- // this.visiblePanels.length 가 2보다 크다면 가로 방향 Flicking이 조작 중이라는 것을 의미합니다.
288
- // 이 경우 가로 방향 Flicking의 이동이 완전히 끝난 뒤 _onHorizontalMoveEnd 에서 syncToCategory할 것이므로 여기서는 하지 않습니다.
289
- if (
290
- this.visiblePanels.length < 2 &&
291
- this._verticalFlicking[this.index] === e.currentTarget
292
- ) {
293
- this._syncToCategory(e.index, this.index);
294
- }
295
- };
296
- }