@egjs/flicking 4.12.0-beta.9 → 4.12.1-beta.0

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 (84) hide show
  1. package/declaration/CrossFlicking.d.ts +89 -76
  2. package/declaration/Flicking.d.ts +244 -244
  3. package/declaration/camera/Camera.d.ts +90 -90
  4. package/declaration/camera/index.d.ts +4 -4
  5. package/declaration/camera/mode/BoundCameraMode.d.ts +13 -13
  6. package/declaration/camera/mode/CameraMode.d.ts +20 -20
  7. package/declaration/camera/mode/CircularCameraMode.d.ts +19 -19
  8. package/declaration/camera/mode/LinearCameraMode.d.ts +9 -9
  9. package/declaration/camera/mode/index.d.ts +6 -6
  10. package/declaration/cfc/getDefaultCameraTransform.d.ts +3 -3
  11. package/declaration/cfc/getRenderingPanels.d.ts +4 -4
  12. package/declaration/cfc/index.d.ts +5 -5
  13. package/declaration/cfc/sync.d.ts +4 -4
  14. package/declaration/cfc/withFlickingMethods.d.ts +2 -2
  15. package/declaration/const/axes.d.ts +8 -8
  16. package/declaration/const/error.d.ts +34 -34
  17. package/declaration/const/external.d.ts +54 -54
  18. package/declaration/control/AxesController.d.ts +44 -44
  19. package/declaration/control/Control.d.ts +45 -45
  20. package/declaration/control/FreeControl.d.ts +14 -14
  21. package/declaration/control/SnapControl.d.ts +16 -16
  22. package/declaration/control/StateMachine.d.ts +14 -14
  23. package/declaration/control/StrictControl.d.ts +20 -20
  24. package/declaration/control/index.d.ts +14 -14
  25. package/declaration/control/states/AnimatingState.d.ts +9 -9
  26. package/declaration/control/states/DisabledState.d.ts +9 -9
  27. package/declaration/control/states/DraggingState.d.ts +8 -8
  28. package/declaration/control/states/HoldingState.d.ts +10 -10
  29. package/declaration/control/states/IdleState.d.ts +9 -9
  30. package/declaration/control/states/State.d.ts +47 -47
  31. package/declaration/core/AnchorPoint.d.ts +15 -15
  32. package/declaration/core/AutoResizer.d.ts +16 -16
  33. package/declaration/core/FlickingError.d.ts +5 -5
  34. package/declaration/core/ResizeWatcher.d.ts +33 -33
  35. package/declaration/core/Viewport.d.ts +25 -25
  36. package/declaration/core/VirtualManager.d.ts +37 -37
  37. package/declaration/core/index.d.ts +6 -6
  38. package/declaration/core/panel/Panel.d.ts +89 -89
  39. package/declaration/core/panel/VirtualPanel.d.ts +19 -19
  40. package/declaration/core/panel/index.d.ts +5 -5
  41. package/declaration/core/panel/provider/ElementProvider.d.ts +8 -8
  42. package/declaration/core/panel/provider/VanillaElementProvider.d.ts +12 -12
  43. package/declaration/core/panel/provider/VirtualElementProvider.d.ts +15 -15
  44. package/declaration/core/panel/provider/index.d.ts +5 -5
  45. package/declaration/index.cjs.d.ts +3 -3
  46. package/declaration/index.d.ts +15 -15
  47. package/declaration/index.umd.d.ts +2 -2
  48. package/declaration/renderer/ExternalRenderer.d.ts +7 -7
  49. package/declaration/renderer/Renderer.d.ts +59 -59
  50. package/declaration/renderer/VanillaRenderer.d.ts +10 -10
  51. package/declaration/renderer/index.d.ts +6 -6
  52. package/declaration/renderer/strategy/NormalRenderingStrategy.d.ts +23 -23
  53. package/declaration/renderer/strategy/RenderingStrategy.d.ts +15 -15
  54. package/declaration/renderer/strategy/VirtualRenderingStrategy.d.ts +17 -17
  55. package/declaration/renderer/strategy/index.d.ts +5 -5
  56. package/declaration/type/event.d.ts +88 -88
  57. package/declaration/type/external.d.ts +31 -31
  58. package/declaration/type/internal.d.ts +13 -13
  59. package/declaration/utils.d.ts +47 -47
  60. package/dist/flicking-inline.css +37 -0
  61. package/dist/flicking-inline.min.css +1 -0
  62. package/dist/flicking-inline.min.min.css +1 -0
  63. package/dist/flicking.cjs.js +36 -6
  64. package/dist/flicking.cjs.js.map +1 -1
  65. package/dist/flicking.css +40 -0
  66. package/dist/flicking.esm.js +36 -6
  67. package/dist/flicking.esm.js.map +1 -1
  68. package/dist/flicking.js +36 -6
  69. package/dist/flicking.js.map +1 -1
  70. package/dist/flicking.min.css +1 -0
  71. package/dist/flicking.min.js +2 -2
  72. package/dist/flicking.min.js.map +1 -1
  73. package/dist/flicking.min.min.css +1 -0
  74. package/dist/flicking.pkgd.js +786 -756
  75. package/dist/flicking.pkgd.js.map +1 -1
  76. package/dist/flicking.pkgd.min.js +2 -2
  77. package/dist/flicking.pkgd.min.js.map +1 -1
  78. package/package.json +5 -6
  79. package/src/CrossFlicking.ts +32 -4
  80. package/src/Flicking.ts +1 -1
  81. package/src/control/SnapControl.ts +3 -1
  82. package/src/control/states/HoldingState.ts +4 -0
  83. package/src/core/panel/Panel.ts +4 -0
  84. package/src/utils.ts +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egjs/flicking",
3
- "version": "4.12.0-beta.9",
3
+ "version": "4.12.1-beta.0",
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",
@@ -12,13 +12,12 @@
12
12
  "types": "declaration/index.d.ts",
13
13
  "scripts": {
14
14
  "start": "concurrently \"rollup -w --config ./rollup.config.dev.js\" \"http-serve\"",
15
- "build": "run-s build:bundle build:declaration printsizes",
16
- "build-react": "run-s build:bundle build:declaration && pvu --build=react-flicking",
15
+ "build": "run-s build:bundle build:declaration build:css printsizes",
17
16
  "build:bundle": "rm -rf ./dist && rollup -c",
18
17
  "build:declaration": "rm -rf ./declaration && tsc -p tsconfig.declaration.json",
19
18
  "build:css": "run-s build:css-clear build:sass build:css-prefix build:css-min",
20
19
  "build:css-clear": "rm -rf ./dist/*.css",
21
- "build:sass": "node-sass sass/ -o dist/ -x --output-style expanded",
20
+ "build:sass": "sass sass/:dist/ --style=expanded --no-source-map && sass sass/flicking.sass dist/flicking.min.css --style=compressed --no-source-map && sass sass/flicking-inline.sass dist/flicking-inline.min.css --style=compressed --no-source-map",
22
21
  "build:css-prefix": "postcss dist/*.css --replace --use autoprefixer --no-map",
23
22
  "build:css-min": "postcss dist/*.css --ext .min.css --use postcss-clean -d dist/ --no-map",
24
23
  "declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json",
@@ -115,7 +114,6 @@
115
114
  "husky": "^1.3.1",
116
115
  "jsdoc-to-mdx": "^1.1.2",
117
116
  "karma-typescript-es6-transform": "^5.5.2",
118
- "node-sass": "^7.0.1",
119
117
  "npm-run-all": "^4.1.5",
120
118
  "postcss-clean": "^1.2.2",
121
119
  "postcss-cli": "^7.1.2",
@@ -130,6 +128,7 @@
130
128
  "rollup-plugin-terser": "^7.0.2",
131
129
  "rollup-plugin-typescript2": "^0.36.0",
132
130
  "rollup-plugin-visualizer": "^4.2.1",
131
+ "sass": "^1.79.3",
133
132
  "sync-exec": "^0.6.2",
134
133
  "ts-mock-imports": "^1.3.3",
135
134
  "tsconfig-paths-webpack-plugin": "^3.5.1",
@@ -140,7 +139,7 @@
140
139
  "typescript-transform-paths": "^2.2.3"
141
140
  },
142
141
  "dependencies": {
143
- "@egjs/axes": "^3.9.0",
142
+ "@egjs/axes": "^3.9.1",
144
143
  "@egjs/component": "^3.0.1",
145
144
  "@egjs/imready": "^1.3.1",
146
145
  "@egjs/list-differ": "^1.0.1"
@@ -13,7 +13,9 @@ import {
13
13
  MoveEndEvent,
14
14
  MoveEvent,
15
15
  MoveStartEvent,
16
- WillChangeEvent
16
+ RestoredEvent,
17
+ WillChangeEvent,
18
+ WillRestoreEvent
17
19
  } from "./type/event";
18
20
  import { LiteralUnion, ValueOf } from "./type/internal";
19
21
  import { CLASS, EVENTS, MOVE_DIRECTION } from "./const/external";
@@ -26,7 +28,9 @@ export const SIDE_EVENTS = {
26
28
  MOVE: "sideMove",
27
29
  MOVE_END: "sideMoveEnd",
28
30
  WILL_CHANGE: "sideWillChange",
29
- CHANGED: "sideChanged"
31
+ CHANGED: "sideChanged",
32
+ WILL_RESTORE: "sideWillRestore",
33
+ RESTORED: "sideRestored"
30
34
  } as const;
31
35
 
32
36
  export type CrossFlickingEvent<T> = { mainIndex: number } & T;
@@ -39,6 +43,8 @@ export interface CrossFlickingEvents extends FlickingEvents {
39
43
  [SIDE_EVENTS.MOVE_END]: CrossFlickingEvent<MoveEndEvent>;
40
44
  [SIDE_EVENTS.WILL_CHANGE]: CrossFlickingEvent<WillChangeEvent>;
41
45
  [SIDE_EVENTS.CHANGED]: CrossFlickingEvent<ChangedEvent>;
46
+ [SIDE_EVENTS.WILL_RESTORE]: CrossFlickingEvent<WillRestoreEvent>;
47
+ [SIDE_EVENTS.RESTORED]: CrossFlickingEvent<RestoredEvent>;
42
48
  }
43
49
 
44
50
  export interface CrossFlickingOptions extends FlickingOptions {
@@ -55,6 +61,14 @@ export interface SideState {
55
61
  element: HTMLElement;
56
62
  }
57
63
 
64
+ export interface CrossFlickingChangedEvent extends ChangedEvent {
65
+ sideIndex?: number;
66
+ }
67
+
68
+ export interface CrossFlickingWillChangeEvent extends WillChangeEvent {
69
+ sideIndex?: number;
70
+ }
71
+
58
72
  export class CrossFlicking extends Flicking {
59
73
  // Core components
60
74
  private _sideFlicking: Flicking[];
@@ -68,6 +82,7 @@ export class CrossFlicking extends Flicking {
68
82
  // Internal State
69
83
  private _sideState: SideState[];
70
84
  private _moveDirection: LiteralUnion<ValueOf<typeof MOVE_DIRECTION>> | null;
85
+ private _originalDragThreshold: number;
71
86
  private _nextIndex: number;
72
87
 
73
88
  // Components
@@ -75,6 +90,10 @@ export class CrossFlicking extends Flicking {
75
90
  return this._sideFlicking;
76
91
  }
77
92
 
93
+ public get sideIndex() {
94
+ return this._sideFlicking.map(i => i.index);
95
+ }
96
+
78
97
  public get sideState() {
79
98
  return this._sideState;
80
99
  }
@@ -120,6 +139,7 @@ export class CrossFlicking extends Flicking {
120
139
  // Internal states
121
140
  this._moveDirection = null;
122
141
  this._nextIndex = 0;
142
+ this._originalDragThreshold = this.dragThreshold;
123
143
 
124
144
  // Bind options
125
145
  this._sideOptions = sideOptions;
@@ -147,6 +167,9 @@ export class CrossFlicking extends Flicking {
147
167
  this.on(EVENTS.HOLD_START, this._onHorizontalHoldStart);
148
168
  this.on(EVENTS.MOVE, this._onHorizontalMove);
149
169
  this.on(EVENTS.MOVE_END, this._onHorizontalMoveEnd);
170
+ [EVENTS.CHANGED, EVENTS.WILL_CHANGE].forEach((event) => {
171
+ this.on(event, this._addSideIndex);
172
+ });
150
173
 
151
174
  this._sideFlicking.forEach((flicking, mainIndex) => {
152
175
  flicking.on(EVENTS.HOLD_START, this._onSideHoldStart);
@@ -331,9 +354,10 @@ export class CrossFlicking extends Flicking {
331
354
  return;
332
355
  }
333
356
 
357
+ const dragThreshold = this._originalDragThreshold;
334
358
  const threshold = draggable
335
- ? this.dragThreshold && this.dragThreshold >= 10
336
- ? this.dragThreshold
359
+ ? dragThreshold && dragThreshold >= 10
360
+ ? dragThreshold
337
361
  : 10
338
362
  : Infinity;
339
363
 
@@ -368,6 +392,10 @@ export class CrossFlicking extends Flicking {
368
392
  });
369
393
  };
370
394
 
395
+ private _addSideIndex = (e: ChangedEvent | WillChangeEvent): void => {
396
+ (e as CrossFlickingChangedEvent | CrossFlickingWillChangeEvent).sideIndex = this._sideFlicking[e.index].index;
397
+ };
398
+
371
399
  private _onHorizontalHoldStart = (): void => {
372
400
  this._setDraggable(MOVE_DIRECTION.HORIZONTAL, true);
373
401
  this._moveDirection = null;
package/src/Flicking.ts CHANGED
@@ -1739,7 +1739,7 @@ class Flicking extends Component<FlickingEvents> {
1739
1739
  if (!defaultPanel) return;
1740
1740
 
1741
1741
  const nearestAnchor = camera.findNearestAnchor(defaultPanel.position);
1742
- const initialPanel = (nearestAnchor && defaultPanel.index !== nearestAnchor.panel.index) ? nearestAnchor.panel : defaultPanel;
1742
+ const initialPanel = (nearestAnchor && defaultPanel.position !== nearestAnchor.panel.position && defaultPanel.index !== nearestAnchor.panel.index) ? nearestAnchor.panel : defaultPanel;
1743
1743
  control.setActive(initialPanel, null, false);
1744
1744
 
1745
1745
  if (!nearestAnchor) {
@@ -109,8 +109,9 @@ class SnapControl extends Control {
109
109
  if (snapDelta >= snapThreshold && snapDelta > 0) {
110
110
  // Move to anchor at position
111
111
  targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
112
- } else if (absPosDelta >= flicking.threshold && absPosDelta > 0) {
112
+ } else if (absPosDelta >= flicking.threshold && absPosDelta > 0 && anchorAtCamera === activeAnchor) {
113
113
  // Move to the adjacent panel
114
+ // console.log("moveToPosition anchorAtCamera activeAnchor absPosDelta", camera.position, anchorAtCamera, activeAnchor, absPosDelta, snapThreshold)
114
115
  targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
115
116
  } else {
116
117
  // Fallback to nearest panel from current camera
@@ -205,6 +206,7 @@ class SnapControl extends Control {
205
206
  }
206
207
  }
207
208
 
209
+ // console.log("_findAdjacentAnchor", position, posDelta, anchorAtCamera)
208
210
  const adjacentAnchor = (posDelta > 0 ? camera.getNextAnchor(anchorAtCamera) : camera.getPrevAnchor(anchorAtCamera)) ?? anchorAtCamera;
209
211
 
210
212
  return adjacentAnchor;
@@ -39,6 +39,10 @@ class HoldingState extends State {
39
39
 
40
40
  const inputEvent = axesEvent.inputEvent as { offsetX: number; offsetY: number };
41
41
 
42
+ if (!inputEvent) {
43
+ return;
44
+ }
45
+
42
46
  const offset = flicking.horizontal
43
47
  ? inputEvent.offsetX
44
48
  : inputEvent.offsetY;
@@ -321,6 +321,10 @@ class Panel {
321
321
  useFractionalSize
322
322
  } = flicking;
323
323
 
324
+ if (!el) {
325
+ return this;
326
+ }
327
+
324
328
  if (cached) {
325
329
  this._size = cached.size;
326
330
  this._margin = { ...cached.margin };
package/src/utils.ts CHANGED
@@ -262,6 +262,10 @@ export const setSize = (el: HTMLElement, { width, height }: Partial<{
262
262
  width: number | string;
263
263
  height: number | string;
264
264
  }>) => {
265
+ if (!el) {
266
+ return;
267
+ }
268
+
265
269
  if (width != null) {
266
270
  if (isString(width)) {
267
271
  el.style.width = width;