Skip to content

Commit

Permalink
Merge branch 'next' into fix-2957
Browse files Browse the repository at this point in the history
  • Loading branch information
wjgogogo authored Nov 8, 2024
2 parents 144b437 + 12be6b5 commit 39561c3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/s2-core/src/sheet-type/spread-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export abstract class SpreadSheet extends EE {
/**
* 表格是否已销毁
*/
private destroyed = false;
public destroyed = false;

protected abstract bindEvents(): void;

Expand Down
8 changes: 8 additions & 0 deletions packages/s2-core/src/ui/hd-adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export class HdAdapter {
private renderByDevicePixelRatio = async (
ratio = window.devicePixelRatio,
) => {
if (this.spreadsheet.destroyed) {
return;
}

const {
container,
options: { width, height },
Expand All @@ -130,6 +134,10 @@ export class HdAdapter {
};

private renderByZoomScale = debounce(async (event: Event) => {
if (this.spreadsheet.destroyed) {
return;
}

const target = event.target as VisualViewport;
const ratio = Math.ceil(target?.scale);

Expand Down
10 changes: 7 additions & 3 deletions s2-site/docs/api/basic-class/spreadsheet.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ s2.isPivotMode()

| 参数 | 说明 | 类型 | 版本 |
| --- |------------------------------------------------------------------------------------------------------------------------| --- |----|
| dom | 挂载的容器节点 | `string` \| `HTMLElement` | |
| themeName | 主题名 | [ThemeName](/api/general/s2-theme#themename) | |
| theme | 主题配置 | [S2Theme](/docs/api/general/S2Theme) | |
| store | 存储的一些信息 | [Store](/docs/api/basic-class/store) | |
| dataCfg | 数据配置 | [S2DataConfig](/docs/api/general/S2DataConfig) | |
Expand All @@ -24,11 +24,15 @@ s2.isPivotMode()
| tooltip | 提示信息 | [BaseTooltip](/docs/api/basic-class/base-tooltip) | |
| container | g-canvas 实例 | [Canvas](https://g.antv.antgroup.com/api/renderer/canvas) | |
| interaction | 交互 | [Interaction](/zh/docs/api/basic-class/interaction) | |
| hd | 开启高清适配 | [HdAdapter](https://github.com/antvis/S2/blob/next/packages/s2-core/src/ui/hd-adapter/index.ts) | |
| hdAdapter | 高清适配器 | [HdAdapter](https://github.com/antvis/S2/blob/next/packages/s2-core/src/ui/hd-adapter/index.ts) | |
| destroyed | 表格是否已销毁 | `boolean` | |
| on | 事件订阅 | (event: [S2Event](/docs/manual/advanced/interaction/basic), listener: () => void) => void | |
| emit | 事件发布 | (event: [S2Event](/docs/manual/advanced/interaction/basic), ...args: any[]) => void | |
| getDataSet | 获取数据集 | (options: [S2Options](/docs/api/general/S2Options)) => [BaseDataSet](/docs/api/basic-class/base-data-set) | |
| isPivotMode | 是否是透视表 | `() => boolean` | |
| isCustomRowFields | 是否是自定义行头维值 | `() => boolean` | |
| isCustomColumnFields | 是否是自定义列头维值 | `() => boolean` | |
| isCustomHeaderFields | 是否是自定义表头维值 | `() => boolean` | |
| isHierarchyTreeType | 是否是树状结构 | `() => boolean` | |
| isFrozenRowHeader | 是否是冻结行头状态 | `() => boolean` | |
| isTableMode | 是否是明细表 | `() => boolean` | |
Expand All @@ -48,7 +52,7 @@ s2.isPivotMode()
| setThemeCfg | 更新主题配置 (含主题 schema, 色板,主题名) | (themeCfg: [ThemeCfg](/docs/api/general/S2Theme/#themecfg)) => void | |
| setTheme | 更新主题 (只包含主题 scheme) | (theme: [S2Theme](/docs/api/general/S2Theme/#s2theme)) => void | |
| getTheme | 获取主题 (只包含主题 scheme) | ( ) => [S2Theme](/docs/api/general/S2Theme/#s2theme) | |
| getThemeName | 获取主题名 | ( ) => `default \| colorful \| gray \| dark` | |
| getThemeName | 获取主题名 | () => [ThemeName](/api/general/s2-theme#themename) | |
| updatePagination | 更新分页 | (pagination: [Pagination](/docs/api/general/S2Options#pagination)) => void | |
| changeSheetSize | 修改表格画布大小,不用重新加载数据 | `(width?: number, height?: number) => void` | |
| getLayoutWidthType | 获取单元格宽度布局类型(LayoutWidthType: `adaptive(自适应)` \| `colAdaptive(列自适应)` \| `compact(紧凑)`| () => `LayoutWidthType`| |
Expand Down
19 changes: 15 additions & 4 deletions s2-site/docs/api/general/S2Theme.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,28 @@ s2.setTheme({

功能描述:表格主题配置项。查看 [文档](/manual/basic/theme)[示例](/examples/theme/default/#colorful)

| 参数 | 参数 | 类型 | 默认值 | 必选 |
| 参数 | 说明 | 类型 | 默认值 | 必选 |
| ------- | ----------- | --------------------------------- | --------- | ---- |
| theme | 主题 schema | [S2Theme](#s2theme) | - | |
| palette | 色板 | [Palette](#palette) | - | |
| name | 主题名 | `default` \| `colorful` \| `gray` | `default` | |
| name | 主题名 | [ThemeName](#themename) | `default` | |

### ThemeName

功能描述:表格主题名称。查看 [文档](/manual/basic/theme)[示例](/examples/theme/default/#colorful)

| 参数 | 说明 | 类型 | 默认值 | 必选 |
| ---- | -------------- | ---------------------- | ------ | ---- |
| default | 默认 | `string` | - | |
| colorful | 多彩蓝 | `string` | - | |
| gray | 简约灰 | `string` | - | |
| dark | 暗黑 | `string` | - | |

### Palette

功能描述:表主题色板。查看 [文档](/manual/basic/theme)[示例](/examples/theme/custom/#custom-palette)

| 参数 | 参数 | 类型 | 默认值 | 必选 |
| 参数 | 说明 | 类型 | 默认值 | 必选 |
| ------------------- | --------------------------------------------------- | ---------------------------------------------------------------- | ------ | ---- |
| brandColor | 色板主题色 | `string` | - ||
| basicColors | 基础颜色 | `string[]` | - ||
Expand All @@ -50,7 +61,7 @@ s2.setTheme({

功能描述:表格主题 `Schema`. 查看 [文档](/manual/basic/theme#%E4%B8%BB%E9%A2%98-schema)[示例](/examples/theme/custom/#custom-palette)

| 参数 | 参数 | 类型 | 默认值 | 必选 |
| 参数 | 说明 | 类型 | 默认值 | 必选 |
| ----------------- | -------------------------------------- | ----------------------------------------------- | ------ | ---- |
| cornerCell | 角头单元格主题 | [DefaultCellTheme](#defaultcelltheme) | | |
| rowCell | 行头单元格主题 | [DefaultCellTheme](#defaultcelltheme) | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ fetch(
displayCondition: (meta) => meta.level > 0,
onClick: (options) => {
console.log(options);
const { meta, event } = options;

meta.spreadsheet.handleGroupSort(event, meta);
},
onHover: (options) => {
console.log(options);
},
},
{
Expand All @@ -38,7 +38,7 @@ fetch(
onClick: (options) => {
const { meta, event } = options;

meta.spreadsheet.tooltip.show({
meta.spreadsheet.showTooltip({
position: { x: event.clientX, y: event.clientY },
content: `<div>ColTooltip</div>`,
});
Expand All @@ -51,7 +51,7 @@ fetch(
onClick: (options) => {
const { meta, event } = options;

meta.spreadsheet.tooltip.show({
meta.spreadsheet.showTooltip({
position: { x: event.clientX, y: event.clientY },
content: `<div>CornerTooltip</div>`,
});
Expand All @@ -66,7 +66,7 @@ fetch(
onClick: (options) => {
const { meta, event } = options;

meta.spreadsheet.tooltip.show({
meta.spreadsheet.showTooltip({
position: { x: event.clientX, y: event.clientY },
content: `<div>RowTooltip</div>`,
});
Expand All @@ -83,7 +83,7 @@ fetch(

content.innerHTML = '我是 RowTooltip 自定义内容';

meta.spreadsheet.tooltip.show({
meta.spreadsheet.showTooltip({
position: { x: event.clientX, y: event.clientY },
content,
});
Expand Down

0 comments on commit 39561c3

Please sign in to comment.