API > @blocksuite/blocks > getViewportElement
Function: getViewportElement ​
getViewportElement(
page
):null
|HTMLDivElement
Get editor viewport element.
Parameters ​
Parameter | Type |
---|---|
page | Page |
Returns ​
null
| HTMLDivElement
Example ​
ts
const viewportElement = getViewportElement(this.model.page);
if (!viewportElement) return;
this._disposables.addFromEvent(viewportElement, 'scroll', () => {
updatePosition();
});
const viewportElement = getViewportElement(this.model.page);
if (!viewportElement) return;
this._disposables.addFromEvent(viewportElement, 'scroll', () => {
updatePosition();
});
Defined In ​
packages/blocks/src/_common/utils/query.ts:230