diff --git a/common/changes/@visactor/vtable/535-feature-overscroll-behavior_2023-11-07-08-51.json b/common/changes/@visactor/vtable/535-feature-overscroll-behavior_2023-11-07-08-51.json new file mode 100644 index 000000000..0223bec81 --- /dev/null +++ b/common/changes/@visactor/vtable/535-feature-overscroll-behavior_2023-11-07-08-51.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "feat: add option overscrollBehavior\n\n", + "type": "patch", + "packageName": "@visactor/vtable" + } + ], + "packageName": "@visactor/vtable", + "email": "892739385@qq.com" +} \ No newline at end of file diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 140bceaa4..68f287f62 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -14,7 +14,7 @@ importers: '@types/markdown-it': ^13.0.0 '@types/react': ^18.0.0 '@types/react-dom': ^18.0.0 - '@visactor/vchart': 1.5.3 + '@visactor/vchart': 1.6.0 '@visactor/vtable': workspace:* '@vitejs/plugin-react': 3.1.0 axios: ^1.4.0 @@ -35,7 +35,7 @@ importers: yargs: ^17.1.1 dependencies: '@arco-design/web-react': 2.46.1_5ifijlhiwgyo26nyk4gkpsvy4e - '@visactor/vchart': 1.5.3 + '@visactor/vchart': 1.6.0 '@visactor/vtable': link:../packages/vtable axios: 1.5.1 highlight.js: 11.8.0 @@ -78,10 +78,10 @@ importers: '@types/offscreencanvas': 2019.6.4 '@types/react': ^18.0.0 '@types/react-dom': ^18.0.0 - '@visactor/vchart': 1.5.3 + '@visactor/vchart': 1.6.0 '@visactor/vdataset': ~0.15.7 - '@visactor/vrender': 0.16.11 - '@visactor/vrender-components': 0.16.11 + '@visactor/vrender': 0.16.12 + '@visactor/vrender-components': 0.16.12 '@visactor/vscale': 0.16.0 '@visactor/vutils': 0.16.6 '@visactor/vutils-extension': 1.5.1-alpha.0 @@ -121,8 +121,8 @@ importers: vite-plugin-markdown: ^2.1.0 dependencies: '@visactor/vdataset': 0.15.14 - '@visactor/vrender': 0.16.11 - '@visactor/vrender-components': 0.16.11 + '@visactor/vrender': 0.16.12 + '@visactor/vrender-components': 0.16.12 '@visactor/vscale': 0.16.0 '@visactor/vutils': 0.16.6 '@visactor/vutils-extension': 1.5.1-alpha.0 @@ -142,7 +142,7 @@ importers: '@types/offscreencanvas': 2019.6.4 '@types/react': 18.2.25 '@types/react-dom': 18.2.10 - '@visactor/vchart': 1.5.3 + '@visactor/vchart': 1.6.0 '@vitejs/plugin-react': 3.1.0_vite@3.2.6 axios: 1.5.1 chai: 4.3.4 @@ -3048,8 +3048,8 @@ packages: resolution: {integrity: sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==} dev: true - /@visactor/vchart/1.5.3: - resolution: {integrity: sha512-ny/Xe1nwRF/5hYbgmV/BoCg+Nm8ZWCIz7V7ZxTTb9G5Xa8FEQCTqySgiUkkge3EFyPaIYstqglS+FZPHfJIRNQ==} + /@visactor/vchart/1.6.0: + resolution: {integrity: sha512-L5r3qhkXUnXWFWIsPf7Gwp8rBa/AEmO29tZxZGNaGCxomdYDAMOC77LFZxIuTO6oHYEseNVAz/JZ4edSqnMbog==} dependencies: '@visactor/vdataset': 0.16.6 '@visactor/vgrammar-core': 0.8.1 @@ -3059,12 +3059,12 @@ packages: '@visactor/vgrammar-util': 0.8.1 '@visactor/vgrammar-wordcloud': 0.8.1 '@visactor/vgrammar-wordcloud-shape': 0.8.1 - '@visactor/vrender-components': 0.16.11 - '@visactor/vrender-core': 0.16.9 - '@visactor/vrender-kits': 0.16.9 + '@visactor/vrender-components': 0.16.12 + '@visactor/vrender-core': 0.16.11 + '@visactor/vrender-kits': 0.16.11 '@visactor/vscale': 0.16.6 '@visactor/vutils': 0.16.6 - '@visactor/vutils-extension': 1.5.3 + '@visactor/vutils-extension': 1.6.0 /@visactor/vdataset/0.15.14: resolution: {integrity: sha512-uPRUJAcldwEUezQnXUIB5IwFyMhktgc9YyObm0fFtBEf9P+zln+d/cW1jIN8H2oTIaTyAryDCzZ3MDWTI8jOqg==} @@ -3121,9 +3121,9 @@ packages: '@visactor/vdataset': 0.16.6 '@visactor/vgrammar-coordinate': 0.8.1 '@visactor/vgrammar-util': 0.8.1 - '@visactor/vrender-components': 0.16.11 - '@visactor/vrender-core': 0.16.11 - '@visactor/vrender-kits': 0.16.11 + '@visactor/vrender-components': 0.16.12 + '@visactor/vrender-core': 0.16.12 + '@visactor/vrender-kits': 0.16.12 '@visactor/vscale': 0.16.6 '@visactor/vutils': 0.16.6 @@ -3132,8 +3132,8 @@ packages: dependencies: '@visactor/vgrammar-core': 0.8.1 '@visactor/vgrammar-util': 0.8.1 - '@visactor/vrender-core': 0.16.11 - '@visactor/vrender-kits': 0.16.11 + '@visactor/vrender-core': 0.16.12 + '@visactor/vrender-kits': 0.16.12 '@visactor/vutils': 0.16.6 /@visactor/vgrammar-projection/0.8.1: @@ -3149,8 +3149,8 @@ packages: dependencies: '@visactor/vgrammar-core': 0.8.1 '@visactor/vgrammar-util': 0.8.1 - '@visactor/vrender-core': 0.16.11 - '@visactor/vrender-kits': 0.16.11 + '@visactor/vrender-core': 0.16.12 + '@visactor/vrender-kits': 0.16.12 '@visactor/vutils': 0.16.6 /@visactor/vgrammar-util/0.8.1: @@ -3163,8 +3163,8 @@ packages: dependencies: '@visactor/vgrammar-core': 0.8.1 '@visactor/vgrammar-util': 0.8.1 - '@visactor/vrender-core': 0.16.11 - '@visactor/vrender-kits': 0.16.11 + '@visactor/vrender-core': 0.16.12 + '@visactor/vrender-kits': 0.16.12 '@visactor/vscale': 0.16.6 '@visactor/vutils': 0.16.6 @@ -3173,15 +3173,15 @@ packages: dependencies: '@visactor/vgrammar-core': 0.8.1 '@visactor/vgrammar-util': 0.8.1 - '@visactor/vrender-core': 0.16.11 - '@visactor/vrender-kits': 0.16.11 + '@visactor/vrender-core': 0.16.12 + '@visactor/vrender-kits': 0.16.12 '@visactor/vutils': 0.16.6 - /@visactor/vrender-components/0.16.11: - resolution: {integrity: sha512-ZnZoNDKCkbNSId9fdywCG+F5DfxRgYR9IbnAYsK3sEnouRiHwfjHUG5q8G1RHG43QnhN0kSVuDI1qaocd3hYJg==} + /@visactor/vrender-components/0.16.12: + resolution: {integrity: sha512-hYH32WPMb4Z7jUkNrTwAXEKDGcJQLD9uySg2bFDcvmhUOBe9nc19+B+mW0t8zmZY97T5D3w+iudNRvwgJi5DHg==} dependencies: - '@visactor/vrender-core': 0.16.11 - '@visactor/vrender-kits': 0.16.11 + '@visactor/vrender-core': 0.16.12 + '@visactor/vrender-kits': 0.16.12 '@visactor/vscale': 0.16.0 '@visactor/vutils': 0.16.6 @@ -3198,8 +3198,8 @@ packages: '@visactor/vutils': 0.16.6 color-convert: 2.0.1 - /@visactor/vrender-core/0.16.9: - resolution: {integrity: sha512-nNsYliMouH40vgu+RCW4wIV3z/4VAr9Y3GjkGYTKuBjHkco4kF9+rHEiuTenTSdvOY1W78eiUXEm8ipdqUgOyg==} + /@visactor/vrender-core/0.16.12: + resolution: {integrity: sha512-dnkAr787qEk2KRP1mivzcDUIFlXBrpoqLBAV8SVcqUFXUA3FGbHo0BHI5kgzk72HM/rXtTVA5S1mOeCAVKedBA==} dependencies: '@visactor/vutils': 0.16.6 color-convert: 2.0.1 @@ -3221,19 +3221,19 @@ packages: '@visactor/vutils': 0.16.6 roughjs: 4.5.2 - /@visactor/vrender-kits/0.16.9: - resolution: {integrity: sha512-m2BpQMW3RsqBXOVPOapMWl8jf6fuxFidFI4b1YCg2iXijmhpRzyOt9ffFarxm1Wmls35OE0gX8UPAYH7lBiu2w==} + /@visactor/vrender-kits/0.16.12: + resolution: {integrity: sha512-/q05tAo7eyhmp/f24is8x4/1hMLsN4kueK5O1gh67lZYVVBqPPopZiz4yCy6hb1oVnNTzv5Onbbhdnr1i+3Rnw==} dependencies: '@resvg/resvg-js': 2.4.1 - '@visactor/vrender-core': 0.16.9 + '@visactor/vrender-core': 0.16.12 '@visactor/vutils': 0.16.6 roughjs: 4.5.2 - /@visactor/vrender/0.16.11: - resolution: {integrity: sha512-Ch0Dz8n0lhlGAwdIcvl8I5Hy5s2SDAvGXtHwNn1P1JEbzLge64gVkQLFwqQHt7VTqNzdIigTENu9t1rAQWLvPw==} + /@visactor/vrender/0.16.12: + resolution: {integrity: sha512-Iy0n0FskM0nMyyAhJkDbZkCOtzKCPJxexrjDGrsonxJkgZX+XagF8N52A/cTzds7/jHudB1pstDo+oNwsA3pcg==} dependencies: - '@visactor/vrender-core': 0.16.11 - '@visactor/vrender-kits': 0.16.11 + '@visactor/vrender-core': 0.16.12 + '@visactor/vrender-kits': 0.16.12 dev: false /@visactor/vscale/0.16.0: @@ -3261,11 +3261,11 @@ packages: '@visactor/vutils': 0.16.6 dev: false - /@visactor/vutils-extension/1.5.3: - resolution: {integrity: sha512-eGIfn10cLN7SUd1WooGqGbiRxlQ8VIbMZLI4gnHOebkmTxGPdOakfqIHe6VHEik58HBjMnK5rEQJZwz2rFuxZA==} + /@visactor/vutils-extension/1.6.0: + resolution: {integrity: sha512-bhBw880F9/3fYSo0fMJ7ixCxs7ykCDhVhPRX6QMTTBnBM9sotj6YN4iRFMiW9Mq5DD45Bkox9oMoNj3qHhGyFQ==} dependencies: - '@visactor/vrender-core': 0.16.11 - '@visactor/vrender-kits': 0.16.11 + '@visactor/vrender-core': 0.16.12 + '@visactor/vrender-kits': 0.16.12 '@visactor/vscale': 0.16.6 '@visactor/vutils': 0.16.6 diff --git a/docs/package.json b/docs/package.json index 49e749df7..3b6866808 100644 --- a/docs/package.json +++ b/docs/package.json @@ -11,7 +11,7 @@ "dependencies": { "@arco-design/web-react": "2.46.1", "@visactor/vtable": "workspace:*", - "@visactor/vchart": "1.5.3", + "@visactor/vchart": "1.6.0", "markdown-it": "^13.0.0", "highlight.js": "^11.8.0", "axios": "^1.4.0", @@ -38,4 +38,4 @@ "globby": "11.1.0", "chokidar": "^3.5.0" } -} +} \ No newline at end of file diff --git a/packages/vtable/package.json b/packages/vtable/package.json index 733cb59dc..e53d97192 100644 --- a/packages/vtable/package.json +++ b/packages/vtable/package.json @@ -49,8 +49,8 @@ "test-nodejs": "ts-node --transpileOnly --skipProject ./nodejs/index.ts" }, "dependencies": { - "@visactor/vrender": "0.16.11", - "@visactor/vrender-components": "0.16.11", + "@visactor/vrender": "0.16.12", + "@visactor/vrender-components": "0.16.12", "@visactor/vutils-extension": "1.5.1-alpha.0", "@visactor/vutils": "0.16.6", "@visactor/vscale": "0.16.0", @@ -58,7 +58,7 @@ "cssfontparser": "^1.2.1" }, "devDependencies": { - "@visactor/vchart": "1.5.3", + "@visactor/vchart": "1.6.0", "@internal/bundler": "workspace:*", "@internal/eslint-config": "workspace:*", "@internal/ts-config": "workspace:*", @@ -114,4 +114,4 @@ "publishConfig": { "access": "public" } -} +} \ No newline at end of file diff --git a/packages/vtable/src/core/BaseTable.ts b/packages/vtable/src/core/BaseTable.ts index 0fb6a3c0a..20fad86ee 100644 --- a/packages/vtable/src/core/BaseTable.ts +++ b/packages/vtable/src/core/BaseTable.ts @@ -189,7 +189,8 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI { mode, modeParams, canvasWidth, - canvasHeight + canvasHeight, + overscrollBehavior } = options; this.container = container; this.options = options; @@ -254,7 +255,7 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI { internalProps.dragHeaderMode = dragHeaderMode; internalProps.renderChartAsync = renderChartAsync; setBatchRenderChartCount(renderChartAsyncBatchCount); - + internalProps.overscrollBehavior = overscrollBehavior ?? 'auto'; internalProps._rowHeightsMap = new NumberMap(); internalProps._rowRangeHeightsMap = new Map(); internalProps._colRangeWidthsMap = new Map(); @@ -1812,7 +1813,8 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI { autoFillHeight, customRender, renderChartAsync, - renderChartAsyncBatchCount + renderChartAsyncBatchCount, + overscrollBehavior } = options; if (pixelRatio && pixelRatio !== this.internalProps.pixelRatio) { this.internalProps.pixelRatio = pixelRatio; @@ -1870,7 +1872,7 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI { internalProps.dragHeaderMode = dragHeaderMode; internalProps.renderChartAsync = renderChartAsync; setBatchRenderChartCount(renderChartAsyncBatchCount); - + internalProps.overscrollBehavior = overscrollBehavior ?? 'auto'; internalProps.cellTextOverflows = {}; internalProps._rowHeightsMap = new NumberMap(); internalProps._rowRangeHeightsMap = new Map(); diff --git a/packages/vtable/src/event/listener/touch.ts b/packages/vtable/src/event/listener/touch.ts index 06979fd1e..bb145c448 100644 --- a/packages/vtable/src/event/listener/touch.ts +++ b/packages/vtable/src/event/listener/touch.ts @@ -52,7 +52,8 @@ export function bindTouchListener(eventManeger: EventManeger) { if ( e.cancelable && - ((Math.abs(deltaY) >= Math.abs(deltaX) && deltaY !== 0 && isVerticalScrollable(deltaY, stateManeger)) || + (table.internalProps.overscrollBehavior === 'none' || + (Math.abs(deltaY) >= Math.abs(deltaX) && deltaY !== 0 && isVerticalScrollable(deltaY, stateManeger)) || (Math.abs(deltaY) <= Math.abs(deltaX) && deltaX !== 0 && isHorizontalScrollable(deltaX, stateManeger))) ) { e.preventDefault(); diff --git a/packages/vtable/src/event/scroll.ts b/packages/vtable/src/event/scroll.ts index 6de578e55..3d2896976 100644 --- a/packages/vtable/src/event/scroll.ts +++ b/packages/vtable/src/event/scroll.ts @@ -27,7 +27,8 @@ export function handleWhell(event: WheelEvent, state: StateManeger) { state.resetInteractionState(); if ( event.cancelable && - ((Math.abs(deltaY) >= Math.abs(deltaX) && deltaY !== 0 && isVerticalScrollable(deltaY, state)) || + (state.table.internalProps.overscrollBehavior === 'none' || + (Math.abs(deltaY) >= Math.abs(deltaX) && deltaY !== 0 && isVerticalScrollable(deltaY, state)) || (Math.abs(deltaY) <= Math.abs(deltaX) && deltaX !== 0 && isHorizontalScrollable(deltaX, state))) ) { event.preventDefault(); diff --git a/packages/vtable/src/ts-types/base-table.ts b/packages/vtable/src/ts-types/base-table.ts index a612177fc..60eae8ee7 100644 --- a/packages/vtable/src/ts-types/base-table.ts +++ b/packages/vtable/src/ts-types/base-table.ts @@ -187,6 +187,12 @@ export interface IBaseTableProtected { renderChartAsync?: boolean; // // 开启图表异步渲染 每批次渐进渲染图表个数 // renderChartAsyncBatchCount?: number; + + /** + * 'auto':和浏览器滚动行为一致 表格滚动到顶部/底部时 触发浏览器默认行为; + * 设置为 'none' 时, 表格滚动到顶部/底部时, 不再触发父容器滚动 + * */ + overscrollBehavior?: 'auto' | 'none'; } export interface BaseTableConstructorOptions { // /** 指定表格的行数 */ @@ -333,6 +339,11 @@ export interface BaseTableConstructorOptions { modeParams?: any; canvasWidth?: number; canvasHeight?: number; + /** + * 'auto':和浏览器滚动行为一致 表格滚动到顶部/底部时 触发浏览器默认行为; + * 设置为 'none' 时, 表格滚动到顶部/底部时, 不再触发父容器滚动 + * */ + overscrollBehavior?: 'auto' | 'none'; } export interface BaseTableAPI { /** 表格的行数 */