-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
413 make function to expand to make more of the text readeble when pr…
…essing read more contact us page (#434) * Added expand text functionality to "read more" sections. * Removed test text.
- Loading branch information
Showing
3 changed files
with
71 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
//Expands text when clicking on button: | ||
export function toggleTextOverflow(sectionContainer, textContainer, showMoreBtn) { | ||
showMoreBtn.addEventListener("click", () => { | ||
textContainer.classList.toggle("overflow-auto"); | ||
//Closed | ||
if (textContainer.classList.contains("overflow-auto")) { | ||
textContainer.style.overflow = "auto"; | ||
textContainer.style.maxHeight = ""; | ||
showMoreBtn.textContent = "READ MORE"; | ||
sectionContainer.style.height = "auto"; | ||
} else { //Open | ||
let textContentHeight = textContainer.scrollHeight; | ||
textContainer.style.maxHeight = textContentHeight + "px"; | ||
textContainer.style.overflow = ""; | ||
showMoreBtn.textContent = "READ LESS"; | ||
sectionContainer.style.height = "auto"; | ||
} | ||
}); | ||
} | ||
|
||
|
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,25 @@ | ||
import { toggleTextOverflow } from "./general.mjs"; | ||
|
||
//Makes the specific Id's of the elements as arguments. | ||
function addReadMoreSections(sectionContainerId, textContainerId, showMoreBtnId) { | ||
let sectionContainer = document.getElementById(sectionContainerId); | ||
let textContainer = document.querySelector(textContainerId); | ||
let showMoreBtn = document.querySelector(showMoreBtnId); | ||
toggleTextOverflow(sectionContainer, textContainer, showMoreBtn); | ||
} | ||
|
||
//Add toggleTextOverflow functionality to individual sections: | ||
//Healthcare section | ||
addReadMoreSections("section-container", "#scroll-container-health", "#read-more-btn"); | ||
//Education section | ||
addReadMoreSections("section-container-edu", "#scroll-container-edu", "#read-more-btn-edu"); | ||
// Living situation section | ||
addReadMoreSections("section-container-lisi", "#scroll-container-lisi", "#read-more-btn-lisi"); | ||
//Food Distribution section | ||
addReadMoreSections("section-container-food", "#scroll-container-food", "#read-more-btn-food"); | ||
//Music Lessong section | ||
readMore("section-container-music", "#scroll-container-music", "#read-more-btn-music"); | ||
//Future goals section | ||
addReadMoreSections("section-container-futuregoals", "#scroll-container-futuregoals", "#read-more-btn-futuregoals"); | ||
//Activities section | ||
addReadMoreSections("section-container-activities", "#scroll-container-activities", "#read-more-btn-activities"); |
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