API Reference
@univerjs
@univerjs/engine-render
classes
Viewport

@univerjs/engine-render v0.4.2Docs


Class: Viewport

Constructors

new Viewport()

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

Parameters

ParameterType
viewportKeystring
sceneThinScene
props?IViewProps

Returns

Viewport

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:245 (opens in a new tab)

Properties

PropertyTypeDefault valueDescriptionDefined in
bufferEdgeXnumber0Buffer Area size, default is zerosubmodules/univer/packages/engine-render/src/viewport.ts:242 (opens in a new tab)
bufferEdgeYnumber0-submodules/univer/packages/engine-render/src/viewport.ts:243 (opens in a new tab)
onMouseWheel$EventSubject<IWheelEvent>undefined-submodules/univer/packages/engine-render/src/viewport.ts:127 (opens in a new tab)
onScrollAfter$EventSubject<IScrollObserverParam>undefined-submodules/univer/packages/engine-render/src/viewport.ts:129 (opens in a new tab)
onScrollByBar$EventSubject<IScrollObserverParam>undefined-submodules/univer/packages/engine-render/src/viewport.ts:135 (opens in a new tab)
onScrollEnd$EventSubject<IScrollObserverParam>undefined-submodules/univer/packages/engine-render/src/viewport.ts:133 (opens in a new tab)
scrollXnumber0scrollX means scroll x value for scrollbar in viewMain use getBarScroll to get scrolling value(scrollX, scrollY) for scrollbarsubmodules/univer/packages/engine-render/src/viewport.ts:99 (opens in a new tab)
scrollYnumber0-submodules/univer/packages/engine-render/src/viewport.ts:100 (opens in a new tab)

Accessors

_deltaScrollX

get _deltaScrollX(): number

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:451 (opens in a new tab)


_deltaScrollY

get _deltaScrollY(): number

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:455 (opens in a new tab)


_deltaViewportScrollX

get _deltaViewportScrollX(): number

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:459 (opens in a new tab)


_deltaViewportScrollY

get _deltaViewportScrollY(): number

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:463 (opens in a new tab)


bottom

get bottom(): number
set bottom(num): void

Parameters

ParameterType
numnumber

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:354 (opens in a new tab)


bottomOrigin

get bottomOrigin(): number

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:338 (opens in a new tab)


cacheBound

get cacheBound(): null | IBoundRectNoAngle
set cacheBound(val): void

Parameters

ParameterType
valnull | IBoundRectNoAngle

Returns

null | IBoundRectNoAngle

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:434 (opens in a new tab)


canvas

get canvas(): null | Canvas

Returns

null | Canvas

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:467 (opens in a new tab)


height

get height(): Nullable<number>
set height(height): void

Parameters

ParameterType
heightNullable<number>

Returns

Nullable<number>

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:322 (opens in a new tab)


isActive

get isActive(): boolean

Returns

boolean

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:383 (opens in a new tab)


isDirty

get isDirty(): boolean

Returns

boolean

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1187 (opens in a new tab)


isForceDirty

get isForceDirty(): boolean

Returns

boolean

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1203 (opens in a new tab)


isWheelPreventDefaultX

get isWheelPreventDefaultX(): boolean

Returns

boolean

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:362 (opens in a new tab)


isWheelPreventDefaultY

get isWheelPreventDefaultY(): boolean

Returns

boolean

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:366 (opens in a new tab)


left

get left(): number
set left(num): void

Parameters

ParameterType
numnumber

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:350 (opens in a new tab)


leftOrigin

get leftOrigin(): number

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:334 (opens in a new tab)


preCacheBound

get preCacheBound(): null | IBoundRectNoAngle
set preCacheBound(val): void

Parameters

ParameterType
valnull | IBoundRectNoAngle

Returns

null | IBoundRectNoAngle

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:442 (opens in a new tab)


right

get right(): number
set right(num): void

Parameters

ParameterType
numnumber

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:358 (opens in a new tab)


rightOrigin

get rightOrigin(): number

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:342 (opens in a new tab)


scene

get scene(): ThinScene

Returns

ThinScene

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:314 (opens in a new tab)


top

get top(): number
set top(num): void

Parameters

ParameterType
numnumber

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:346 (opens in a new tab)


topOrigin

get topOrigin(): number

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:330 (opens in a new tab)


viewBound

get viewBound(): IBoundRectNoAngle

Returns

IBoundRectNoAngle

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:430 (opens in a new tab)


viewportKey

get viewportKey(): string

Returns

string

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:326 (opens in a new tab)


viewportScrollX

get viewportScrollX(): number
set viewportScrollX(val): void

Parameters

ParameterType
valnumber

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:398 (opens in a new tab)


viewportScrollY

get viewportScrollY(): number
set viewportScrollY(val): void

Parameters

ParameterType
valnumber

Returns

number

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:406 (opens in a new tab)


width

get width(): Nullable<number>
set width(w): void

Parameters

ParameterType
wNullable<number>

Returns

Nullable<number>

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:318 (opens in a new tab)

Methods

_limitViewportScroll()

_limitViewportScroll(viewportScrollX, viewportScrollY): {
  isLimitedX: boolean;
  isLimitedY: boolean;
  viewportScrollX: number;
  viewportScrollY: number;
}

Still in working progress, do not use it now.

Parameters

ParameterType
viewportScrollXnumber
viewportScrollYnumber

Returns

{
  isLimitedX: boolean;
  isLimitedY: boolean;
  viewportScrollX: number;
  viewportScrollY: number;
}
NameTypeDefined in
isLimitedXbooleansubmodules/univer/packages/engine-render/src/viewport.ts:1175 (opens in a new tab)
isLimitedYbooleansubmodules/univer/packages/engine-render/src/viewport.ts:1176 (opens in a new tab)
viewportScrollXnumbersubmodules/univer/packages/engine-render/src/viewport.ts:1173 (opens in a new tab)
viewportScrollYnumbersubmodules/univer/packages/engine-render/src/viewport.ts:1174 (opens in a new tab)

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1163 (opens in a new tab)


_testDisplayCache()

_testDisplayCache(): void

test

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:282 (opens in a new tab)


closeClip()

closeClip(): void

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1099 (opens in a new tab)


disable()

disable(): void

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:473 (opens in a new tab)


dispose()

dispose(): void

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1103 (opens in a new tab)


enable()

enable(): void

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:469 (opens in a new tab)


expandBounds()

expandBounds(value): IBoundRectNoAngle

Parameters

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

Returns

IBoundRectNoAngle

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1433 (opens in a new tab)


getAbsoluteVector()

getAbsoluteVector(coord): Vector2

Parameters

ParameterType
coordVector2

Returns

Vector2

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:961 (opens in a new tab)


getBounding()

getBounding(): IViewportInfo

Returns

IViewportInfo

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:944 (opens in a new tab)


getScrollBar()

getScrollBar(): Nullable<BaseScrollBar>

Returns

Nullable<BaseScrollBar>

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:679 (opens in a new tab)


getScrollBarTransForm()

getScrollBarTransForm(): Transform

Returns

Transform

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:715 (opens in a new tab)


getViewportScrollByScrollXY()

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

get actual scroll value by scrollXY

Returns

{
  x: number;
  y: number;
}
NameTypeDefined in
xnumbersubmodules/univer/packages/engine-render/src/viewport.ts:664 (opens in a new tab)
ynumbersubmodules/univer/packages/engine-render/src/viewport.ts:665 (opens in a new tab)

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:672 (opens in a new tab)


initCacheCanvas()

initCacheCanvas(props?): void

Parameters

ParameterType
props?IViewProps

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:269 (opens in a new tab)


isHit()

isHit(coord): undefined | boolean

Parameters

ParameterType
coordVector2

Returns

undefined | boolean

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1065 (opens in a new tab)


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
isLimitedXbooleanfalsesubmodules/univer/packages/engine-render/src/viewport.ts:1118 (opens in a new tab)
isLimitedYbooleanfalsesubmodules/univer/packages/engine-render/src/viewport.ts:1119 (opens in a new tab)
scrollXnumber0submodules/univer/packages/engine-render/src/viewport.ts:1116 (opens in a new tab)
scrollYnumber0submodules/univer/packages/engine-render/src/viewport.ts:1117 (opens in a new tab)

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1113 (opens in a new tab)


markDirty()

markDirty(state?): void

Parameters

ParameterType
state?boolean

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1180 (opens in a new tab)


markForceDirty()

markForceDirty(state?): void

Parameters

ParameterType
state?boolean

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1192 (opens in a new tab)


onMouseWheel()

onMouseWheel(evt, state): void

At f7140a7c11, only doc need this method. In sheet, wheel event is handled by scroll-manager.service@setScrollInfo

Parameters

ParameterType
evtIWheelEvent
stateEventState

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:976 (opens in a new tab)


openClip()

openClip(): void

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1095 (opens in a new tab)


pickScrollBar()

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

Parameters

ParameterType
coordVector2

Returns

undefined | null | Rect<IRectProps>

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1085 (opens in a new tab)


removeScrollBar()

removeScrollBar(): void

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:487 (opens in a new tab)


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

submodules/univer/packages/engine-render/src/viewport.ts:742 (opens in a new tab)


resetCanvasSizeAndUpdateScroll()

resetCanvasSizeAndUpdateScroll(): void

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:477 (opens in a new tab)


resetPadding()

resetPadding(): void

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:527 (opens in a new tab)


resetPrevCacheBounds()

resetPrevCacheBounds(): void

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1199 (opens in a new tab)


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

submodules/univer/packages/engine-render/src/viewport.ts:501 (opens in a new tab)


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

submodules/univer/packages/engine-render/src/viewport.ts:559 (opens in a new tab)


scrollByViewportDeltaVal()

scrollByViewportDeltaVal(delta, isTrigger): undefined | {
  isLimitedX: boolean;
  isLimitedY: boolean;
  viewportScrollX: number;
  viewportScrollY: number;
}

Parameters

ParameterTypeDefault value
deltaIViewportScrollPositionundefined
isTriggerbooleantrue

Returns

undefined | { isLimitedX: boolean; isLimitedY: boolean; viewportScrollX: number; viewportScrollY: number; }

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:586 (opens in a new tab)


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

submodules/univer/packages/engine-render/src/viewport.ts:549 (opens in a new tab)


scrollToViewportPos()

scrollToViewportPos(pos, isTrigger): undefined | {
  isLimitedX: boolean;
  isLimitedY: boolean;
  viewportScrollX: number;
  viewportScrollY: number;
}

Viewport scroll to certain position.

Parameters

ParameterTypeDefault value
posPartial<IViewportScrollPosition>undefined
isTriggerbooleantrue

Returns

undefined | { isLimitedX: boolean; isLimitedY: boolean; viewportScrollX: number; viewportScrollY: number; }

IViewportScrollPosition

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:571 (opens in a new tab)


setPadding()

setPadding(param): void

Parameters

ParameterType
paramIPosition

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:517 (opens in a new tab)


setScrollBar()

setScrollBar(instance): void

Parameters

ParameterType
instanceBaseScrollBar

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:482 (opens in a new tab)


shouldIntoRender()

shouldIntoRender(): boolean

Returns

boolean

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:723 (opens in a new tab)


transScroll2ViewportScrollValue()

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

Parameters

ParameterType
scrollXnumber
scrollYnumber

Returns

{
  x: number;
  y: number;
}
NameTypeDefined in
xnumbersubmodules/univer/packages/engine-render/src/viewport.ts:664 (opens in a new tab)
ynumbersubmodules/univer/packages/engine-render/src/viewport.ts:665 (opens in a new tab)

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:621 (opens in a new tab)


transViewportScroll2ScrollValue()

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

Parameters

ParameterType
viewportScrollXnumber
viewportScrollYnumber

Returns

{
  x: number;
  y: number;
}
NameTypeDefined in
xnumbersubmodules/univer/packages/engine-render/src/viewport.ts:616 (opens in a new tab)
ynumbersubmodules/univer/packages/engine-render/src/viewport.ts:617 (opens in a new tab)

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:595 (opens in a new tab)


transformVector2SceneCoord()

transformVector2SceneCoord(vec): Vector2

convert vector to scene coordinate, include row & col

Parameters

ParameterType
vecVector2

Returns

Vector2

Vector2

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:953 (opens in a new tab)


updatePrevCacheBounds()

updatePrevCacheBounds(viewBound?): void

Parameters

ParameterType
viewBound?IBoundRectNoAngle

Returns

void

Defined in

submodules/univer/packages/engine-render/src/viewport.ts:1445 (opens in a new tab)


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

submodules/univer/packages/engine-render/src/viewport.ts:689 (opens in a new tab)


Copyright © 2021-2024 DreamNum Co,Ltd. All Rights Reserved.