Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions src/app/(team)/team/_components/TeamBanner/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const teamBannerImgStyle =

export const teamBannerTitleStyle = clsx(
'text-xl-bold',
'relative flex-1',
'laptop:max-w-[800px] tablet:max-w-[460px] max-w-[245px]',
'relative flex-1 pr-3',
'min-w-0'
);
36 changes: 28 additions & 8 deletions src/components/common/Scroll/GradientScrollable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client';
import clsx from 'clsx';
import { useState } from 'react';
import { useEffect, useRef, useState } from 'react';

interface GradientScrollableProps {
children: React.ReactNode;
Expand All @@ -20,8 +19,23 @@ const GradientScrollable = ({
className,
color = '#272e3f',
}: GradientScrollableProps) => {
const scrollRef = useRef<HTMLDivElement>(null);
const [isOverflowing, setIsOverflowing] = useState(false);
const [isScrollMove, setIsScrollMove] = useState(false);

useEffect(() => {
const el = scrollRef.current;
if (!el) return;

const observer = new ResizeObserver(() => {
setIsOverflowing(el.scrollWidth > el.clientWidth);
});

observer.observe(el);

return () => observer.disconnect();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

observer 해제 처리까지 잘 되있어서 안정성 면에서도 좋네요 ! 👍🏻 고생하셨습니다 민지님 ~!

}, [children]);

const handleScroll = (e: React.UIEvent<HTMLDivElement>) => {
const { scrollLeft } = e.currentTarget;
setIsScrollMove(scrollLeft >= 10);
Expand All @@ -30,6 +44,7 @@ const GradientScrollable = ({
return (
<div className="relative">
<div
ref={scrollRef}
onScroll={handleScroll}
className={clsx(
'scrollbar-hide overflow-x-auto whitespace-nowrap',
Expand All @@ -38,12 +53,17 @@ const GradientScrollable = ({
>
{children}
</div>
<div
className={clsx(overflowTextGradientStyle, isScrollMove && 'opacity-0')}
style={{
background: `linear-gradient(to left, ${color}, transparent)`,
}}
/>
{isOverflowing && (
<div
className={clsx(
overflowTextGradientStyle,
isScrollMove && 'opacity-0'
)}
style={{
background: `linear-gradient(to left, ${color}, transparent)`,
}}
/>
)}
</div>
);
};
Expand Down