-
Notifications
You must be signed in to change notification settings - Fork 34
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 #140 from 10play/add-dynamic-height
Add dynamic height
- Loading branch information
Showing
11 changed files
with
188 additions
and
25 deletions.
There are no files selected for viewing
118 changes: 96 additions & 22 deletions
118
example/src/Examples/Advanced/editor-web/build/editorHtml.ts
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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,40 @@ | ||
// For some reason on expo, this file is parsed on native, and then we get an error | ||
import { isExpo } from '../utils/misc'; | ||
|
||
class ContentHeightListener { | ||
public connected = false; | ||
private resizeObserver: ResizeObserver | null = null; | ||
private currentHeight: number | null = null; | ||
|
||
public connect(element: Element, cb: (height: number) => void) { | ||
this.connected = true; | ||
this.currentHeight = element.getBoundingClientRect().height; | ||
cb(this.currentHeight); | ||
|
||
this.resizeObserver = new ResizeObserver((entries) => { | ||
for (let entry of entries) { | ||
const newHeight = entry.target.getBoundingClientRect().height; | ||
if (this.currentHeight !== newHeight) { | ||
this.currentHeight = newHeight; | ||
cb(newHeight); | ||
} | ||
} | ||
}); | ||
|
||
this.resizeObserver.observe(element); | ||
} | ||
|
||
public disconnect() { | ||
this.resizeObserver?.disconnect(); | ||
} | ||
|
||
public get height() { | ||
return this.currentHeight; | ||
} | ||
} | ||
|
||
// when bundling because "document" does not exist. This is a hack to "shim" focusListener on expo | ||
const shimmedHeightListener = { height: 0, connect: () => {}, connected: true }; | ||
export const contentHeightListener = isExpo() | ||
? shimmedHeightListener | ||
: new ContentHeightListener(); |
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