Skip to content

Commit 3341781

Browse files
author
梁朝飞
committed
feat: 三元 to if
1 parent 8106d4c commit 3341781

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

src/MotionThumb.tsx

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -145,28 +145,33 @@ export default function MotionThumb(props: MotionThumbInterface) {
145145
}, [vertical, direction, nextStyle]);
146146

147147
// =========================== Motion ===========================
148-
const onAppearStart = () =>
149-
vertical
150-
? {
151-
transform: 'translateY(var(--thumb-start-top))',
152-
height: 'var(--thumb-start-height)',
153-
}
154-
: {
155-
transform: 'translateX(var(--thumb-start-left))',
156-
width: 'var(--thumb-start-width)',
157-
};
148+
const onAppearStart = () => {
149+
if (vertical) {
150+
return {
151+
transform: 'translateY(var(--thumb-start-top))',
152+
height: 'var(--thumb-start-height)',
153+
};
154+
}
158155

159-
const onAppearActive = () =>
160-
// Returns active transform and size styles for the thumb based on the layout orientation (vertical or horizontal).
161-
vertical
162-
? {
163-
transform: 'translateY(var(--thumb-active-top))',
164-
height: 'var(--thumb-active-height)',
165-
}
166-
: {
167-
transform: 'translateX(var(--thumb-active-left))',
168-
width: 'var(--thumb-active-width)',
169-
};
156+
return {
157+
transform: 'translateX(var(--thumb-start-left))',
158+
width: 'var(--thumb-start-width)',
159+
};
160+
};
161+
162+
const onAppearActive = () => {
163+
if (vertical) {
164+
return {
165+
transform: 'translateY(var(--thumb-active-top))',
166+
height: 'var(--thumb-active-height)',
167+
};
168+
}
169+
170+
return {
171+
transform: 'translateX(var(--thumb-active-left))',
172+
width: 'var(--thumb-active-width)',
173+
};
174+
};
170175

171176
const onVisibleChanged = () => {
172177
setPrevStyle(null);

0 commit comments

Comments
 (0)