generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
130 changed files
with
828 additions
and
291 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
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,50 @@ | ||
export const collapseSection = (element) => { | ||
// Get the height of the element's inner content, regardless of its actual size | ||
const sectionHeight = element.scrollHeight; | ||
|
||
// Temporarily disable all css transitions | ||
const elementTransition = element.style.transition; | ||
element.style.transition = ''; | ||
|
||
/** | ||
* On the next frame (as soon as the previous style change has taken effect), | ||
* explicitly set the element's height to its current pixel height, so we | ||
* aren't transitioning out of 'auto' | ||
*/ | ||
requestAnimationFrame(() => { | ||
element.style.height = `${sectionHeight}px`; | ||
element.style.transition = elementTransition; | ||
|
||
/** | ||
* On the next frame (as soon as the previous style change has taken effect), | ||
* have the element transition to height: 0 | ||
*/ | ||
requestAnimationFrame(() => { | ||
element.style.height = '0px'; | ||
}); | ||
}); | ||
|
||
// Mark the section as "currently collapsed" | ||
element.setAttribute('data-collapsed', 'true'); | ||
}; | ||
|
||
export const expandSection = (element) => { | ||
// Get the height of the element's inner content, regardless of its actual size | ||
const sectionHeight = element.scrollHeight; | ||
|
||
// Have the element transition to the height of its inner content | ||
element.style.height = `${sectionHeight}px`; | ||
|
||
// When the next css transition finishes (which should be the one we just triggered) | ||
element.addEventListener('transitionend', () => { | ||
// Remove this event listener so it only gets triggered once | ||
// eslint-disable-next-line no-caller, no-restricted-properties, no-undef | ||
element.removeEventListener('transitionend', arguments.callee); | ||
|
||
// Remove "height" from the element's inline styles, so it can return to its initial value | ||
element.style.height = null; | ||
}); | ||
|
||
// Mark the section as "currently not collapsed" | ||
element.setAttribute('data-collapsed', 'false'); | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
Oops, something went wrong.