fix(vton-slider): initial render shows after-only (clip-path refactor) (#602)#608
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BeforeAfter slider의 첫 렌더 시 after 이미지만 보이고 before 이미지가 width=0으로 표시되지 않던 race condition을 CSS
clip-path방식으로 리팩토하여 해결.Root cause
BeforeAfterSlider.tsx:54-57의 inner image width를containerRef.current.offsetWidth로 계산:첫 렌더에서
containerRef.current === null→ before 이미지 width=0 → after만 표시. 사용자가 슬라이더를 드래그하면 setSliderPos가 re-render를 트리거하면서 그제야 ref가 측정되어 정상 표시.Changes
packages/web/lib/components/vton/BeforeAfterSlider.tsx— 전체 리팩토<div>clip wrapper +offsetWidth기반 inner img 제거absolute inset-0 h-full w-full object-contain로 동일 위치/크기에 겹쳐 배치style={{ clipPath: \inset(0 ${100 - sliderPos}% 0 0)` }}` 적용pointer-events-none추가 (드래그 hit-test 방해 방지)packages/web/lib/components/vton/__tests__/BeforeAfterSlider.test.tsx(신규)inset(0 50% 0 0)인지 확인widthpx 값이 더 이상 적용되지 않는지(offsetWidth 의존 제거 확인) 확인Verification
bun run test BeforeAfterSlider.test.tsx→ 3 PASSbun run lint→ 0 errors (pre-existing img warning만)bun run tsc --noEmit→ 0 errors (vton files)bun run build→ PASSTest plan
bun run buildfailure is NOT this PRLocal
bun run build가packages/web/app/api/v1/content/assets/plan/__tests__/route.test.ts:559의useResearchInCopy타입 mismatch로 실패합니다. 이는 dev pre-existing: #498 (feat(content-studio): AI-powered content generation pipeline) 머지된 시점부터 발생. 본 PR은 vton 파일만 건드리고 vton 한정 lint/tsc/test는 모두 PASS. content-studio 영역 fix는 별도 owner가 처리해야 함.Refs #602 (sub-PR #2 of 4)