diff --git a/README.md b/README.md index 146102ee..1c99c78c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![Logo Do Site AniProject.](https://user-images.githubusercontent.com/69987890/177884319-0678f842-f3ca-4f62-8d31-7638ca954057.png) -Projeto de um site de animes, mangas e filmes relacionados. A API da AniList dispoe informações de animes e episodios sendo lançados atualmente, dados do elenco por trâs de tal mídia, e muito mais. +Projeto de um site de animes e mangas, utilizando a API da AniList que dispoe informações de animes e episódios sendo lançados atualmente, dados do elenco por trás de tal mídia, e muito mais. ## :hammer: Funcionalidades @@ -12,11 +12,11 @@ Projeto de um site de animes, mangas e filmes relacionados. A API da { - - scrollHeroSection() - - }, []) - - function scrollHeroSection() { - - if (typeof window !== "undefined") { - let isDragging = false; - - let startPosition = 0; - let currentTranslate = 0; - - let currentListIndex = 1 - - const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0) - let wasDraggedMoreThanOneThirdScreen = false - - const carousel = document.getElementById(`carousel`) as HTMLElement; - - if (carousel) { - - carousel.addEventListener('mousedown', (e) => { - isDragging = true; - startPosition = e.clientX - currentTranslate; - }); - - carousel.addEventListener('mouseup', (e) => { - isDragging = false; - currentTranslate = vw - (vw * (currentListIndex + 1)) - const newPosition = e.clientX - (startPosition - currentTranslate) - - currentTranslate = newPosition - vw; - - if (wasDraggedMoreThanOneThirdScreen) { - transitionBeetweenItens() - } - - }); - - carousel.addEventListener('mousemove', (e) => { - if (!isDragging) return; - - const newPosition = currentListIndex > 1 ? (e.clientX - (vw * currentListIndex)) : (e.clientX - startPosition) - - currentTranslate = newPosition; - - if ((currentListIndex + 1) == data.length) return - - updateCarousel(); - - if (currentTranslate + (vw * 1.25)) { - wasDraggedMoreThanOneThirdScreen = true - } - - }); - } - - const updateCarousel = () => { - carousel.style.transform = `translateX(${currentTranslate}px)`; - } + const [[page, direction], setPage] = useState([0, 0]); + + const variants = { + enter: (direction: number) => { + return { + x: direction > 0 ? 1000 : -1000, + opacity: 0 + }; + }, + center: { + zIndex: 1, + x: 0, + opacity: 1 + }, + exit: (direction: number) => { + return { + zIndex: 0, + x: direction < 0 ? 1000 : -1000, + opacity: 0 + }; + } + }; - const transitionBeetweenItens = () => { + const swipeConfidenceThreshold = 10000; + const swipePower = (offset: number, velocity: number) => { + return Math.abs(offset) * velocity; + }; - carousel.style.transform = `translateX(${(vw - (vw * (currentListIndex + 1)))}px)`; - currentListIndex++ - currentTranslate = 0 - wasDraggedMoreThanOneThirdScreen = false + const imageIndex = wrap(0, data.length, page); - } + const paginate = (newDirection: number) => { + setPage([page + newDirection, newDirection]); + }; - } + const styledList = { + background: `linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.10)), url(${data[imageIndex]?.media.bannerImage})`, + backgroundPosition: "center", + backgroundSize: "cover", + backgroundRepeat: "no-repeat" } return ( <> - + )}
@@ -146,7 +133,10 @@ function HeroCarousel({ data }: { data: ApiTrendingMidiaResults[] }) { data.slice(0, 6).map((item: ApiTrendingMidiaResults, key: number) => ( item.media.bannerImage && (
  • - {`Cover + + {`Cover + + {item.media.title.romaji}
  • )) ) diff --git a/front-end/package-lock.json b/front-end/package-lock.json index f0798141..9b06f825 100644 --- a/front-end/package-lock.json +++ b/front-end/package-lock.json @@ -1,12 +1,12 @@ { "name": "front-end", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "front-end", - "version": "2.0.0", + "version": "2.0.1", "dependencies": { "axios": "^1.6.6", "framer-motion": "^11.0.3", diff --git a/front-end/package.json b/front-end/package.json index 340ff81e..84ee61fe 100644 --- a/front-end/package.json +++ b/front-end/package.json @@ -1,6 +1,6 @@ { "name": "front-end", - "version": "2.0.0", + "version": "2.0.1", "private": true, "scripts": { "dev": "next dev",