From b365d89a11adf40d37b78292f121b890e960d0e8 Mon Sep 17 00:00:00 2001 From: Factiven Date: Thu, 13 Apr 2023 16:03:57 +0700 Subject: update 2nd --- components/hero/content.js | 119 +++++++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 53 deletions(-) (limited to 'components/hero/content.js') diff --git a/components/hero/content.js b/components/hero/content.js index 532e4a6..a3db854 100644 --- a/components/hero/content.js +++ b/components/hero/content.js @@ -1,9 +1,12 @@ import Link from "next/link"; -import React from "react"; +import React, { useState } from "react"; import Image from "next/image"; import { MdChevronLeft, MdChevronRight } from "react-icons/md"; export default function Content({ ids, section, data }) { + const [scrollLeft, setScrollLeft] = useState(false); + const [scrollRight, setScrollRight] = useState(true); + const slideLeft = () => { var slider = document.getElementById(ids); slider.scrollLeft = slider.scrollLeft - 500; @@ -13,65 +16,75 @@ export default function Content({ ids, section, data }) { slider.scrollLeft = slider.scrollLeft + 500; }; + const handleScroll = (e) => { + const scrollLeft = e.target.scrollLeft > 31; + const scrollRight = + e.target.scrollLeft < e.target.scrollWidth - e.target.clientWidth; + setScrollLeft(scrollLeft); + setScrollRight(scrollRight); + }; + + // console.log({ left: scrollLeft, right: scrollRight }); + const array = data; const filteredData = array.filter((item) => item.status !== "Unknown"); return (
-

- {section} -

-
-
- -
- {filteredData.map((anime) => { - const url = encodeURIComponent( - anime.title.english || anime.title.romaji - ); - - return ( -
{section} +
+ +
+ {filteredData.map((anime) => { + return ( +
+ - - {anime.title.romaji - -
- ); - })} -
- + {anime.title.romaji + +
+ ); + })}
+
); -- cgit v1.2.3