UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

47 lines 2.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.shouldAddResizeArea = exports.getOrCreateResizeAreaGroupById = exports.getResizeAreaAttrs = void 0; const tslib_1 = require("tslib"); const g_1 = require("@antv/g"); const constant_1 = require("../../common/constant"); const getResizeAreaAttrs = (options) => { const { type, theme, width: resizeAreaWidth, height: resizeAreaHeight } = options, otherOptions = tslib_1.__rest(options, ["type", "theme", "width", "height"]); const width = type === constant_1.ResizeDirectionType.Horizontal ? theme.size : undefined; const height = type === constant_1.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 }), }; }; exports.getResizeAreaAttrs = getResizeAreaAttrs; 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 g_1.Group({ id, style: { zIndex: constant_1.FRONT_GROUND_GROUP_RESIZE_AREA_Z_INDEX }, }))); }; exports.getOrCreateResizeAreaGroupById = getOrCreateResizeAreaGroupById; 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; }; exports.shouldAddResizeArea = shouldAddResizeArea; //# sourceMappingURL=resize.js.map