@antv/s2
Version:
effective spreadsheet render core lib
48 lines • 2.03 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PanelBBox = void 0;
const math_1 = require("../../utils/math");
const frame_1 = require("../header/frame");
const base_bbox_1 = require("./base-bbox");
class PanelBBox extends base_bbox_1.BaseBBox {
calculateBBox() {
this.calculateOriginWidth();
this.calculateOriginalHeight();
const { cornerBBox } = this.facet;
const cornerPosition = {
x: (0, math_1.floor)(cornerBBox.maxX),
y: (0, math_1.floor)(cornerBBox.maxY),
};
// splitLine 也应该占位,panelBBox = canvasBBox - cornerBBox - splitLineBBox
this.x = cornerPosition.x + frame_1.Frame.getVerticalBorderWidth(this.spreadsheet);
this.y =
cornerPosition.y + frame_1.Frame.getHorizontalBorderWidth(this.spreadsheet);
this.minX = this.x;
this.minY = this.y;
this.width = this.getPanelWidth();
this.height = this.getPanelHeight();
this.viewportHeight = Math.abs((0, math_1.floor)(Math.min(this.height, this.originalHeight)));
this.viewportWidth = Math.abs((0, math_1.floor)(Math.min(this.width, this.originalWidth)));
this.maxX = this.x + this.viewportWidth;
this.maxY = this.y + this.viewportHeight;
}
calculateOriginalHeight() {
this.originalHeight = this.facet.getRealHeight();
}
calculateOriginWidth() {
this.originalWidth = this.facet.getRealWidth();
}
getPanelWidth() {
const { width: canvasWidth } = this.spreadsheet.options;
const panelWidth = Math.max(0, canvasWidth - this.x);
return panelWidth;
}
getPanelHeight() {
const scrollBarSize = this.spreadsheet.theme.scrollBar.size;
const { height: canvasHeight } = this.spreadsheet.options;
const panelHeight = Math.max(0, canvasHeight - this.y - scrollBarSize);
return panelHeight;
}
}
exports.PanelBBox = PanelBBox;
//# sourceMappingURL=panel-bbox.js.map