Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a mix-up between before and after images in the slide view #49

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions src/components/Viewer/internal/ComparisonView/Slide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ const View = styled.div`

const Before = styled(View)`
z-index: 0;
transform: translate(0, 0);
`;

const After = styled(View)`
z-index: 1;
transform: translate(0, 0);
`;

const Handle = styled.span`
Expand Down Expand Up @@ -182,38 +182,38 @@ export const Slide: React.FC<Props> = ({
onChange={handleChange}
/>

<Before
style={{
width: image.before.width,
height: image.before.height,
}}
>
<Image
ref={image.before.ref}
src={before}
onLoad={image.before.handleLoad}
/>
<Markers variant="before" matching={matching} />
</Before>

<Frame style={{ width: `${value}%` }}>
<Before
<After
style={{
top: 0,
left: canvas.width / 2 - image.before.width / 2,
width: image.before.width,
height: image.before.height,
left: canvas.width / 2 - image.after.width / 2,
width: image.after.width,
height: image.after.height,
}}
>
<Image
ref={image.before.ref}
src={before}
onLoad={image.before.handleLoad}
ref={image.after.ref}
src={after}
onLoad={image.after.handleLoad}
/>
<Markers variant="before" matching={matching} />
</Before>
<Markers variant="after" matching={matching} />
</After>
</Frame>

<After
style={{
width: image.after.width,
height: image.after.height,
}}
>
<Image
ref={image.after.ref}
src={after}
onLoad={image.after.handleLoad}
/>
<Markers variant="after" matching={matching} />
</After>

<Handle style={{ left: `${value}%` }}>
<HandleBar />
</Handle>
Expand Down