-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add option to include absolute elements in auto resizer (#901)
* feat: introduce some additional logic for window.updateHeight method in order to count absolute positioned elements. * feat: check for absolute positioned elements with MutationObserver * test: add mocked Array<MutationRecord> to test file * refactor: apply review suggestions Co-authored-by: Andi Pätzold <[email protected]> * refactor: get height based on highest getBoundingClientRect.bottom * refactor: always run observer to store absolute elements * feat: update type definition for startAutoResizer * fix: call updateHeight after checkAbsoluteElements is updated * feat: do not check elements with negative bottom * Update lib/window.ts * fix: code readability * fix: ignore tranformed elements * Revert "fix: ignore tranformed elements" This reverts commit 624e9f3. * fix: do not check for negative bottom * docs: add warning about negative bottom and transformed elements * Update lib/types/window.types.ts Co-authored-by: Andi Pätzold <[email protected]> Co-authored-by: Renato Massao Yonamine <[email protected]> Co-authored-by: Renato Massao Yonamine <[email protected]> Co-authored-by: Andi Pätzold <[email protected]>
- Loading branch information
1 parent
88aa356
commit 0269b00
Showing
4 changed files
with
106 additions
and
20 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 |
---|---|---|
|
@@ -12,3 +12,7 @@ | |
.env | ||
.env.local | ||
.envrc | ||
|
||
# editors | ||
.vscode/ | ||
.idea/ |
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 |
---|---|---|
@@ -1,8 +1,15 @@ | ||
export interface WindowAPI { | ||
/** Sets the iframe height to the given value in pixels or using scrollHeight if value is not passed */ | ||
updateHeight: (height?: number) => void | ||
/** Listens for DOM changes and updates height when the size changes. */ | ||
startAutoResizer: () => void | ||
/** | ||
* Listens for DOM changes and updates height when the size changes. | ||
* | ||
* When passing absoluteElements true, an infinite loop can happen if elements are always rendered below the height of the window. | ||
* e.g. transformed elements or absolute elements with negative bottom | ||
* @param {Object} opts - Options to be passed to auto resize | ||
* @param {Boolean} opts.absoluteElements - Defines if auto resize should consider absolut elements | ||
*/ | ||
startAutoResizer: ({ absoluteElements }?: { absoluteElements?: boolean }) => void | ||
/** Stops resizing the iframe automatically. */ | ||
stopAutoResizer: () => void | ||
} |
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