@egjs/flicking 4.6.2 → 4.6.3
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/declaration/camera/mode/CameraMode.d.ts +1 -0
- package/declaration/camera/mode/CircularCameraMode.d.ts +1 -0
- package/dist/flicking.esm.js +48 -21
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +48 -21
- package/dist/flicking.js.map +1 -1
- package/dist/flicking.min.js +2 -2
- package/dist/flicking.min.js.map +1 -1
- package/dist/flicking.pkgd.js +48 -21
- package/dist/flicking.pkgd.js.map +1 -1
- package/dist/flicking.pkgd.min.js +2 -2
- package/dist/flicking.pkgd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/camera/Camera.ts +1 -19
- package/src/camera/mode/CameraMode.ts +22 -0
- package/src/camera/mode/CircularCameraMode.ts +27 -0
- package/src/control/StrictControl.ts +7 -3
|
@@ -11,6 +11,7 @@ declare abstract class CameraMode {
|
|
|
11
11
|
};
|
|
12
12
|
getAnchors(): AnchorPoint[];
|
|
13
13
|
findAnchorIncludePosition(position: number): AnchorPoint | null;
|
|
14
|
+
findNearestAnchor(position: number): AnchorPoint | null;
|
|
14
15
|
clampToReachablePosition(position: number): number;
|
|
15
16
|
getCircularOffset(): number;
|
|
16
17
|
canReach(panel: Panel): boolean;
|
|
@@ -8,6 +8,7 @@ declare class CircularCameraMode extends CameraMode {
|
|
|
8
8
|
max: number;
|
|
9
9
|
};
|
|
10
10
|
getAnchors(): AnchorPoint[];
|
|
11
|
+
findNearestAnchor(position: number): AnchorPoint | null;
|
|
11
12
|
findAnchorIncludePosition(position: number): AnchorPoint | null;
|
|
12
13
|
getCircularOffset(): number;
|
|
13
14
|
clampToReachablePosition(position: number): number;
|
package/dist/flicking.esm.js
CHANGED
|
@@ -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.6.
|
|
7
|
+
version: 4.6.3
|
|
8
8
|
*/
|
|
9
9
|
import Component, { ComponentEvent } from '@egjs/component';
|
|
10
10
|
import Axes, { PanInput } from '@egjs/axes';
|
|
@@ -3569,6 +3569,7 @@ function (_super) {
|
|
|
3569
3569
|
var lastAnchor = anchors[anchors.length - 1];
|
|
3570
3570
|
var shouldBounceToFirst = position <= cameraRange.min && isBetween(firstAnchor.panel.index, indexRange.min, indexRange.max);
|
|
3571
3571
|
var shouldBounceToLast = position >= cameraRange.max && isBetween(lastAnchor.panel.index, indexRange.min, indexRange.max);
|
|
3572
|
+
var isAdjacent = adjacentAnchor && (indexRange.min <= indexRange.max ? isBetween(adjacentAnchor.index, indexRange.min, indexRange.max) : adjacentAnchor.index >= indexRange.min || adjacentAnchor.index <= indexRange.max);
|
|
3572
3573
|
|
|
3573
3574
|
if (shouldBounceToFirst || shouldBounceToLast) {
|
|
3574
3575
|
// In bounce area
|
|
@@ -3579,7 +3580,7 @@ function (_super) {
|
|
|
3579
3580
|
// Move to anchor at position
|
|
3580
3581
|
targetPanel = anchorAtPosition.panel;
|
|
3581
3582
|
targetPos = anchorAtPosition.position;
|
|
3582
|
-
} else if (isOverThreshold &&
|
|
3583
|
+
} else if (isOverThreshold && isAdjacent) {
|
|
3583
3584
|
// Move to adjacent anchor
|
|
3584
3585
|
targetPanel = adjacentAnchor.panel;
|
|
3585
3586
|
targetPos = adjacentAnchor.position;
|
|
@@ -3645,6 +3646,27 @@ function () {
|
|
|
3645
3646
|
}, null);
|
|
3646
3647
|
};
|
|
3647
3648
|
|
|
3649
|
+
__proto.findNearestAnchor = function (position) {
|
|
3650
|
+
var anchors = this._flicking.camera.anchorPoints;
|
|
3651
|
+
if (anchors.length <= 0) return null;
|
|
3652
|
+
var prevDist = Infinity;
|
|
3653
|
+
|
|
3654
|
+
for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
|
|
3655
|
+
var anchor = anchors[anchorIdx];
|
|
3656
|
+
var dist = Math.abs(anchor.position - position);
|
|
3657
|
+
|
|
3658
|
+
if (dist > prevDist) {
|
|
3659
|
+
// Return previous anchor
|
|
3660
|
+
return anchors[anchorIdx - 1];
|
|
3661
|
+
}
|
|
3662
|
+
|
|
3663
|
+
prevDist = dist;
|
|
3664
|
+
} // Return last anchor
|
|
3665
|
+
|
|
3666
|
+
|
|
3667
|
+
return anchors[anchors.length - 1];
|
|
3668
|
+
};
|
|
3669
|
+
|
|
3648
3670
|
__proto.clampToReachablePosition = function (position) {
|
|
3649
3671
|
var camera = this._flicking.camera;
|
|
3650
3672
|
var range = camera.range;
|
|
@@ -3774,6 +3796,28 @@ function (_super) {
|
|
|
3774
3796
|
});
|
|
3775
3797
|
};
|
|
3776
3798
|
|
|
3799
|
+
__proto.findNearestAnchor = function (position) {
|
|
3800
|
+
var camera = this._flicking.camera;
|
|
3801
|
+
var anchors = camera.anchorPoints;
|
|
3802
|
+
if (anchors.length <= 0) return null;
|
|
3803
|
+
var camRange = camera.range;
|
|
3804
|
+
var minDist = Infinity;
|
|
3805
|
+
var minDistIndex = -1;
|
|
3806
|
+
|
|
3807
|
+
for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
|
|
3808
|
+
var anchor = anchors[anchorIdx];
|
|
3809
|
+
var dist = Math.min(Math.abs(anchor.position - position), Math.abs(anchor.position - camRange.min + camRange.max - position), Math.abs(position - camRange.min + camRange.max - anchor.position));
|
|
3810
|
+
|
|
3811
|
+
if (dist < minDist) {
|
|
3812
|
+
minDist = dist;
|
|
3813
|
+
minDistIndex = anchorIdx;
|
|
3814
|
+
}
|
|
3815
|
+
} // Return last anchor
|
|
3816
|
+
|
|
3817
|
+
|
|
3818
|
+
return anchors[minDistIndex];
|
|
3819
|
+
};
|
|
3820
|
+
|
|
3777
3821
|
__proto.findAnchorIncludePosition = function (position) {
|
|
3778
3822
|
var camera = this._flicking.camera;
|
|
3779
3823
|
var range = camera.range;
|
|
@@ -4542,24 +4586,7 @@ function () {
|
|
|
4542
4586
|
|
|
4543
4587
|
|
|
4544
4588
|
__proto.findNearestAnchor = function (position) {
|
|
4545
|
-
|
|
4546
|
-
if (anchors.length <= 0) return null;
|
|
4547
|
-
var prevDist = Infinity;
|
|
4548
|
-
|
|
4549
|
-
for (var anchorIdx = 0; anchorIdx < anchors.length; anchorIdx++) {
|
|
4550
|
-
var anchor = anchors[anchorIdx];
|
|
4551
|
-
var dist = Math.abs(anchor.position - position);
|
|
4552
|
-
|
|
4553
|
-
if (dist > prevDist) {
|
|
4554
|
-
// Return previous anchor
|
|
4555
|
-
return anchors[anchorIdx - 1];
|
|
4556
|
-
}
|
|
4557
|
-
|
|
4558
|
-
prevDist = dist;
|
|
4559
|
-
} // Return last anchor
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
return anchors[anchors.length - 1];
|
|
4589
|
+
return this._mode.findNearestAnchor(position);
|
|
4563
4590
|
};
|
|
4564
4591
|
/**
|
|
4565
4592
|
* Return {@link AnchorPoint} that matches {@link Flicking#currentPanel}
|
|
@@ -8376,7 +8403,7 @@ function (_super) {
|
|
|
8376
8403
|
*/
|
|
8377
8404
|
|
|
8378
8405
|
|
|
8379
|
-
Flicking.VERSION = "4.6.
|
|
8406
|
+
Flicking.VERSION = "4.6.3";
|
|
8380
8407
|
return Flicking;
|
|
8381
8408
|
}(Component);
|
|
8382
8409
|
|