@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
Parameter | Type |
---|---|
viewportKey | string |
scene | Scene |
props ? | IViewProps |
Returns
Properties
Property | Type | Default value | Description | Defined in |
---|---|---|---|---|
bufferEdgeX | number | 0 | Buffer Area size, default is zero | packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:226 |
bufferEdgeY | number | 0 | - | 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 |
scrollX | number | 0 | scrollX means scroll x value for scrollbar in viewMain use getBarScroll to get scrolling value(scrollX, scrollY) for scrollbar | packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:119 |
scrollY | number | 0 | - | 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
Parameter | Type |
---|---|
num | number |
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
Parameter | Type |
---|---|
val | null | 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
Parameter | Type |
---|---|
height | Nullable <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
Parameter | Type |
---|---|
num | number |
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
Parameter | Type |
---|---|
val | null | IBoundRectNoAngle |
Returns
void
right
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
Parameter | Type |
---|---|
num | number |
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
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
Parameter | Type |
---|---|
num | number |
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
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
Parameter | Type |
---|---|
val | number |
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
Parameter | Type |
---|---|
val | number |
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
Parameter | Type |
---|---|
w | Nullable <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
Parameter | Type |
---|---|
viewportScrollX | number |
viewportScrollY | number |
Returns
ILimitedScrollResult
calcViewportInfo()
calcViewportInfo(): IViewportInfo
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:792
Returns
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
Parameter | Type |
---|---|
value | { bottom : number ; left : number ; right : number ; top : number ; } |
value.bottom | number |
value.left | number |
value.right | number |
value.top | number |
Returns
getAbsoluteVector()
getAbsoluteVector(coord): Vector2
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:919
Parameters
Parameter | Type |
---|---|
coord | Vector2 |
Returns
getBounding()
getBounding(): IViewportInfo
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:902
Get viewport info
Returns
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
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;
}
initCacheCanvas()
initCacheCanvas(props?): void
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:250
Parameters
Parameter | Type |
---|---|
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
Parameter | Type |
---|---|
coord | Vector2 |
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
Parameter | Type |
---|---|
scrollX | Nullable <number > |
scrollY | Nullable <number > |
Returns
{
isLimitedX: boolean;
isLimitedY: boolean;
scrollX: number;
scrollY: number;
}
markDirty()
markDirty(state?): void
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1093
Parameters
Parameter | Type |
---|---|
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
Parameter | Type |
---|---|
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
Parameter | Type |
---|---|
evt | IWheelEvent |
state | EventState |
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
Parameter | Type |
---|---|
coord | Vector2 |
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
Parameter | Type | Default value | Description |
---|---|---|---|
parentCtx ? | UniverRenderingContext | undefined | parentCtx is cacheCtx from layer when layer._allowCache is true |
objects ? | BaseObject [] | [] | - |
isMaxLayer ? | boolean | false | - |
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
Parameter | Type |
---|---|
position | IViewPosition |
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
Parameter | Type | Default value |
---|---|---|
delta | Partial <IScrollBarPosition > | undefined |
isTrigger | boolean | true |
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
Parameter | Type | Default value |
---|---|---|
delta | IViewportScrollPosition | undefined |
isTrigger | boolean | true |
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
Parameter | Type | Description |
---|---|---|
pos | Partial <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
Parameter | Type | Default value |
---|---|---|
pos | Partial <IViewportScrollPosition > | undefined |
isTrigger | boolean | true |
Returns
Nullable
<ILimitedScrollResult
>
setPadding()
setPadding(param): void
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:465
Parameters
Parameter | Type |
---|---|
param | IPosition |
Returns
void
setScrollBar()
setScrollBar(instance): void
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:437
Parameters
Parameter | Type |
---|---|
instance | BaseScrollBar |
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
Parameter | Type |
---|---|
vec | Vector2 |
Returns
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
Parameter | Type |
---|---|
scrollX | number |
scrollY | number |
Returns
{
x: number;
y: number;
}
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
Parameter | Type |
---|---|
viewportScrollX | number |
viewportScrollY | number |
Returns
{
x: number;
y: number;
}
updatePrevCacheBounds()
updatePrevCacheBounds(viewBound?): void
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/viewport.ts:1357
Parameters
Parameter | Type |
---|---|
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
Parameter | Type |
---|---|
current | Partial <IScrollObserverParam > |
Returns
Viewport
Lumixraku
this method is so wried, viewportMain did not call it, now only called in freeze situation.