@egjs/flicking 4.10.5-beta.0 → 4.10.6

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 +236 -236
  2. package/declaration/camera/Camera.d.ts +82 -82
  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 +44 -44
  17. package/declaration/control/AxesController.d.ts +44 -44
  18. package/declaration/control/Control.d.ts +44 -44
  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.d.ts +13 -13
  45. package/declaration/index.umd.d.ts +2 -2
  46. package/declaration/renderer/ExternalRenderer.d.ts +7 -7
  47. package/declaration/renderer/Renderer.d.ts +59 -58
  48. package/declaration/renderer/VanillaRenderer.d.ts +10 -10
  49. package/declaration/renderer/index.d.ts +6 -6
  50. package/declaration/renderer/strategy/NormalRenderingStrategy.d.ts +23 -23
  51. package/declaration/renderer/strategy/RenderingStrategy.d.ts +15 -15
  52. package/declaration/renderer/strategy/VirtualRenderingStrategy.d.ts +17 -17
  53. package/declaration/renderer/strategy/index.d.ts +5 -5
  54. package/declaration/type/event.d.ts +88 -88
  55. package/declaration/type/external.d.ts +31 -31
  56. package/declaration/type/internal.d.ts +13 -13
  57. package/declaration/utils.d.ts +45 -45
  58. package/dist/flicking.esm.js +40 -37
  59. package/dist/flicking.esm.js.map +1 -1
  60. package/dist/flicking.js +40 -37
  61. package/dist/flicking.js.map +1 -1
  62. package/dist/flicking.min.js +2 -2
  63. package/dist/flicking.min.js.map +1 -1
  64. package/dist/flicking.pkgd.js +882 -871
  65. package/dist/flicking.pkgd.js.map +1 -1
  66. package/dist/flicking.pkgd.min.js +2 -2
  67. package/dist/flicking.pkgd.min.js.map +1 -1
  68. package/package.json +1 -1
  69. package/src/Flicking.ts +2 -1
  70. package/src/camera/Camera.ts +1 -1
  71. package/src/control/AxesController.ts +14 -29
  72. package/src/control/SnapControl.ts +2 -2
  73. package/src/control/StrictControl.ts +9 -3
  74. package/src/core/ResizeWatcher.ts +1 -1
  75. package/src/renderer/Renderer.ts +6 -0
  76. package/src/renderer/VanillaRenderer.ts +1 -0
  77. package/src/utils.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egjs/flicking",
3
- "version": "4.10.5-beta.0",
3
+ "version": "4.10.6",
4
4
  "description": "Everyday 30 million people experience. It's reliable, flexible and extendable carousel.",
5
5
  "main": "dist/flicking.js",
6
6
  "module": "dist/flicking.esm.js",
package/src/Flicking.ts CHANGED
@@ -1065,11 +1065,12 @@ class Flicking extends Component<FlickingEvents> {
1065
1065
  this.disableInput();
1066
1066
  }
1067
1067
  renderer.checkPanelContentsReady(renderer.panels);
1068
+ this._initialized = true;
1068
1069
 
1069
1070
  return renderer.render().then(() => {
1070
1071
  // Done initializing & emit ready event
1071
1072
  this._plugins.forEach(plugin => plugin.init(this));
1072
- this._initialized = true;
1073
+
1073
1074
  if (preventEventsBeforeInit) {
1074
1075
  this.trigger = originalTrigger;
1075
1076
  }
@@ -551,7 +551,7 @@ class Camera {
551
551
  const flicking = getFlickingAttached(this._flicking);
552
552
  const renderer = flicking.renderer;
553
553
 
554
- if (renderer.rendering) return this;
554
+ if (renderer.rendering || !flicking.initialized) return this;
555
555
 
556
556
  const actualPosition = this._position - this._alignPos - this._offset + this._circularOffset;
557
557
 
@@ -8,7 +8,7 @@ import Flicking from "../Flicking";
8
8
  import FlickingError from "../core/FlickingError";
9
9
  import * as AXES from "../const/axes";
10
10
  import * as ERROR from "../const/error";
11
- import { circulatePosition, getFlickingAttached, parseBounce } from "../utils";
11
+ import { getFlickingAttached, parseBounce } from "../utils";
12
12
  import { ControlParams } from "../type/external";
13
13
 
14
14
  import StateMachine from "./StateMachine";
@@ -376,37 +376,22 @@ class AxesController {
376
376
  }
377
377
  };
378
378
 
379
- if (duration === 0) {
380
- const flicking = getFlickingAttached(this._flicking);
381
- const camera = flicking.camera;
382
-
383
- animate();
379
+ return new Promise((resolve, reject) => {
380
+ const animationFinishHandler = () => {
381
+ axes.off(AXES.EVENT.HOLD, interruptionHandler);
382
+ resolve();
383
+ };
384
384
 
385
- const newPos = flicking.circularEnabled
386
- ? circulatePosition(position, camera.range.min, camera.range.max)
387
- : position;
385
+ const interruptionHandler = () => {
386
+ axes.off(AXES.EVENT.FINISH, animationFinishHandler);
387
+ reject(new FlickingError(ERROR.MESSAGE.ANIMATION_INTERRUPTED, ERROR.CODE.ANIMATION_INTERRUPTED));
388
+ };
388
389
 
389
- axes.axisManager.set({ [AXES.POSITION_KEY]: newPos });
390
+ axes.once(AXES.EVENT.FINISH, animationFinishHandler);
391
+ axes.once(AXES.EVENT.HOLD, interruptionHandler);
390
392
 
391
- return Promise.resolve();
392
- } else {
393
- return new Promise((resolve, reject) => {
394
- const animationFinishHandler = () => {
395
- axes.off(AXES.EVENT.HOLD, interruptionHandler);
396
- resolve();
397
- };
398
-
399
- const interruptionHandler = () => {
400
- axes.off(AXES.EVENT.FINISH, animationFinishHandler);
401
- reject(new FlickingError(ERROR.MESSAGE.ANIMATION_INTERRUPTED, ERROR.CODE.ANIMATION_INTERRUPTED));
402
- };
403
-
404
- axes.once(AXES.EVENT.FINISH, animationFinishHandler);
405
- axes.once(AXES.EVENT.HOLD, interruptionHandler);
406
-
407
- animate();
408
- });
409
- }
393
+ animate();
394
+ });
410
395
  }
411
396
 
412
397
  public updateDirection() {
@@ -113,8 +113,8 @@ class SnapControl extends Control {
113
113
  // Move to the adjacent panel
114
114
  targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
115
115
  } else {
116
- // Restore to active panel
117
- return this.moveToPanel(activeAnchor.panel, {
116
+ // Fallback to nearest panel from current camera
117
+ return this.moveToPanel(anchorAtCamera.panel, {
118
118
  duration,
119
119
  axesEvent
120
120
  });
@@ -242,9 +242,15 @@ class StrictControl extends Control {
242
242
  targetPanel = adjacentAnchor!.panel;
243
243
  targetPos = adjacentAnchor!.position;
244
244
  } else {
245
- // Restore to active panel
246
- targetPos = camera.clampToReachablePosition(activePanel.position);
247
- targetPanel = activePanel;
245
+ // Fallback to nearest panel from current camera
246
+ const anchorAtCamera = camera.findNearestAnchor(camera.position);
247
+ if (!anchorAtCamera) {
248
+ return Promise.reject(new FlickingError(ERROR.MESSAGE.POSITION_NOT_REACHABLE(position), ERROR.CODE.POSITION_NOT_REACHABLE));
249
+ }
250
+ return this.moveToPanel(anchorAtCamera.panel, {
251
+ duration,
252
+ axesEvent
253
+ });
248
254
  }
249
255
 
250
256
  this._triggerIndexChangeEvent(targetPanel, position, axesEvent);
@@ -67,7 +67,7 @@ class ResizeWatcher {
67
67
  public destroy() {
68
68
  this._observer?.disconnect();
69
69
  if (this._options.useWindowResize) {
70
- window.removeEventListener("reisze", this._onResize);
70
+ window.removeEventListener("resize", this._onResize);
71
71
  }
72
72
  }
73
73
 
@@ -536,6 +536,12 @@ abstract class Renderer {
536
536
  cameraElement.removeChild(panel.element);
537
537
  });
538
538
  }
539
+
540
+ protected _afterRender() {
541
+ const flicking = getFlickingAttached(this._flicking);
542
+
543
+ flicking.camera.applyTransform();
544
+ }
539
545
  }
540
546
 
541
547
  export default Renderer;
@@ -20,6 +20,7 @@ class VanillaRenderer extends Renderer {
20
20
  strategy.renderPanels(flicking);
21
21
 
22
22
  this._resetPanelElementOrder();
23
+ this._afterRender();
23
24
  }
24
25
 
25
26
  protected _collectPanels() {
package/src/utils.ts CHANGED
@@ -214,7 +214,7 @@ export const circulatePosition = (pos: number, min: number, max: number) => {
214
214
  if (pos < min) {
215
215
  const offset = (min - pos) % size;
216
216
  pos = max - offset;
217
- } else if (pos >= max) {
217
+ } else if (pos > max) {
218
218
  const offset = (pos - max) % size;
219
219
  pos = min + offset;
220
220
  }