-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from KNU-Design-Web/feature#79
Feature#79: 프로젝트 이미지 및 비디오 LazyLoad 적용
- Loading branch information
Showing
9 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
11 changes: 11 additions & 0 deletions
11
src/components/ProjectPage/ProjectImage/ProjectImage.style.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import styled from "@emotion/styled"; | ||
|
||
export const ImageWrapper = styled.div` | ||
width: 100%; | ||
`; | ||
|
||
export const Image = styled.img` | ||
display: block; | ||
width: 100%; | ||
margin: 0px auto; | ||
`; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useInView } from "react-intersection-observer"; | ||
|
||
import * as ProjectImageStyles from "./ProjectImage.style"; | ||
|
||
export interface ProjectImageProps extends React.ComponentProps<"img"> { | ||
offset: number; | ||
} | ||
|
||
export const ProjectImage = ({ src, offset, ...rest }: ProjectImageProps) => { | ||
const { ref, inView } = useInView({ | ||
triggerOnce: true, | ||
rootMargin: `${offset}px`, | ||
}); | ||
|
||
return ( | ||
<ProjectImageStyles.ImageWrapper ref={ref} style={{ minHeight: `${offset}px` }}> | ||
{inView && <ProjectImageStyles.Image src={src} {...rest} />} | ||
</ProjectImageStyles.ImageWrapper> | ||
); | ||
}; |
13 changes: 13 additions & 0 deletions
13
src/components/ProjectPage/ProjectVideo/ProjectVideo.style.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import styled from "@emotion/styled"; | ||
|
||
export const VideoWrapper = styled.div` | ||
width: 100%; | ||
`; | ||
|
||
export const Video = styled.video` | ||
display: block; | ||
width: 100%; | ||
margin: 0px auto; | ||
border: 0; | ||
padding: 0; | ||
`; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useInView } from "react-intersection-observer"; | ||
|
||
import * as ProjectVideoStyles from "./ProjectVideo.style"; | ||
|
||
export interface ProjectVideoProps extends React.ComponentProps<"video"> { | ||
offset: number; | ||
} | ||
|
||
export const ProjectVideo = ({ src, offset, ...rest }: ProjectVideoProps) => { | ||
const { ref, inView } = useInView({ | ||
triggerOnce: true, | ||
rootMargin: `${offset}px`, | ||
}); | ||
|
||
return ( | ||
<ProjectVideoStyles.VideoWrapper ref={ref} style={{ minHeight: `${offset}px` }}> | ||
{inView && <ProjectVideoStyles.Video src={src} autoPlay loop muted playsInline {...rest} />} | ||
</ProjectVideoStyles.VideoWrapper> | ||
); | ||
}; |
This file contains 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
This file contains 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