Skip to content

API > @blocksuite/blocks > getViewportElement

Function: getViewportElement ​

getViewportElement(page): null | HTMLDivElement

Get editor viewport element.

Parameters ​

ParameterType
pagePage

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