|
@@ -1,3 +1,4 @@
|
|
|
|
|
+import { useEffect, useRef } from 'react';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
import { Icon } from '@iconify/react';
|
|
import { Icon } from '@iconify/react';
|
|
@@ -9,6 +10,22 @@ import Wrapper from './Wrapper';
|
|
|
|
|
|
|
|
export function Features() {
|
|
export function Features() {
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
|
|
+ const scrollRef = useRef<HTMLDivElement>(null);
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ const el = scrollRef.current;
|
|
|
|
|
+ if (!el) return;
|
|
|
|
|
+ const scrollToCenter = () => {
|
|
|
|
|
+ const { scrollWidth, clientWidth } = el;
|
|
|
|
|
+ if (scrollWidth > clientWidth) {
|
|
|
|
|
+ el.scrollLeft = (scrollWidth - clientWidth) / 2;
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ scrollToCenter();
|
|
|
|
|
+ const observer = new ResizeObserver(scrollToCenter);
|
|
|
|
|
+ observer.observe(el);
|
|
|
|
|
+ return () => observer.disconnect();
|
|
|
|
|
+ }, []);
|
|
|
|
|
|
|
|
const items = [
|
|
const items = [
|
|
|
{
|
|
{
|
|
@@ -40,12 +57,15 @@ export function Features() {
|
|
|
</p>
|
|
</p>
|
|
|
</div>
|
|
</div>
|
|
|
</Wrapper>
|
|
</Wrapper>
|
|
|
- <div className="w-full sm:max-w-full sm:overflow-x-scroll sm:no-scrollbar">
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ ref={scrollRef}
|
|
|
|
|
+ className="w-full sm:max-w-full sm:overflow-x-auto sm:overflow-y-hidden sm:no-scrollbar"
|
|
|
|
|
+ >
|
|
|
<Wrapper className="w-fit min-w-full flex flex-wrap sm:flex-nowrap items-stretch gap-8">
|
|
<Wrapper className="w-fit min-w-full flex flex-wrap sm:flex-nowrap items-stretch gap-8">
|
|
|
{items.map(({ titleKey, descKey, icon }, index) => (
|
|
{items.map(({ titleKey, descKey, icon }, index) => (
|
|
|
<div
|
|
<div
|
|
|
key={index}
|
|
key={index}
|
|
|
- className="rounded-2xl border border-white/10 bg-white/5 sm:min-h-[246px] w-full sm:w-[406px] p-5 sm:p-8 shrink-0 flex flex-col"
|
|
|
|
|
|
|
+ className="transition-all rounded-2xl border border-white/10 bg-white/5 sm:min-h-[246px] w-full sm:w-[406px] p-5 sm:p-8 shrink-0 flex flex-col"
|
|
|
>
|
|
>
|
|
|
<Icon
|
|
<Icon
|
|
|
icon={icon}
|
|
icon={icon}
|