diff --git a/packages/s2-core/src/cell/corner-cell.ts b/packages/s2-core/src/cell/corner-cell.ts index 2e387caf0c..55c8331ed8 100644 --- a/packages/s2-core/src/cell/corner-cell.ts +++ b/packages/s2-core/src/cell/corner-cell.ts @@ -24,6 +24,7 @@ import { getResizeAreaAttrs, shouldAddResizeArea, } from '../utils/interaction/resize'; +import { isMobile } from '../utils/is-mobile'; import { HeaderCell } from './header-cell'; export class CornerCell extends HeaderCell { @@ -55,6 +56,19 @@ export class CornerCell extends HeaderCell { this.update(); } + private onTreeIconClick(isCollapsed: boolean) { + if (isMobile()) { + return; + } + + this.emitCollapseEvent(isCollapsed); + } + + private emitCollapseEvent(isCollapsed: boolean) { + this.spreadsheet.facet.resetScrollY(); + this.spreadsheet.emit(S2Event.ROW_CELL_ALL_COLLAPSED__PRIVATE, isCollapsed); + } + /** * 绘制折叠展开的 icon */ @@ -85,13 +99,15 @@ export class CornerCell extends HeaderCell { }, isCollapsed, onClick: () => { - this.spreadsheet.facet.resetScrollY(); - this.spreadsheet.emit( - S2Event.ROW_CELL_ALL_COLLAPSED__PRIVATE, - isCollapsed, - ); + this.onTreeIconClick(isCollapsed); }, }); + // 移动端, 点击热区为整个单元格 + if (isMobile()) { + this.addEventListener('touchend', () => { + this.emitCollapseEvent(isCollapsed); + }); + } } protected isLastRowCornerCell() { diff --git a/packages/s2-core/src/cell/row-cell.ts b/packages/s2-core/src/cell/row-cell.ts index 1fe344d7b0..0acb6d7ae5 100644 --- a/packages/s2-core/src/cell/row-cell.ts +++ b/packages/s2-core/src/cell/row-cell.ts @@ -161,8 +161,8 @@ export class RowCell extends HeaderCell { iconCfg: { x: iconX, y: iconY, - width: size!, - height: size!, + width: size, + height: size, fill, }, isCollapsed, @@ -173,7 +173,7 @@ export class RowCell extends HeaderCell { // 移动端, 点击热区为整个单元格 if (isMobile()) { - this.addEventListener('click', () => { + this.addEventListener('touchend', () => { this.emitCollapseEvent(); }); }