Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] fix: 修复明细表底部存在空白行的问题 (close #2958) #2967

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/s2-core/__tests__/spreadsheet/scroll-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ describe('Scroll Tests', () => {
s2.changeSheetSize(1000, 150); // 纵向滚动条
await s2.render(false);

expect(Math.floor(s2.facet.vScrollBar.getBBox().x)).toEqual(213);
expect(Math.floor(s2.facet.vScrollBar.getBBox().x)).toEqual(218);

s2.setOptions({
interaction: {
Expand Down Expand Up @@ -942,7 +942,7 @@ describe('Scroll Tests', () => {
new MouseEvent('click', {
// 右下角滑道点击
clientX: x + maxX - 2,
clientY: y + maxY + 2,
clientY: y + maxY - scrollbar!.theme!.size! + 2,
} as MouseEventInit),
);

Expand Down Expand Up @@ -974,7 +974,7 @@ describe('Scroll Tests', () => {
await sleep(500);

expect(Math.floor(s2.facet.hScrollBar.thumbOffset)).toBeCloseTo(9);
expect(Math.floor(s2.facet.vScrollBar.thumbOffset)).toBeCloseTo(14);
expect(Math.floor(s2.facet.vScrollBar.thumbOffset)).toBeCloseTo(15);
expect(Math.floor(s2.facet.hRowScrollBar.thumbOffset)).toBeCloseTo(10);
});

Expand All @@ -986,7 +986,7 @@ describe('Scroll Tests', () => {
await sleep(500);

expect(s2.facet.hScrollBar.thumbOffset).toBeCloseTo(0);
expect(Math.floor(s2.facet.vScrollBar.thumbOffset)).toBeCloseTo(20);
expect(Math.floor(s2.facet.vScrollBar.thumbOffset)).toBeCloseTo(17);
});

test('should scroll to cell by id when cell outside of viewport', async () => {
Expand All @@ -1005,7 +1005,7 @@ describe('Scroll Tests', () => {
await sleep(500);

expect(s2.facet.hScrollBar.thumbOffset).toBeCloseTo(0);
expect(Math.floor(s2.facet.vScrollBar.thumbOffset)).toBeCloseTo(20);
expect(Math.floor(s2.facet.vScrollBar.thumbOffset)).toBeCloseTo(17);
});

test('should scroll to node', async () => {
Expand All @@ -1016,7 +1016,7 @@ describe('Scroll Tests', () => {
await sleep(500);

expect(s2.facet.hScrollBar.thumbOffset).toBeCloseTo(49);
expect(Math.floor(s2.facet.vScrollBar.thumbOffset)).toBeCloseTo(20);
expect(Math.floor(s2.facet.vScrollBar.thumbOffset)).toBeCloseTo(17);
});

test('should scroll to top', async () => {
Expand Down Expand Up @@ -1045,7 +1045,7 @@ describe('Scroll Tests', () => {
await sleep(500);

expect(s2.facet.hScrollBar.thumbOffset).toBeCloseTo(0);
expect(Math.floor(s2.facet.vScrollBar.thumbOffset)).toBeCloseTo(20);
expect(Math.floor(s2.facet.vScrollBar.thumbOffset)).toBeCloseTo(17);
});

test('should scroll to right', async () => {
Expand Down
12 changes: 6 additions & 6 deletions packages/s2-core/__tests__/unit/facet/bbox/panel-bbox-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('PanelBBox Tests', () => {
const bbox = new PanelBBox(facet, true);

expect(bbox.width).toBe(578);
expect(bbox.height).toBe(573);
expect(bbox.height).toBe(578);
expect(bbox.viewportWidth).toBe(200);
expect(bbox.viewportHeight).toBe(200);
expect(bbox.maxX).toBe(222);
Expand All @@ -90,11 +90,11 @@ describe('PanelBBox Tests', () => {
const bbox = new PanelBBox(facet, true);

expect(bbox.width).toBe(578);
expect(bbox.height).toBe(573);
expect(bbox.height).toBe(578);
expect(bbox.viewportWidth).toBe(578);
expect(bbox.viewportHeight).toBe(573);
expect(bbox.viewportHeight).toBe(578);
expect(bbox.maxX).toBe(600);
expect(bbox.maxY).toBe(595);
expect(bbox.maxY).toBe(600);
expect(bbox.originalHeight).toBe(2000);
expect(bbox.originalWidth).toBe(2000);
});
Expand All @@ -110,7 +110,7 @@ describe('PanelBBox Tests', () => {
const bbox = new PanelBBox(facet, true);

expect(bbox.width).toBe(578);
expect(bbox.height).toBe(573);
expect(bbox.height).toBe(578);
expect(bbox.viewportWidth).toBe(200);
expect(bbox.viewportHeight).toBe(200);
expect(bbox.maxX).toBe(222);
Expand All @@ -130,7 +130,7 @@ describe('PanelBBox Tests', () => {
const bbox = new PanelBBox(facet, true);

expect(bbox.width).toBe(578);
expect(bbox.height).toBe(573);
expect(bbox.height).toBe(578);
expect(bbox.viewportWidth).toBe(200);
expect(bbox.viewportHeight).toBe(200);
expect(bbox.maxX).toBe(222);
Expand Down
6 changes: 1 addition & 5 deletions packages/s2-core/src/extends/pivot-chart/facet/panel-bbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import { PanelBBox as OriginPanelBBox } from '@antv/s2';

export class PanelBBox extends OriginPanelBBox {
protected override getPanelHeight(): number {
const scrollBarSize = this.spreadsheet.theme.scrollBar!.size;
const { height: canvasHeight } = this.spreadsheet.options;

const { axisColsHierarchy } = this.layoutResult;
const colAxisHeight = axisColsHierarchy?.height ?? 0;

const panelHeight = Math.max(
0,
canvasHeight! - this.y - scrollBarSize! - colAxisHeight,
);
const panelHeight = Math.max(0, canvasHeight! - this.y - colAxisHeight);

return panelHeight;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/s2-core/src/facet/bbox/panel-bbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ export class PanelBBox extends BaseBBox {
}

protected getPanelHeight() {
const scrollBarSize = this.spreadsheet.theme.scrollBar!.size;
const { height: canvasHeight } = this.spreadsheet.options;
const panelHeight = Math.max(0, canvasHeight! - this.y - scrollBarSize!);
const panelHeight = Math.max(0, canvasHeight! - this.y);

return panelHeight;
}
Expand Down
Loading