@egjs/flicking 4.14.1 → 4.14.2-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egjs/flicking",
3
- "version": "4.14.1",
3
+ "version": "4.14.2-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",
@@ -345,7 +345,7 @@ class AxesController {
345
345
  return Promise.reject(new FlickingError(ERROR.MESSAGE.NOT_ATTACHED_TO_FLICKING, ERROR.CODE.NOT_ATTACHED_TO_FLICKING));
346
346
  }
347
347
 
348
- const startPos = axes.get([AXES.POSITION_KEY])[AXES.POSITION_KEY];
348
+ const startPos = this.getCurrentPosition();
349
349
 
350
350
  if (startPos === position) {
351
351
  const flicking = getFlickingAttached(this._flicking);
@@ -396,6 +396,14 @@ class AxesController {
396
396
  });
397
397
  }
398
398
 
399
+ /**
400
+ * 현재
401
+ * @returns
402
+ */
403
+ public getCurrentPosition() {
404
+ return this._axes?.get([AXES.POSITION_KEY])[AXES.POSITION_KEY] ?? 0;
405
+ }
406
+
399
407
  public updateDirection() {
400
408
  const flicking = getFlickingAttached(this._flicking);
401
409
  const axes = this._axes!;
@@ -380,12 +380,19 @@ abstract class Control {
380
380
  axesEvent?: OnRelease;
381
381
  }) {
382
382
  const flicking = getFlickingAttached(this._flicking);
383
- const animate = () => this._controller.animateTo(position, duration, axesEvent);
383
+
384
+ // 거리(1px 미만)가 매우 짧은 경우 duration이 늘어지는걸 방지하기 위해 0으로 바꿔 즉시 변경
385
+ let nextDuration = duration;
386
+
387
+ if (Math.abs(nextDuration - position) < 0.5) {
388
+ nextDuration = 0;
389
+ }
390
+ const animate = () => this._controller.animateTo(position, nextDuration, axesEvent);
384
391
  const state = this._controller.state;
385
392
 
386
393
  state.targetPanel = newActivePanel;
387
394
 
388
- if (duration <= 0) {
395
+ if (nextDuration <= 0) {
389
396
  return animate();
390
397
  } else {
391
398
  return animate().then(async () => {
@@ -220,8 +220,9 @@ class StrictControl extends Control {
220
220
  const firstAnchor = anchors[0];
221
221
  const lastAnchor = anchors[anchors.length - 1];
222
222
 
223
- const shouldBounceToFirst = position <= cameraRange.min && isBetween(firstAnchor.panel.index, indexRange.min, indexRange.max);
224
- const shouldBounceToLast = position >= cameraRange.max && isBetween(lastAnchor.panel.index, indexRange.min, indexRange.max);
223
+ // position bounce으로 인하여 범위를 넘어가야 동작하도록 변경
224
+ const shouldBounceToFirst = position < cameraRange.min && isBetween(firstAnchor.panel.index, indexRange.min, indexRange.max);
225
+ const shouldBounceToLast = position > cameraRange.max && isBetween(lastAnchor.panel.index, indexRange.min, indexRange.max);
225
226
 
226
227
  const isAdjacent = adjacentAnchor && (indexRange.min <= indexRange.max
227
228
  ? isBetween(adjacentAnchor.index, indexRange.min, indexRange.max)
@@ -20,6 +20,9 @@ class AutoResizer {
20
20
  return this._enabled;
21
21
  }
22
22
 
23
+ /**
24
+ * @param flicking
25
+ */
23
26
  public constructor(flicking: Flicking) {
24
27
  this._flicking = flicking;
25
28
  this._enabled = false;