Skip to content

Commit

Permalink
Merge pull request #162 from P4-Games/fix/parpapeo-flipbook
Browse files Browse the repository at this point in the history
Fix/parpapeo flipbook
  • Loading branch information
dappsar authored Nov 22, 2023
2 parents 77df104 + 19b92b2 commit 9cda55c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
21 changes: 18 additions & 3 deletions src/sections/Gamma/GammaAlbum.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useState, useEffect } from 'react'
import PropTypes from 'prop-types'
import HTMLFlipBook from 'react-pageflip'
import { FcCheckmark } from 'react-icons/fc'
Expand Down Expand Up @@ -93,6 +93,18 @@ const GammaAlbum = (props) => {
}

const Book = () => {
const [isClassesReplaced, setIsClassesReplaced] = useState(false)
useEffect(() => {
// Cambiar las clases después de un tiempo de carga simulado (0.5 mSeg),
// es para evitar un efecto de parpadeo no deseado por htmlFlipBook
const timer = setTimeout(() => {
setIsClassesReplaced(true);
}, 0.5)

// Limpiar el temporizador para evitar fugas de memoria
return () => clearTimeout(timer)
}, [])

if (!paginationObj)
return (<></>)
else
Expand All @@ -115,14 +127,17 @@ const GammaAlbum = (props) => {
{Array.from({ length: 10 }, (_, index) => (
<div
key={index}
className={index % 2 === 0 ? 'hero__top__album__book__page' : 'hero__top__album__book__page0'}
className={
index % 2 === 0
? (isClassesReplaced ? 'hero__top__album__book__page' : '')
: (isClassesReplaced ? 'hero__top__album__book__page0' : '')
}
data-density='hard'
number={index + 1}
>
<PageContent page={paginationObj[`page${index + 1}`]} pageNumber={index + 1} />
</div>
))}

</HTMLFlipBook>
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/styles/_hero.scss
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@ $groundHeight: 40px;
margin-right: 10px;
}
}

&__btn2 {
@extend .hero__top__album__book__page__btn;
background: #f60008;
&:hover {
background: #fc272e;
}
}

&__btn3 {
@extend .hero__top__album__book__page__btn;
background: #eeda41;
Expand Down

0 comments on commit 9cda55c

Please sign in to comment.