UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

39 lines 2.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getScrollOffsetForRow = exports.getScrollOffsetForCol = void 0; const lodash_1 = require("lodash"); const common_1 = require("../../common"); const interaction_1 = require("../../common/constant/interaction"); // 获取滚动指定列到视口内的滚动 x 轴 Offset。滚动到视口边缘位置,左侧和右侧视滚动方向而定。 const getScrollOffsetForCol = (colIndex, direction, spreadsheet) => { const { facet } = spreadsheet; const { viewportWidth } = facet.panelBBox; const areas = facet === null || facet === void 0 ? void 0 : facet.frozenGroupAreas; const frozenColWidth = areas[common_1.FrozenGroupArea.Col].width; const frozenTrailingColWidth = areas[common_1.FrozenGroupArea.TrailingCol].width; const colNode = facet.getColLeafNodes()[colIndex]; if (direction === interaction_1.ScrollDirection.SCROLL_UP) { return colNode.x - frozenColWidth; } return colNode.x + colNode.width - (viewportWidth - frozenTrailingColWidth); }; exports.getScrollOffsetForCol = getScrollOffsetForCol; // 获取滚动指定行到视口内的滚动 y 轴 Offset。滚动到视口边缘位置,上侧和下侧视滚动方向而定。 const getScrollOffsetForRow = (rowIndex, direction, spreadsheet) => { const { facet } = spreadsheet; const { getCellOffsetY } = facet.viewCellHeights; const { viewportHeight } = facet.panelBBox; const rowOffset = getCellOffsetY(rowIndex + 1); if ((0, lodash_1.isNil)(rowOffset)) { return 0; } const areas = facet === null || facet === void 0 ? void 0 : facet.frozenGroupAreas; const frozenRowHeight = areas[common_1.FrozenGroupArea.Row].height; const frozenTrailingRowHeight = areas[common_1.FrozenGroupArea.TrailingRow].height; if (direction === interaction_1.ScrollDirection.SCROLL_UP) { return getCellOffsetY(rowIndex) - frozenRowHeight; } return rowOffset - (viewportHeight - frozenTrailingRowHeight); }; exports.getScrollOffsetForRow = getScrollOffsetForRow; //# sourceMappingURL=scroll.js.map