Skip to content

Commit

Permalink
Merge pull request #459 from woowacourse-teams/feat/302-javascript-co…
Browse files Browse the repository at this point in the history
…ntrolled-swipe

JavaScript로 제어하는 스크롤 스냅 구현
  • Loading branch information
solo5star authored Sep 20, 2023
2 parents 1775c47 + 4c72e87 commit acb36e2
Show file tree
Hide file tree
Showing 5 changed files with 419 additions and 39 deletions.
11 changes: 1 addition & 10 deletions client/src/components/CafeCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useEffect, useRef, useState } from 'react';
import { styled } from 'styled-components';
import useIntersection from '../hooks/useIntersection';
import type { Cafe } from '../types';
import Image from '../utils/Image';
import CafeActionBar from './CafeActionBar';
Expand All @@ -9,23 +8,15 @@ import CafeSummary from './CafeSummary';

type CardProps = {
cafe: Cafe;
onIntersect?: (intersection: IntersectionObserverEntry) => void;
};

const CafeCard = (props: CardProps) => {
const { cafe, onIntersect } = props;
const { cafe } = props;

const [isShowDetail, setIsShowDetail] = useState(false);
const [currentImageIndex, setCurrentImageIndex] = useState(0);

const ref = useRef<HTMLDivElement>(null);
const intersection = useIntersection(ref, { threshold: 0.7 });

useEffect(() => {
if (intersection) {
onIntersect?.(intersection);
}
}, [intersection?.isIntersecting]);

useEffect(() => {
const handleScroll = () => {
Expand Down
Loading

0 comments on commit acb36e2

Please sign in to comment.