Skip to content

Commit 890e638

Browse files
committed
chore: add comment to SnapControl
1 parent 184e3a9 commit 890e638

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/control/SnapControl.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ class SnapControl extends Control {
8585
* @return {Promise<void>} A Promise which will be resolved after reaching the target position<ko>해당 좌표 도달시에 resolve되는 Promise</ko>
8686
*/
8787
public moveToPosition(position: number, duration: number, axesEvent?: OnRelease) {
88+
// moveToPosition은 관련 메서드가 호출되었을 때 혹은 사용자가 드래그를 중단했을 때 발생합니다.
89+
// 각각의 경우에 맞게 도착해야 할 패널을 계산합니다.
8890
const flicking = getFlickingAttached(this._flicking);
8991
const camera = flicking.camera;
9092
const activeAnchor = camera.findActiveAnchor();
@@ -107,13 +109,18 @@ class SnapControl extends Control {
107109
let targetAnchor: AnchorPoint;
108110

109111
if (snapDelta >= snapThreshold && snapDelta > 0) {
110-
// Move to anchor at position
112+
// 사용자가 드래그를 마치며 호출되었다면 snapDelta 값이 존재합니다.
113+
// position 값에는 사용자의 드래그가 종료된 시점에서 가속도 등을 고려하여 계산된 도착 지점입니다.
114+
// findSnappedAnchor는 position에서 가장 가까운 Anchor를 가진 패널을 찾습니다.
111115
targetAnchor = this._findSnappedAnchor(position, anchorAtCamera);
112116
} else if (absPosDelta >= flicking.threshold && absPosDelta > 0 && anchorAtCamera === activeAnchor) {
113-
// Move to the adjacent panel
117+
// threshold 옵션 값보다 큰 거리를 움직인 채로 드래그가 현재 패널에서 멈추면 이전/다음 패널로 움직입니다.
118+
// anchorAtCamera === activeAnchor 는 드래그가 현재 패널 위치에서 멈춘 경우를 의미합니다.
119+
// findAdjacentAnchor는 현재 패널의 이전/다음 패널을 찾습니다.
114120
targetAnchor = this._findAdjacentAnchor(position, posDelta, anchorAtCamera);
115121
} else {
116-
// Fallback to nearest panel from current camera
122+
// 사용자 입력이 아닌 메서드를 통한 호출 등 위 경우들에 해당되지 않는 fallback입니다.
123+
// 사용자 입력의 가속도를 고려할 필요 없이 현재 카메라 위치에서 가장 가까운 Anchor를 찾습니다.
117124
return this.moveToPanel(anchorAtCamera.panel, {
118125
duration,
119126
axesEvent

0 commit comments

Comments
 (0)