Skip to content

Commit

Permalink
fix: add comments for set frozen cmd params
Browse files Browse the repository at this point in the history
  • Loading branch information
lumixraku committed Oct 14, 2024
1 parent 5957a04 commit b91f5cc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/sheets-ui/src/commands/commands/set-frozen.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

import type { ICommand } from '@univerjs/core';
import type { ISetFrozenMutationParams } from '@univerjs/sheets';
import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, RANGE_TYPE } from '@univerjs/core';
import { IRenderManagerService } from '@univerjs/engine-render';
import { getSheetCommandTarget, SetFrozenMutation, SetFrozenMutationFactory, SheetsSelectionsService } from '@univerjs/sheets';
import type { ICommand } from '@univerjs/core';

import type { ISetFrozenMutationParams } from '@univerjs/sheets';
import { getSheetCommandTarget, SetFrozenMutation, SetFrozenMutationFactory, SheetsSelectionsService } from '@univerjs/sheets';
import { SheetScrollManagerService } from '../../services/scroll-manager.service';

export enum SetSelectionFrozenType {
Expand Down Expand Up @@ -58,27 +58,27 @@ export const SetSelectionFrozenCommand: ICommand<ISetSelectionFrozenCommandParam
const { sheetViewStartRow = 0, sheetViewStartColumn = 0 } = scrollManagerService.getCurrentScrollState() || {};
let startRow;
let startColumn;
let ySplit;
let xSplit;
let freezedRowCount;
let freezedColCount;
const { startRow: selectRow, startColumn: selectColumn, rangeType } = range;
// Frozen to Row
if (rangeType === RANGE_TYPE.ROW || type === SetSelectionFrozenType.Row) {
startRow = selectRow;
ySplit = selectRow - sheetViewStartRow;
freezedRowCount = selectRow - sheetViewStartRow;
startColumn = -1;
xSplit = 0;
freezedColCount = 0;
// Frozen to Column
} else if (rangeType === RANGE_TYPE.COLUMN || type === SetSelectionFrozenType.Column) {
startRow = -1;
ySplit = 0;
freezedRowCount = 0;
startColumn = selectColumn;
xSplit = selectColumn - sheetViewStartColumn;
freezedColCount = selectColumn - sheetViewStartColumn;
// Frozen to Range
} else if (rangeType === RANGE_TYPE.NORMAL) {
startRow = selectRow;
ySplit = selectRow - sheetViewStartRow;
freezedRowCount = selectRow - sheetViewStartRow;
startColumn = selectColumn;
xSplit = selectColumn - sheetViewStartColumn;
freezedColCount = selectColumn - sheetViewStartColumn;
// Unexpected value
} else {
return false;
Expand All @@ -88,8 +88,8 @@ export const SetSelectionFrozenCommand: ICommand<ISetSelectionFrozenCommandParam
subUnitId,
startRow,
startColumn,
xSplit: startColumn > 0 ? Math.max(1, xSplit) : xSplit,
ySplit: startRow > 0 ? Math.max(1, ySplit) : ySplit,
xSplit: startColumn > 0 ? Math.max(1, freezedColCount) : freezedColCount,
ySplit: startRow > 0 ? Math.max(1, freezedRowCount) : freezedRowCount,
};
const undoMutationParams: ISetFrozenMutationParams = SetFrozenMutationFactory(accessor, redoMutationParams);

Expand Down
8 changes: 8 additions & 0 deletions packages/sheets/src/commands/mutations/set-frozen.mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ export interface ISetFrozenMutationParams {
subUnitId: string;
startRow: number;
startColumn: number;
/**
* Number of frozen rows.
* if row freeze start at 7, end at 10, then ySplit is 3
*/
ySplit: number;
/**
* Number of frozen columns.
* if column freeze start at 7, end at 10, then xSplit is 3
*/
xSplit: number;
resetScroll?: boolean;
}
Expand Down

0 comments on commit b91f5cc

Please sign in to comment.