Skip to content

Commit

Permalink
feat: add scrollLeftTop for sheet snapshot (#2348)
Browse files Browse the repository at this point in the history
* feat: add scrollLeftTop for sheet snapshot

fix: build

* fix: set-frozen test case need ScrollManagerService -> SheetSkeletonManagerService

test: failed

* fix: switch tab sync state in scene and viewport

chore: more comments

* chore: more comments2
  • Loading branch information
lumixraku authored Jun 3, 2024
1 parent 54460f9 commit 38d8003
Show file tree
Hide file tree
Showing 29 changed files with 420 additions and 236 deletions.
2 changes: 1 addition & 1 deletion packages/docs-ui/src/controllers/back-scroll.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class BackScrollController extends RxDisposable {
offsetX = left - boundRight + ANCHOR_WIDTH;
}

const config = viewportMain.getBarScroll(offsetX, offsetY);
const config = viewportMain.transViewportScroll2ScrollValue(offsetX, offsetY);
viewportMain.scrollBy(config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class DocEditorBridgeController extends Disposable {
if (scrollBar == null) {
viewportMain && new ScrollBar(viewportMain, { enableHorizontal: false, barSize: 8 });
} else {
viewportMain?.resetSizeAndScrollBar();
viewportMain?.resetCanvasSizeAndUpdateScrollBar();
}
} else {
scrollBar = null;
Expand All @@ -132,7 +132,7 @@ export class DocEditorBridgeController extends Disposable {
if (scrollBar == null) {
viewportMain && new ScrollBar(viewportMain, { barSize: 8, enableVertical: false });
} else {
viewportMain?.resetSizeAndScrollBar();
viewportMain?.resetCanvasSizeAndUpdateScrollBar();
}
} else {
scrollBar = null;
Expand Down
2 changes: 1 addition & 1 deletion packages/docs-ui/src/controllers/zoom.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class ZoomController extends Disposable {

const viewport = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
if (scrollToX !== Number.POSITIVE_INFINITY && viewport != null) {
const actualX = viewport.getBarScroll(scrollToX, 0).x;
const actualX = viewport.transViewportScroll2ScrollValue(scrollToX, 0).x;
viewport.scrollTo({
x: actualX,
});
Expand Down
6 changes: 4 additions & 2 deletions packages/engine-render/src/basics/scroll-xy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
* limitations under the License.
*/

import type { Viewport } from '../viewport';

export function getCurrentScrollXY(scrollTimer: any) {
const scene = scrollTimer.getScene();
const viewport = scrollTimer.getViewportByCoord(scene);
const viewport = scrollTimer.getViewportByCoord(scene) as Viewport;
const scrollX = 0;
const scrollY = 0;
if (!viewport) {
Expand All @@ -25,7 +27,7 @@ export function getCurrentScrollXY(scrollTimer: any) {
scrollY,
};
}
const actualScroll = viewport.getActualScroll(viewport.scrollX, viewport.scrollY);
const actualScroll = viewport.transScroll2ViewportScrollValue(viewport.scrollX, viewport.scrollY);
return {
scrollX: actualScroll.x,
scrollY: actualScroll.y,
Expand Down
20 changes: 10 additions & 10 deletions packages/engine-render/src/components/sheets/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ export enum ShowGridlinesState {
}

export enum SHEET_VIEWPORT_KEY {
VIEW_MAIN = 'viewMain',
VIEW_MAIN_LEFT_TOP = 'viewMainLeftTop',
VIEW_MAIN_TOP = 'viewMainTop',
VIEW_MAIN_LEFT = 'viewMainLeft',

VIEW_ROW_TOP = 'viewRowTop',
VIEW_ROW_BOTTOM = 'viewRowBottom',
VIEW_COLUMN_LEFT = 'viewColumnLeft',
VIEW_COLUMN_RIGHT = 'viewColumnRight',
VIEW_LEFT_TOP = 'viewLeftTop',
VIEW_MAIN = 'sheetViewMain',
VIEW_MAIN_LEFT_TOP = 'sheetViewMainLeftTop',
VIEW_MAIN_TOP = 'sheetViewMainTop',
VIEW_MAIN_LEFT = 'sheetViewMainLeft',

VIEW_ROW_TOP = 'sheetViewRowTop',
VIEW_ROW_BOTTOM = 'sheetViewRowBottom',
VIEW_COLUMN_LEFT = 'sheetViewColumnLeft',
VIEW_COLUMN_RIGHT = 'sheetViewColumnRight',
VIEW_LEFT_TOP = 'sheetViewLeftTop',
}

export interface IPaintForRefresh {
Expand Down
4 changes: 0 additions & 4 deletions packages/engine-render/src/components/sheets/spreadsheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,6 @@ export class Spreadsheet extends SheetComponent {
const spreadsheetSkeleton = this.getSkeleton()!;
const { rowHeaderWidth, columnHeaderHeight } = spreadsheetSkeleton;
const { left, top, right, bottom } = cacheBound;
// left -= rowHeaderWidth;
// top -= columnHeaderHeight;
// right -= rowHeaderWidth;
// bottom -= columnHeaderHeight;
const findClosestHundred = (number: number) => {
const remainder = number % 100;
return number + (100 - remainder);
Expand Down
2 changes: 1 addition & 1 deletion packages/engine-render/src/scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ export class Scene extends ThinScene {

this.transform = composeResult;
this.getViewports().forEach((vp: Viewport) => {
vp.resetSizeAndScrollBar();
vp.resetCanvasSizeAndUpdateScrollBar();
});
this.makeDirty(true);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/engine-render/src/scroll-timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class ScrollTimer {
y,
});

const actualScroll = viewport?.getActualScroll(x, y);
const actualScroll = viewport?.transScroll2ViewportScrollValue(x, y);

this._scrollX = actualScroll?.x || 0;
this._scrollY = actualScroll?.y || 0;
Expand Down
Loading

0 comments on commit 38d8003

Please sign in to comment.