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: set-frozen test case need ScrollManagerService -> SheetSkeletonManagerService

* fix: switch tab sync state in scene and viewport

fix: revert back _updateViewZoom

chore: import SHEET_VIEWPORT_KEY from engine-render
  • Loading branch information
lumixraku committed Jun 6, 2024
1 parent d497b03 commit 97698b8
Show file tree
Hide file tree
Showing 37 changed files with 503 additions and 323 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
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 97698b8

Please sign in to comment.