UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

41 lines 2.08 kB
import { __rest } from "tslib"; import { Group } from '@antv/g'; import { FRONT_GROUND_GROUP_RESIZE_AREA_Z_INDEX, ResizeDirectionType, } from '../../common/constant'; export const getResizeAreaAttrs = (options) => { const { type, theme, width: resizeAreaWidth, height: resizeAreaHeight } = options, otherOptions = __rest(options, ["type", "theme", "width", "height"]); const width = type === ResizeDirectionType.Horizontal ? theme.size : undefined; const height = type === ResizeDirectionType.Vertical ? theme.size : undefined; return { style: { fill: theme.background, fillOpacity: theme.backgroundOpacity, cursor: `${type}-resize`, width: width, height: height, }, appendInfo: Object.assign(Object.assign({}, otherOptions), { isResizeArea: true, type, width: resizeAreaWidth, height: resizeAreaHeight, size: theme.size }), }; }; export const getOrCreateResizeAreaGroupById = (spreadsheet, id) => { var _a; if (!((_a = spreadsheet.facet) === null || _a === void 0 ? void 0 : _a.foregroundGroup)) { return; } const existedResizeArea = spreadsheet.facet.foregroundGroup.getElementById(id); return (existedResizeArea || spreadsheet.facet.foregroundGroup.appendChild(new Group({ id, style: { zIndex: FRONT_GROUND_GROUP_RESIZE_AREA_Z_INDEX }, }))); }; export const shouldAddResizeArea = (resizeArea, resizeClipArea, scrollOffset) => { const { scrollX = 0, scrollY = 0 } = scrollOffset !== null && scrollOffset !== void 0 ? scrollOffset : {}; // x轴上有重叠 const overlapInXAxis = !(resizeArea.x - scrollX > resizeClipArea.x + resizeClipArea.width || resizeArea.x + resizeArea.width - scrollX < resizeClipArea.x); // y轴上有重叠 const overlapInYAxis = !(resizeArea.y - scrollY > resizeClipArea.y + resizeClipArea.height || resizeArea.y + resizeArea.height - scrollY < resizeClipArea.y); return overlapInXAxis && overlapInYAxis; }; //# sourceMappingURL=resize.js.map