Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/support click interval for dblclick #3589

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vchart",
"comment": "feat: vchart support clickInterval params",
"type": "none"
}
],
"packageName": "@visactor/vchart"
}
28 changes: 19 additions & 9 deletions packages/vchart/src/compile/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,32 @@ export class Compiler implements ICompiler {
this._option?.onError?.(...args);
});
}
const {
performanceHook,
autoRefreshDpr,
dpr,
mode,
gestureConfig,
interactive,
clickInterval,
autoPreventDefault,
...restOption
} = this._option;
this._view = new View({
width: this._width,
height: this._height,
container: this._container.dom ?? null,
renderCanvas: this._container.canvas ?? null,
hooks: (this._option as any).performanceHook, // vgrammar 事件改造后,性能回调函数放在了hooks中实现
...this._option,
autoRefresh: isValid(this._option.autoRefreshDpr) ? this._option.autoRefreshDpr : !isValid(this._option.dpr),
mode: toRenderMode(this._option.mode),
hooks: performanceHook, // vgrammar 事件改造后,性能回调函数放在了hooks中实现
...restOption,
autoRefresh: isValid(autoRefreshDpr) ? autoRefreshDpr : !isValid(dpr),
mode: toRenderMode(mode),
autoFit: false,
eventConfig: {
gesture: isValid(this._option.gestureConfig)
? (this._option.gestureConfig as any)
: isMobileLikeMode(this._option.mode),
disable: this._option.interactive === false
gesture: isValid(gestureConfig) ? (gestureConfig as any) : isMobileLikeMode(mode),
disable: interactive === false,
clickInterval,
autoPreventDefault
},
doLayout: () => {
this._compileChart?.onLayout(this._view);
Expand All @@ -133,7 +144,6 @@ export class Compiler implements ICompiler {
// emit afterRender event
this.getStage().hooks.afterRender.tap('chart-event', this.handleStageRender);

const interactive = this._option.interactive;
if (interactive !== false) {
// 将 view 实例化之前监听的事件挂载到 view 上
this._viewListeners.forEach(listener => {
Expand Down
19 changes: 19 additions & 0 deletions packages/vchart/src/compile/interface/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Hooks } from '@visactor/vgrammar-core';
import type { IColor, IStageParams, IStage, ILayer } from '@visactor/vrender-core';
import type { RenderMode } from '../../typings/spec/common';
import type { IBoundsLike } from '@visactor/vutils';
Expand Down Expand Up @@ -170,4 +171,22 @@ export interface IRenderOption {
* 用于vrender渲染react元素,`react-dom`包导出元素
*/
ReactDOM?: any;
/**
* @since 1.13.2
* @default 200
* 单位 ms
* 多次点击之间的最大时间,默认为 200 ms,用于判断点击次数
*/
clickInterval?: number;
/**
* @since 1.13.2
* @default false
* VRender 参数 是否自动阻止事件
*/
autoPreventDefault?: boolean;
/**
* @deprecated
* 请使用 hooks 代替
*/
performanceHook?: Hooks;
}
Loading