@univerjs/engine-render v0.5.0-beta.1Docs


Class: Viewport

Constructors

new Viewport()

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

Parameters

ParameterType
viewportKeystring
sceneScene
props?IViewProps

Returns

Viewport

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:251

Properties

PropertyTypeDefault valueDescriptionDefined in
bufferEdgeXnumber0Buffer Area size, default is zeropackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:248
bufferEdgeYnumber0-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:249
onMouseWheel$EventSubject<IWheelEvent>undefined-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:133
onScrollAfter$EventSubject<IScrollObserverParam>undefined-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:135
onScrollByBar$EventSubject<IScrollObserverParam>undefined-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:141
onScrollEnd$EventSubject<IScrollObserverParam>undefined-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:139
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:105
scrollYnumber0-packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:106

Accessors

_deltaScrollX

Get Signature

get _deltaScrollX(): number
Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:421


_deltaScrollY

Get Signature

get _deltaScrollY(): number
Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:425


_deltaViewportScrollX

Get Signature

get _deltaViewportScrollX(): number
Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:429


_deltaViewportScrollY

Get Signature

get _deltaViewportScrollY(): number
Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:433


bottom

Get Signature

get bottom(): number
Returns

number

Set Signature

set bottom(num): void
Parameters
ParameterType
numnumber
Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:324


bottomOrigin

Get Signature

get bottomOrigin(): number
Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:308


cacheBound

Get Signature

get cacheBound(): null | IBoundRectNoAngle
Returns

null | IBoundRectNoAngle

Set Signature

set cacheBound(val): void
Parameters
ParameterType
valnull | IBoundRectNoAngle
Returns

void

Defined in

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


canvas

Get Signature

get canvas(): null | Canvas
Returns

null | Canvas

Defined in

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


height

Get Signature

get height(): Nullable<number>
Returns

Nullable<number>

Set Signature

set height(height): void
Parameters
ParameterType
heightNullable<number>
Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:292


isActive

Get Signature

get isActive(): boolean
Returns

boolean

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:353


isDirty

Get Signature

get isDirty(): boolean
Returns

boolean

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1111


isForceDirty

Get Signature

get isForceDirty(): boolean
Returns

boolean

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1127


isWheelPreventDefaultX

Get Signature

get isWheelPreventDefaultX(): boolean
Returns

boolean

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:332


isWheelPreventDefaultY

Get Signature

get isWheelPreventDefaultY(): boolean
Returns

boolean

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:336


left

Get Signature

get left(): number
Returns

number

Set Signature

set left(num): void
Parameters
ParameterType
numnumber
Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:320


leftOrigin

Get Signature

get leftOrigin(): number
Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:304


preCacheBound

Get Signature

get preCacheBound(): null | IBoundRectNoAngle
Returns

null | IBoundRectNoAngle

Set Signature

set preCacheBound(val): void
Parameters
ParameterType
valnull | IBoundRectNoAngle
Returns

void

Defined in

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


Get Signature

get right(): number
Returns

number

Set Signature

set right(num): void
Parameters
ParameterType
numnumber
Returns

void

Defined in

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


rightOrigin

Get Signature

get rightOrigin(): number
Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:312


scene

Get Signature

get scene(): Scene
Returns

Scene

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:284


top

Get Signature

get top(): number
Returns

number

Set Signature

set top(num): void
Parameters
ParameterType
numnumber
Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:316


topOrigin

Get Signature

get topOrigin(): number
Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:300


viewBound

Get Signature

get viewBound(): IBoundRectNoAngle
Returns

IBoundRectNoAngle

Defined in

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


viewportKey

Get Signature

get viewportKey(): string
Returns

string

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:296


viewportScrollX

Get Signature

get viewportScrollX(): number
Returns

number

Set Signature

set viewportScrollX(val): void
Parameters
ParameterType
valnumber
Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:368


viewportScrollY

Get Signature

get viewportScrollY(): number
Returns

number

Set Signature

set viewportScrollY(val): void
Parameters
ParameterType
valnumber
Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:376


width

Get Signature

get width(): Nullable<number>
Returns

Nullable<number>

Set Signature

set width(w): void
Parameters
ParameterType
wNullable<number>
Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:288

Methods

_limitViewportScroll()

_limitViewportScroll(viewportScrollX, viewportScrollY): ILimitedScrollResult

Still in working progress, do not use it now.

Parameters

ParameterType
viewportScrollXnumber
viewportScrollYnumber

Returns

ILimitedScrollResult

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1087


closeClip()

closeClip(): void

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1024


disable()

disable(): void

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:443


dispose()

dispose(): void

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1028


enable()

enable(): void

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:439


expandBounds()

expandBounds(value): IBoundRectNoAngle

Parameters

ParameterType
valueobject
value.bottomnumber
value.leftnumber
value.rightnumber
value.topnumber

Returns

IBoundRectNoAngle

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1356


getAbsoluteVector()

getAbsoluteVector(coord): Vector2

Parameters

ParameterType
coordVector2

Returns

Vector2

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:930


getBounding()

getBounding(): IViewportInfo

Returns

IViewportInfo

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:913


getScrollBar()

getScrollBar(): Nullable<BaseScrollBar>

Returns

Nullable<BaseScrollBar>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:648


getScrollBarTransForm()

getScrollBarTransForm(): Transform

Returns

Transform

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:684


getViewportScrollByScrollXY()

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

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:633
ynumberpackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:634

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:641


initCacheCanvas()

initCacheCanvas(props?): void

Parameters

ParameterType
props?IViewProps

Returns

void

Defined in

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


isHit()

isHit(coord): boolean

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

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:990


limitedScroll()

limitedScroll(scrollX, scrollY): {
  isLimitedX: false;
  isLimitedY: false;
  scrollX: 0;
  scrollY: 0;
}

Parameters

ParameterType
scrollXNullable<number>
scrollYNullable<number>

Returns

{
  isLimitedX: false;
  isLimitedY: false;
  scrollX: 0;
  scrollY: 0;
}
NameTypeDefault valueDefined in
isLimitedXbooleanfalsepackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1043
isLimitedYbooleanfalsepackages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1044
scrollXnumber0packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1041
scrollYnumber0packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1042

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1038


markDirty()

markDirty(state?): void

Parameters

ParameterType
state?boolean

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1104


markForceDirty()

markForceDirty(state?): void

Parameters

ParameterType
state?boolean

Returns

void

Defined in

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


onMouseWheel()

onMouseWheel(evt, state): void

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

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:945


openClip()

openClip(): void

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1020


pickScrollBar()

pickScrollBar(coord): undefined | null | Rect<IRectProps>

Parameters

ParameterType
coordVector2

Returns

undefined | null | Rect<IRectProps>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1010


removeScrollBar()

removeScrollBar(): void

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:457


render()

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

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

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:711


resetCanvasSizeAndUpdateScroll()

resetCanvasSizeAndUpdateScroll(): void

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:447


resetPadding()

resetPadding(): void

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:490


resetPrevCacheBounds()

resetPrevCacheBounds(): void

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1123


resizeWhenFreezeChange()

resizeWhenFreezeChange(position): void

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

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:471


scrollByBarDeltaValue()

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

Srolling 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: false; isLimitedY: false; scrollX: 0; scrollY: 0; }

isLimited

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:522


scrollByViewportDeltaVal()

scrollByViewportDeltaVal(delta, isTrigger): Nullable<ILimitedScrollResult>

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>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:555


scrollToBarPos()

scrollToBarPos(pos): undefined | {
  isLimitedX: false;
  isLimitedY: false;
  scrollX: 0;
  scrollY: 0;
}

ScrollBar scroll to certain position.

Parameters

ParameterTypeDescription
posPartial<IScrollBarPosition>position of scrollBar

Returns

undefined | { isLimitedX: false; isLimitedY: false; scrollX: 0; scrollY: 0; }

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:512


scrollToViewportPos()

scrollToViewportPos(pos, isTrigger): Nullable<ILimitedScrollResult>

Viewport scroll to certain position.

Parameters

ParameterTypeDefault value
posPartial<IViewportScrollPosition>undefined
isTriggerbooleantrue

Returns

Nullable<ILimitedScrollResult>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:534


setPadding()

setPadding(param): void

Parameters

ParameterType
paramIPosition

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:480


setScrollBar()

setScrollBar(instance): void

Parameters

ParameterType
instanceBaseScrollBar

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:452


shouldIntoRender()

shouldIntoRender(): boolean

Returns

boolean

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:692


transformVector2SceneCoord()

transformVector2SceneCoord(vec): Vector2

convert vector to scene coordinate, include row & col

Parameters

ParameterType
vecVector2

Returns

Vector2

Vector2

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:922


transScroll2ViewportScrollValue()

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

Parameters

ParameterType
scrollXnumber
scrollYnumber

Returns

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

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:590


transViewportScroll2ScrollValue()

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

Parameters

ParameterType
viewportScrollXnumber
viewportScrollYnumber

Returns

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

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:564


updatePrevCacheBounds()

updatePrevCacheBounds(viewBound?): void

Parameters

ParameterType
viewBound?IBoundRectNoAngle

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1368


updateScrollVal()

updateScrollVal(current): Viewport

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 wierd, viewportMain did not call it, now only called in freeze situation.

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:658