Skip to content

BlockSuite API Documentation / @blocksuite/blocks / Viewport

Class: Viewport

Constructors

new Viewport(undefined)

new Viewport(): Viewport

Returns

Viewport

Properties

ZOOM_MAX

ZOOM_MAX: number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:32


ZOOM_MIN

ZOOM_MIN: number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:33


_center

protected _center: IPoint

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:25


_cumulativeParentScale

protected _cumulativeParentScale: number = 1

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:30


_el

protected _el: HTMLElement

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:28


_height

protected _height: number = 0

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:24


_left

protected _left: number = 0

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:21


_rafId

protected _rafId: null | number = null

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:27


_syncFlag

private _syncFlag: boolean = false

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:29


_top

protected _top: number = 0

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:22


_width

protected _width: number = 0

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:23


_zoom

protected _zoom: number = 1.0

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:26


sizeUpdated

sizeUpdated: Slot<object>

Type declaration

height

height: number

left

left: number

top

top: number

width

width: number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:36


viewportUpdated

viewportUpdated: Slot<object>

Type declaration

center

center: IVec2

zoom

zoom: number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:35

Accessors

boundingClientRect

get boundingClientRect(): DOMRect

Returns

DOMRect

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:122


center

get center(): IPoint

Returns

IPoint

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:67


centerX

get centerX(): number

Returns

number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:59


centerY

get centerY(): number

Returns

number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:63


cumulativeParentScale

get cumulativeParentScale(): number

Returns

number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:75


height

get height(): number

Returns

number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:55


left

get left(): number

Returns

number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:43


top

get top(): number

Returns

number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:47


translateX

get translateX(): number

Returns

number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:89


translateY

get translateY(): number

Returns

number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:93


viewportBounds

get viewportBounds(): Bound

Returns

Bound

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:113


viewportMaxXY

get viewportMaxXY(): object

Returns

object

x

x: number

y

y: number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:105


viewportMinXY

get viewportMinXY(): object

Returns

object

x

x: number

y

y: number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:97


viewportX

get viewportX(): number

Returns

number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:79


viewportY

get viewportY(): number

Returns

number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:84


width

get width(): number

Returns

number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:51


zoom

get zoom(): number

Returns

number

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:71

Methods

applyDeltaCenter()

applyDeltaCenter(deltaX, deltaY): void

Parameters

deltaX: number

deltaY: number

Returns

void

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:201


dispose()

dispose(): void

Returns

void

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:350


isInViewport()

isInViewport(bound): boolean

Parameters

bound: Bound

Returns

boolean

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:205


onResize()

onResize(): void

Returns

void

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:126


setCenter()

setCenter(centerX, centerY): void

Parameters

centerX: number

centerY: number

Returns

void

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:170


setContainer()

setContainer(container): void

Parameters

container: HTMLElement

Returns

void

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:138


setCumulativeParentScale()

setCumulativeParentScale(scale): void

Parameters

scale: number

Returns

void

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:197


setRect()

setRect(left, top, width, height): void

Parameters

left: number

top: number

width: number

height: number

Returns

void

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:257


setViewport()

setViewport(newZoom, newCenter, smooth): void

Parameters

newZoom: number

newCenter: number[]= undefined

smooth: boolean= false

Returns

void

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:213


setViewportByBound()

setViewportByBound(bound, padding, smooth): void

Parameters

bound: Bound

padding: [number, number, number, number]= undefined

smooth: boolean= false

Returns

void

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:238


setZoom()

setZoom(zoom, focusPoint?): void

Parameters

zoom: number

focusPoint?: IPoint

Returns

void

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:179


smoothTranslate()

smoothTranslate(x, y): void

Parameters

x: number

y: number

Returns

void

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:288


smoothZoom()

smoothZoom(zoom, focusPoint?): void

Parameters

zoom: number

focusPoint?: IPoint

Returns

void

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:270


sync()

sync(viewport): () => void

Parameters

viewport: Viewport

Returns

Function

Returns

void

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:311


toModelBound()

toModelBound(bound): Bound

Parameters

bound: Bound

Returns

Bound

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:156


toModelCoord()

toModelCoord(viewX, viewY): [number, number]

Parameters

viewX: number

viewY: number

Returns

[number, number]

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:146


toViewBound()

toViewBound(bound): Bound

Parameters

bound: Bound

Returns

Bound

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:163


toViewCoord()

toViewCoord(modelX, modelY): [number, number]

Parameters

modelX: number

modelY: number

Returns

[number, number]

Source

packages/blocks/src/root-block/edgeless/utils/viewport.ts:151