-
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.
Merge pull request #5 from DO-SOPT-WEB/week2-picbooth
[1μ£Όμ°¨ μ¬ν + 2μ£Όμ°¨ κΈ°λ³Έ/μ¬ν/μκ°] λ€νμ΄μ μ¬μ§κ΄
- Loading branch information
Showing
4 changed files
with
309 additions
and
50 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,70 @@ | ||
const topButton = document.querySelector(".top-button"); | ||
|
||
// νμ΄μ§λ₯Ό μ€ν¬λ‘€ν λ μ΄λ²€νΈλ₯Ό μμ νμ¬ Top λ²νΌμ λΆν¬λͺ λλ₯Ό μ‘°μ ν©λλ€. | ||
window.addEventListener("scroll", () => { | ||
const scrollPosition = window.scrollY; | ||
const opacity = Math.min(1, scrollPosition / 300); // μ€ν¬λ‘€ μμΉμ λ°λΌ λΆν¬λͺ λλ₯Ό μ‘°μ | ||
topButton.style.opacity = opacity.toString(); | ||
}); | ||
|
||
// Top λ²νΌμ ν΄λ¦ν λ νμ΄μ§ μλ¨μΌλ‘ μ€ν¬λ‘€ν©λλ€. | ||
topButton.addEventListener("click", () => { | ||
window.scrollTo({ top: 0, behavior: "smooth" }); | ||
}); | ||
|
||
const allEachElements = document.querySelectorAll(".each"); | ||
|
||
allEachElements.forEach((each) => { | ||
const hoverText = each.querySelector(".hover-text"); | ||
|
||
hoverText.style.opacity = "0"; | ||
each.addEventListener("mouseenter", () => { | ||
hoverText.style.opacity = "1"; | ||
}); | ||
|
||
each.addEventListener("mouseleave", () => { | ||
hoverText.style.opacity = "0"; | ||
}); | ||
}); | ||
//eachμμ νΈλ² | ||
//νΈλ²μμ λ보기 | ||
|
||
// μ νμλ₯Ό μ¬μ©νμ¬ λͺ¨λ λ보기 λ²νΌμ κ°μ Έμ΅λλ€. | ||
const moreButtons = document.querySelectorAll(".more-button"); | ||
|
||
// λͺ¨λ λ보기 λ²νΌμ λν μ΄λ²€νΈ νΈλ€λ¬λ₯Ό λ±λ‘ν©λλ€. | ||
moreButtons.forEach((moreButton) => { | ||
moreButton.addEventListener("click", function () { | ||
// νμ¬ ν΄λ¦λ λ보기 λ²νΌμ λΆλͺ¨ μμλ₯Ό μ°Ύμ΅λλ€. | ||
const parent = this.parentElement; | ||
|
||
// λΆλͺ¨ μμμμ ν΄λΉ p μμλ₯Ό μ°Ύμ΅λλ€. | ||
const textElement = parent.querySelector("p:nth-child(2)"); | ||
|
||
// λ§μ€μνλ₯Ό μ κ±°νκ³ μ 체 ν μ€νΈλ₯Ό νμν©λλ€. | ||
textElement.style.overflow = "initial"; | ||
textElement.style.whiteSpace = "initial"; | ||
textElement.style.textOverflow = "initial"; | ||
textElement.style.webkitLineClamp = "initial"; | ||
textElement.style.wordBreak = "initial"; | ||
|
||
// λ보기 λ²νΌμ μ¨κΉλλ€. | ||
this.style.display = "none"; | ||
}); | ||
}); | ||
|
||
const imgPreview = document.querySelector(".img-preview"); | ||
const scrollLeft = document.querySelector(".scroll-left"); | ||
const scrollRight = document.querySelector(".scroll-right"); | ||
|
||
// μ€ν¬λ‘€ μΌμͺ½ λ²νΌμ ν΄λ¦νμ λ μ€νλλ ν¨μ | ||
scrollLeft.addEventListener("click", () => { | ||
// κ°μ₯ μΌμͺ½ μ΄λ―Έμ§λ‘ μ€ν¬λ‘€ | ||
imgPreview.scrollLeft = 0; | ||
}); | ||
|
||
// μ€ν¬λ‘€ μ€λ₯Έμͺ½ λ²νΌμ ν΄λ¦νμ λ μ€νλλ ν¨μ | ||
scrollRight.addEventListener("click", () => { | ||
// κ°μ₯ μ€λ₯Έμͺ½ μ΄λ―Έμ§λ‘ μ€ν¬λ‘€ | ||
imgPreview.scrollLeft = imgPreview.scrollWidth; | ||
}); |
Oops, something went wrong.