Skip to content

Commit

Permalink
fix: 增加单元格单双击的判断范围
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 committed Oct 14, 2024
1 parent 5eed119 commit 30999c4
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 25 deletions.
6 changes: 3 additions & 3 deletions packages/s2-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
},
"dependencies": {
"@antv/event-emitter": "^0.1.3",
"@antv/g": "^6.0.12",
"@antv/g-canvas": "^2.0.10",
"@antv/g-lite": "^2.0.8",
"@antv/g": "^6.0.14",
"@antv/g-canvas": "^2.0.15",
"@antv/g-lite": "^2.0.11",
"d3-ease": "^3.0.1",
"d3-interpolate": "^1.3.2",
"d3-timer": "^1.0.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/s2-core/src/facet/base-facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ export abstract class BaseFacet {
event?.preventDefault?.();
}

// 移动端的 prevent 存在于 originalEvent上
// 移动端的 prevent 存在于 originalEvent 上
const mobileEvent = (event as unknown as GraphEvent)?.originalEvent;

if (mobileEvent?.cancelable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ export class DataCellClick extends BaseEvent implements BaseEventImplement {

if (interaction.isSelectedCell(cell)) {
// https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail,使用 detail 属性来判断是否是双击,双击时不触发选择态 reset
if ((event.originalEvent as UIEvent)?.detail === 1) {
if (
event.detail === 1 ||
event.nativeEvent?.detail === 1 ||
event.originalEvent?.detail === 1
) {
interaction.reset();

// https://github.com/antvis/S2/issues/2447
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ export class BaseBrushSelection
};

protected mouseDown(event: CanvasEvent) {
event?.preventDefault?.();

if (this.spreadsheet.interaction.hasIntercepts([InterceptType.CLICK])) {
return;
}
Expand Down
6 changes: 5 additions & 1 deletion packages/s2-core/src/interaction/event-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,11 @@ export class EventController {
}

// 双击的 detail 是 2
if (event.detail === 2) {
if (
event.detail === 2 ||
event.nativeEvent?.detail === 2 ||
event.originalEvent?.detail === 2
) {
this.onCanvasDoubleClick(event);
}
};
Expand Down
6 changes: 3 additions & 3 deletions packages/s2-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
"devDependencies": {
"@ant-design/icons": "^5.3.7",
"@antv/event-emitter": "^0.1.3",
"@antv/g": "^6.0.12",
"@antv/g-plugin-a11y": "^1.0.9",
"@antv/g-plugin-rough-canvas-renderer": "^2.0.11",
"@antv/g": "^6.0.14",
"@antv/g-plugin-a11y": "^1.0.11",
"@antv/g-plugin-rough-canvas-renderer": "^2.0.15",
"@antv/g2": "^5.1.20",
"@antv/s2": "workspace:*",
"@antv/s2-shared": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions packages/s2-react/playground/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ export const s2Options: SheetComponentOptions = {
transformCanvasConfig() {
return {
supportsCSSTransform: true,
supportsPointerEvents: false,
// dblClickSpeed: 500,
// devicePixelRatio: 3,
// cursor: 'crosshair',
Expand Down
153 changes: 137 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 30999c4

Please sign in to comment.