Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add scrollLeftTop for sheet snapshot #2348

Merged
merged 4 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading