Skip to content

BlockSuite API Documentation / @blocksuite/blocks / Viewport

Class: Viewport

Constructors

new Viewport(undefined)

new Viewport(): Viewport

Returns

Viewport

Properties

_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:33


viewportUpdated

viewportUpdated: Slot<Object>

Type declaration

center

center: IVec2

zoom

zoom: number

Source

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

Accessors

boundingClientRect

get boundingClientRect(): DOMRect

Returns

DOMRect

Source

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


center

get center(): IPoint

Returns

IPoint

Source

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


centerX

get centerX(): number

Returns

number

Source

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


centerY

get centerY(): number

Returns

number

Source

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


cumulativeParentScale

get cumulativeParentScale(): number

Returns

number

Source

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


height

get height(): number

Returns

number

Source

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


left

get left(): number

Returns

number

Source

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


top

get top(): number

Returns

number

Source

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


translateX

get translateX(): number

Returns

number

Source

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


translateY

get translateY(): number

Returns

number

Source

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


viewportBounds

get viewportBounds(): Bound

Returns

Bound

Source

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


viewportMaxXY

get viewportMaxXY(): Object

Returns

Object

x

x: number

y

y: number

Source

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


viewportMinXY

get viewportMinXY(): Object

Returns

Object

x

x: number

y

y: number

Source

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


viewportX

get viewportX(): number

Returns

number

Source

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


viewportY

get viewportY(): number

Returns

number

Source

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


width

get width(): number

Returns

number

Source

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


zoom

get zoom(): number

Returns

number

Source

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

Methods

applyDeltaCenter()

applyDeltaCenter(deltaX, deltaY): void

Parameters

deltaX: number

deltaY: number

Returns

void

Source

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


dispose()

dispose(): void

Returns

void

Source

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


isInViewport()

isInViewport(bound): boolean

Parameters

bound: Bound

Returns

boolean

Source

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


onResize()

onResize(): void

Returns

void

Source

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


setCenter()

setCenter(centerX, centerY): void

Parameters

centerX: number

centerY: number

Returns

void

Source

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


setContainer()

setContainer(container): void

Parameters

container: HTMLElement

Returns

void

Source

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


setCumulativeParentScale()

setCumulativeParentScale(scale): void

Parameters

scale: number

Returns

void

Source

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


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:254


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:210


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:235


setZoom()

setZoom(zoom, focusPoint?): void

Parameters

zoom: number

focusPoint?: IPoint

Returns

void

Source

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


smoothTranslate()

smoothTranslate(x, y): void

Parameters

x: number

y: number

Returns

void

Source

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


smoothZoom()

smoothZoom(zoom, focusPoint?): void

Parameters

zoom: number

focusPoint?: IPoint

Returns

void

Source

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


sync()

sync(viewport): () => void

Parameters

viewport: Viewport

Returns

Function

Returns

void

Source

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


toModelBound()

toModelBound(bound): Bound

Parameters

bound: Bound

Returns

Bound

Source

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


toModelCoord()

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

Parameters

viewX: number

viewY: number

Returns

[number, number]

Source

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


toViewBound()

toViewBound(bound): Bound

Parameters

bound: Bound

Returns

Bound

Source

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


toViewCoord()

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

Parameters

modelX: number

modelY: number

Returns

[number, number]

Source

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