Skip to content

Commit 5966e56

Browse files
committed
feat: set default value to isReachEnd
1 parent 7b90942 commit 5966e56

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/reactive/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ReactiveSetupAdapter
66
} from "@cfcs/core";
77

8-
import Flicking, { FlickingOptions } from "../Flicking";
8+
import Flicking from "../Flicking";
99

1010
// Check if Flicking has reached the first panel
1111
const getIsReachStart = (flicking: Flicking) => !flicking.circular && flicking.index === 0;
@@ -145,11 +145,11 @@ export interface FlickingReactiveData {
145145
/**
146146
* Flicking instance to connect<ko>연결할 Flicking 인스턴스</ko>
147147
*/
148-
flicking: Flicking | undefined;
148+
flicking?: Flicking;
149149
/**
150150
* Flicking options used for initialization<ko>초기화에 사용되는 Flicking 옵션</ko>
151151
*/
152-
options: FlickingReactiveAPIOptions | undefined;
152+
options?: FlickingReactiveAPIOptions;
153153
}
154154

155155
/**
@@ -177,15 +177,15 @@ export interface FlickingReactiveAPIOptions {
177177
* 또한 isReachStart 계산에도 영향을 줍니다 (defaultIndex가 0일 때 true).
178178
* @default 0
179179
*/
180-
defaultIndex: number;
180+
defaultIndex?: number;
181181
/**
182182
* Total number of panels in the Flicking instance. This sets the totalPanelCount initial value
183183
* and helps prevent layout shifts during SSR hydration.
184184
* @ko Flicking 인스턴스의 전체 패널 개수. totalPanelCount의 초기값을 설정하며
185185
* SSR 하이드레이션 과정에서 레이아웃 시프트를 방지하는 데 도움이 됩니다.
186186
* @default 0
187187
*/
188-
totalPanelCount: number;
188+
totalPanelCount?: number;
189189
}
190190

191191

@@ -226,8 +226,8 @@ FlickingReactiveData
226226
// options를 고려하지 않고 초기값을 설정해도 동작에는 아무런 문제가 없으나, 이 시점의 초기값과 컴포넌트 init 단계에서의 초기값이 다르면 화면 리렌더링이 발생할 수 있으므로
227227
// 이렇게 미리 옵션을 통해서 예측할 수 있는 부분들은 맞춰둔다.
228228
const reactiveObj: FlickingReactiveObject = reactive({
229-
isReachStart: options?.defaultIndex === 0,
230-
isReachEnd: false,
229+
isReachStart: options?.defaultIndex ? options?.defaultIndex === 0 : true,
230+
isReachEnd: (options?.totalPanelCount && options?.defaultIndex) ? (options.defaultIndex === options.totalPanelCount - 1) : false,
231231
totalPanelCount: options?.totalPanelCount ?? 0,
232232
currentPanelIndex: options?.defaultIndex ?? 0,
233233
progress: 0,

0 commit comments

Comments
 (0)