@univerjs/engine-render v0.5.4


Class: Viewport

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:112

Constructors

new Viewport()

new Viewport(
   viewportKey, 
   scene, 
   props?): Viewport

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:229

Parameters

ParameterType
viewportKeystring
sceneScene
props?IViewProps

Returns

Viewport

Properties

PropertyTypeDefault valueDescriptionDefined in
bufferEdgeXnumber0Buffer Area size, default is zeropackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:226
bufferEdgeYnumber0-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:227
onMouseWheel$EventSubject<IWheelEvent>undefined-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:147
onResized$Subject<IViewportReSizeParam>undefined-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:151
onScrollAfter$EventSubject<IScrollObserverParam>undefined-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:148
onScrollByBar$EventSubject<IScrollObserverParam>undefined-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:150
onScrollEnd$EventSubject<IScrollObserverParam>undefined-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:149
scrollXnumber0scrollX means scroll x value for scrollbar in viewMain use getBarScroll to get scrolling value(scrollX, scrollY) for scrollbarpackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:119
scrollYnumber0-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:120

Accessors

_deltaScrollX

Get Signature

get _deltaScrollX(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:396

Returns

number


_deltaScrollY

Get Signature

get _deltaScrollY(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:400

Returns

number


_deltaViewportScrollX

Get Signature

get _deltaViewportScrollX(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:404

Returns

number


_deltaViewportScrollY

Get Signature

get _deltaViewportScrollY(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:408

Returns

number


bottom

Get Signature

get bottom(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:299

Returns

number

Set Signature

set bottom(num): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:365

Parameters
ParameterType
numnumber
Returns

void


bottomOrigin

Get Signature

get bottomOrigin(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:283

Returns

number


cacheBound

Get Signature

get cacheBound(): null | IBoundRectNoAngle

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:379

Returns

null | IBoundRectNoAngle

Set Signature

set cacheBound(val): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:383

Parameters
ParameterType
valnull | IBoundRectNoAngle
Returns

void


canvas

Get Signature

get canvas(): null | Canvas

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:412

Returns

null | Canvas


height

Get Signature

get height(): Nullable<number>

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:267

Returns

Nullable<number>

Set Signature

set height(height): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:319

Parameters
ParameterType
heightNullable<number>
Returns

void


isActive

Get Signature

get isActive(): boolean

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:328

Returns

boolean


isDirty

Get Signature

get isDirty(): boolean

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1100

Returns

boolean


isForceDirty

Get Signature

get isForceDirty(): boolean

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1116

Returns

boolean


isWheelPreventDefaultX

Get Signature

get isWheelPreventDefaultX(): boolean

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:307

Returns

boolean


isWheelPreventDefaultY

Get Signature

get isWheelPreventDefaultY(): boolean

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:311

Returns

boolean


left

Get Signature

get left(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:295

Returns

number

Set Signature

set left(num): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:360

Parameters
ParameterType
numnumber
Returns

void


leftOrigin

Get Signature

get leftOrigin(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:279

Returns

number


preCacheBound

Get Signature

get preCacheBound(): null | IBoundRectNoAngle

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:387

Returns

null | IBoundRectNoAngle

Set Signature

set preCacheBound(val): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:391

Parameters
ParameterType
valnull | IBoundRectNoAngle
Returns

void


Get Signature

get right(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:303

Returns

number

Set Signature

set right(num): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:370

Parameters
ParameterType
numnumber
Returns

void


rightOrigin

Get Signature

get rightOrigin(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:287

Returns

number


scene

Get Signature

get scene(): Scene

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:259

Returns

Scene


top

Get Signature

get top(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:291

Returns

number

Set Signature

set top(num): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:355

Parameters
ParameterType
numnumber
Returns

void


topOrigin

Get Signature

get topOrigin(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:275

Returns

number


viewBound

Get Signature

get viewBound(): IBoundRectNoAngle

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:375

Returns

IBoundRectNoAngle


viewportKey

Get Signature

get viewportKey(): string

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:271

Returns

string


viewportScrollX

Get Signature

get viewportScrollX(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:343

Returns

number

Set Signature

set viewportScrollX(val): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:339

Parameters
ParameterType
valnumber
Returns

void


viewportScrollY

Get Signature

get viewportScrollY(): number

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:351

Returns

number

Set Signature

set viewportScrollY(val): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:347

Parameters
ParameterType
valnumber
Returns

void


width

Get Signature

get width(): Nullable<number>

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:263

Returns

Nullable<number>

Set Signature

set width(w): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:315

Parameters
ParameterType
wNullable<number>
Returns

void

Methods

_limitViewportScroll()

_limitViewportScroll(viewportScrollX, viewportScrollY): ILimitedScrollResult

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1076

Still in working progress, do not use it now.

Parameters

ParameterType
viewportScrollXnumber
viewportScrollYnumber

Returns

ILimitedScrollResult


calcViewportInfo()

calcViewportInfo(): IViewportInfo

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:792

Returns

IViewportInfo


closeClip()

closeClip(): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1013

Returns

void


disable()

disable(): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:418

Returns

void


dispose()

dispose(): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1017

Returns

void


enable()

enable(): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:414

Returns

void


expandBounds()

expandBounds(value): IBoundRectNoAngle

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1345

Parameters

ParameterType
value{ bottom: number; left: number; right: number; top: number; }
value.bottomnumber
value.leftnumber
value.rightnumber
value.topnumber

Returns

IBoundRectNoAngle


getAbsoluteVector()

getAbsoluteVector(coord): Vector2

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:919

Parameters

ParameterType
coordVector2

Returns

Vector2


getBounding()

getBounding(): IViewportInfo

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:902

Get viewport info

Returns

IViewportInfo

Deprecated

use calcViewportInfo


getScrollBar()

getScrollBar(): Nullable<BaseScrollBar>

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:633

Returns

Nullable<BaseScrollBar>


getScrollBarTransForm()

getScrollBarTransForm(): Transform

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:669

Returns

Transform


getViewportScrollByScrollXY()

getViewportScrollByScrollXY(): {
  x: number;
  y: number;
}

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:626

get actual scroll value by scrollXY

Returns

{
  x: number;
  y: number;
}
NameTypeDefined in
xnumberpackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:618
ynumberpackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:619

initCacheCanvas()

initCacheCanvas(props?): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:250

Parameters

ParameterType
props?IViewProps

Returns

void


isHit()

isHit(coord): boolean

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:979

Check if coord is in viewport. Coord is relative to canvas (scale is handled in isHit, Just pass in the original coord from event)

Parameters

ParameterType
coordVector2

Returns

boolean

is in viewport


limitedScroll()

limitedScroll(scrollX, scrollY): {
  isLimitedX: boolean;
  isLimitedY: boolean;
  scrollX: number;
  scrollY: number;
}

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1027

Parameters

ParameterType
scrollXNullable<number>
scrollYNullable<number>

Returns

{
  isLimitedX: boolean;
  isLimitedY: boolean;
  scrollX: number;
  scrollY: number;
}
NameTypeDefault valueDefined in
isLimitedXbooleanfalsepackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1032
isLimitedYbooleanfalsepackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1033
scrollXnumber0packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1030
scrollYnumber0packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1031

markDirty()

markDirty(state?): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1093

Parameters

ParameterType
state?boolean

Returns

void


markForceDirty()

markForceDirty(state?): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1105

Parameters

ParameterType
state?boolean

Returns

void


onMouseWheel()

onMouseWheel(evt, state): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:934

At f7140a7c11, only doc need this method. In sheet, wheel event is handled by scroll.render-controller@scene.onMouseWheel$

Parameters

ParameterType
evtIWheelEvent
stateEventState

Returns

void


openClip()

openClip(): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1009

Returns

void


pickScrollBar()

pickScrollBar(coord): undefined | null | Rect

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:999

Parameters

ParameterType
coordVector2

Returns

undefined | null | Rect


removeScrollBar()

removeScrollBar(): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:442

Returns

void


render()

render(
   parentCtx?, 
   objects?, 
   isMaxLayer?): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:696

Render function in each render loop.

Parameters

ParameterTypeDefault valueDescription
parentCtx?UniverRenderingContextundefinedparentCtx is cacheCtx from layer when layer._allowCache is true
objects?BaseObject[][]-
isMaxLayer?booleanfalse-

Returns

void


resetCanvasSizeAndUpdateScroll()

resetCanvasSizeAndUpdateScroll(): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:422

Returns

void


resetPadding()

resetPadding(): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:475

Returns

void


resetPrevCacheBounds()

resetPrevCacheBounds(): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1112

Returns

void


resizeWhenFreezeChange()

resizeWhenFreezeChange(position): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:456

NOT same as resetCanvasSizeAndScrollbar This method is triggered when adjusting the frozen row & col settings, and during initialization, it is not triggered when resizing the window.

Note that the ‘position’ parameter may not always have ‘height’ and ‘width’ properties. For the ‘viewMain’ element, it only has ‘left’, ‘top’, ‘bottom’, and ‘right’ properties. Additionally, ‘this.width’ and ‘this.height’ may also be ‘undefined’. Therefore, you should use the ‘_getViewPortSize’ method to retrieve the width and height.

Parameters

ParameterType
positionIViewPosition

Returns

void


scrollByBarDeltaValue()

scrollByBarDeltaValue(delta, isTrigger): 
  | undefined
  | {
  isLimitedX: boolean;
  isLimitedY: boolean;
  scrollX: number;
  scrollY: number;
}

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:507

Scrolling by current position plus delta. the most common case is triggered by scroll-timer(in sheet)

Parameters

ParameterTypeDefault value
deltaPartial<IScrollBarPosition>undefined
isTriggerbooleantrue

Returns

| undefined | { isLimitedX: boolean; isLimitedY: boolean; scrollX: number; scrollY: number; }

isLimited


scrollByViewportDeltaVal()

scrollByViewportDeltaVal(delta, isTrigger): Nullable<ILimitedScrollResult>

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:540

Scrolling by current position plus delta. if viewport can not scroll(e.g. viewport size is bigger than content size), then return null.

Parameters

ParameterTypeDefault value
deltaIViewportScrollPositionundefined
isTriggerbooleantrue

Returns

Nullable<ILimitedScrollResult>


scrollToBarPos()

scrollToBarPos(pos): 
  | undefined
  | {
  isLimitedX: boolean;
  isLimitedY: boolean;
  scrollX: number;
  scrollY: number;
}

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:497

ScrollBar scroll to certain position.

Parameters

ParameterTypeDescription
posPartial<IScrollBarPosition>position of scrollBar

Returns

| undefined | { isLimitedX: boolean; isLimitedY: boolean; scrollX: number; scrollY: number; }


scrollToViewportPos()

scrollToViewportPos(pos, isTrigger): Nullable<ILimitedScrollResult>

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:519

Viewport scroll to certain position.

Parameters

ParameterTypeDefault value
posPartial<IViewportScrollPosition>undefined
isTriggerbooleantrue

Returns

Nullable<ILimitedScrollResult>


setPadding()

setPadding(param): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:465

Parameters

ParameterType
paramIPosition

Returns

void


setScrollBar()

setScrollBar(instance): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:437

Parameters

ParameterType
instanceBaseScrollBar

Returns

void


shouldIntoRender()

shouldIntoRender(): boolean

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:677

Returns

boolean


transformVector2SceneCoord()

transformVector2SceneCoord(vec): Vector2

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:911

convert vector to scene coordinate, include row & col

Parameters

ParameterType
vecVector2

Returns

Vector2

Vector2


transScroll2ViewportScrollValue()

transScroll2ViewportScrollValue(scrollX, scrollY): {
  x: number;
  y: number;
}

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:575

Parameters

ParameterType
scrollXnumber
scrollYnumber

Returns

{
  x: number;
  y: number;
}
NameTypeDefined in
xnumberpackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:618
ynumberpackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:619

transViewportScroll2ScrollValue()

transViewportScroll2ScrollValue(viewportScrollX, viewportScrollY): {
  x: number;
  y: number;
}

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:549

Parameters

ParameterType
viewportScrollXnumber
viewportScrollYnumber

Returns

{
  x: number;
  y: number;
}
NameTypeDefined in
xnumberpackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:570
ynumberpackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:571

updatePrevCacheBounds()

updatePrevCacheBounds(viewBound?): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1357

Parameters

ParameterType
viewBound?IBoundRectNoAngle

Returns

void


updateScrollVal()

updateScrollVal(current): Viewport

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:643

Just record state of scroll. This method won’t scroll viewport and scrollbar. TODO:

Parameters

ParameterType
currentPartial<IScrollObserverParam>

Returns

Viewport

Viewport

Lumixraku

this method is so wried, viewportMain did not call it, now only called in freeze situation.