-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddbaed6
commit cd0f9a5
Showing
3 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// turn pages when click next or prev button | ||
const pageTurnBtn = document.querySelectorAll('.nextprev-btn'); | ||
|
||
pageTurnBtn.forEach((el, index) => { | ||
el.onclick = () => { | ||
const pageTurnId = el.getAttribute('data-page'); | ||
const pageTurn = document.getElementById(pageTurnId); | ||
if(pageTurn.classList.contains('turn')){ | ||
pageTurn.classList.remove('turn'); | ||
setTimeout(() =>{ | ||
pageTurn.style.zIndex = 20 - index; | ||
}, 500) | ||
} | ||
else{ | ||
pageTurn.classList.add('turn'); | ||
setTimeout(() => { | ||
pageTurn.style.zIndex = 20 + index; | ||
}, 500) | ||
} | ||
} | ||
}) | ||
|
||
// contact me when button click | ||
const pages = document.querySelectorAll('.book-page.page-right'); | ||
const contactMeBtn = document.querySelector('.btn.contact-me'); | ||
|
||
contactMeBtn.onclick = () =>{ | ||
pages.forEach((page,index) => { | ||
setTimeout(() => { | ||
page.classList.add('turn'); | ||
setTimeout(() => { | ||
page.style.zIndex = 20 + index; | ||
}, 500) | ||
},(index + 1) * 200 + 100) | ||
}) | ||
} | ||
|
||
// create reverse index function | ||
let totalPages = pages.length; | ||
let pageNumber = 0; | ||
|
||
function reverseIndex(){ | ||
pageNumber--; | ||
if(pageNumber < 0){ | ||
pageNumber = totalPages - 1; | ||
} | ||
} | ||
|
||
// back profile button when click | ||
const backProfileBtn = document.querySelector('.back-profile'); | ||
|
||
backProfileBtn.onclick = () => { | ||
pages.forEach((_, index) => { | ||
setTimeout(() => { | ||
reverseIndex(); | ||
pages[pageNumber].classList.remove('turn'); | ||
setTimeout(() => { | ||
reverseIndex(); | ||
pages[pageNumber].style.zIndex = 10 + index; | ||
}, 500) | ||
}, (index + 1) *200 + 100) | ||
}) | ||
} | ||
|
||
// opening Animation | ||
const coverRight = document.querySelector('.cover.cover-right'); | ||
const pageLeft = document.querySelector('.book-page.page-left') | ||
// opening animation (cover right animation) | ||
setTimeout(() =>{ | ||
coverRight.classList.add('turn'); | ||
}, 2100) | ||
|
||
setTimeout(() =>{ | ||
coverRight.style.zIndex = -1; | ||
}, 2800) | ||
|
||
setTimeout(() =>{ | ||
pageLeft.style.zIndex = 20; | ||
}, 3200) | ||
|
||
// opening animation (all page right animation) | ||
pages.forEach((_, index) => { | ||
setTimeout(() => { | ||
reverseIndex(); | ||
pages[pageNumber].classList.remove('turn'); | ||
setTimeout(() => { | ||
reverseIndex(); | ||
pages[pageNumber].style.zIndex = 10 + index; | ||
}, 500) | ||
}, (index + 1) *200 + 2100) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters