Skip to content

Commit

Permalink
[modify] 기대평이 width보다 적게 보여질 때 후처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
lybell-art committed Aug 20, 2024
1 parent 45a2150 commit 53d27ce
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/mainPage/features/comment/autoScrollCarousel/index.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import useAutoCarousel from "./useAutoCarousel.js";

function AutoScrollCarousel({ speed = 1, gap = 0, children }) {
const { position, ref, eventListener } = useAutoCarousel(speed);
const { position, ref, eventListener } = useAutoCarousel(speed, gap);

const flexStyle = "flex [&>div]:flex-shrink-0 gap-[var(--gap,0)] items-center absolute";
const flexStyle = "min-w-full flex [&>div]:flex-shrink-0 gap-[var(--gap,0)] justify-around items-center absolute";
return (
<div className="w-full h-full overflow-hidden" {...eventListener}>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const FRICTION_RATE = 0.1;
const MOMENTUM_THRESHOLD = 0.6;
const MOMENTUM_RATE = 0.3;

function useAutoCarousel(speed = 1) {
function useAutoCarousel(speed = 1, gap = 0) {
const childRef = useRef(null);
const [position, setPosition] = useState(0);
const [isControlled, setIsControlled] = useState(false);
Expand All @@ -19,7 +19,7 @@ function useAutoCarousel(speed = 1) {
(time) => {
if (childRef.current === null) return;

const width = childRef.current.clientWidth;
const width = childRef.current.clientWidth + gap;

// 마우스 뗐을 때 관성 재계산
const baseSpeed = isHovered ? 0 : speed;
Expand Down
2 changes: 1 addition & 1 deletion src/mainPage/features/comment/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { http, HttpResponse } from "msw";
import { makeLorem } from "@common/mock/utils.js";

function getCommentMock() {
return Array.from({ length: 20 }, (_, i) => {
return Array.from({ length: 2 }, (_, i) => {
return {
id: i * 100 + Math.floor(Math.random() * 99),
content: makeLorem(5, 12),
Expand Down

0 comments on commit 53d27ce

Please sign in to comment.