Skip to content

Commit

Permalink
fix: 解决移动端下,树形结构展开、收起交互失效的问题 (#3039)
Browse files Browse the repository at this point in the history
* fix: 解决移动端下,树形结构展开、收起交互失效的问题。

* fix: 解决移动端下,树形结构展开、收起交互失效的问题

* fix: 解决移动端下,树形结构展开、收起交互失效的问题

* fix: 解决移动端下,树形结构展开、收起交互失效的问题

---------

Co-authored-by: gongbei <[email protected]>
Co-authored-by: Jinke Li <[email protected]>
  • Loading branch information
3 people authored Dec 13, 2024
1 parent 001573f commit a97625c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
26 changes: 21 additions & 5 deletions packages/s2-core/src/cell/corner-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CornerHeaderConfig> {
Expand Down Expand Up @@ -55,6 +56,19 @@ export class CornerCell extends HeaderCell<CornerHeaderConfig> {
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
*/
Expand Down Expand Up @@ -85,13 +99,15 @@ export class CornerCell extends HeaderCell<CornerHeaderConfig> {
},
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() {
Expand Down
6 changes: 3 additions & 3 deletions packages/s2-core/src/cell/row-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ export class RowCell extends HeaderCell<RowHeaderConfig> {
iconCfg: {
x: iconX,
y: iconY,
width: size!,
height: size!,
width: size,
height: size,
fill,
},
isCollapsed,
Expand All @@ -173,7 +173,7 @@ export class RowCell extends HeaderCell<RowHeaderConfig> {

// 移动端, 点击热区为整个单元格
if (isMobile()) {
this.addEventListener('click', () => {
this.addEventListener('touchend', () => {
this.emitCollapseEvent();
});
}
Expand Down

0 comments on commit a97625c

Please sign in to comment.