Skip to content

Commit

Permalink
Merge branch 'develop' into dev/0.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
neuqzxy committed Aug 9, 2023
2 parents 372198d + 809a53e commit 4551702
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vrender-components",
"comment": "feat(brush): add sizeThreshold setting",
"type": "none"
}
],
"packageName": "@visactor/vrender-components"
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export function run() {
maxY: guiObject.interactiveRangeY2,
minX: guiObject.interactiveRangeX1,
maxX: guiObject.interactiveRangeX2
}
},
sizeThreshold: 100
};

const brush = new Brush({
Expand Down
6 changes: 3 additions & 3 deletions packages/vrender-components/src/brush/brush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { cloneDeep, debounce, isFunction, merge, polygonContainPoint, throttle }
import { AbstractComponent } from '../core/base';
import type { BrushAttributes } from './type';
import { IOperateType } from './type';
import { DEFAULT_BRUSH_ATTRIBUTES, SIZE_THRESHOLD } from './config';
import { DEFAULT_BRUSH_ATTRIBUTES, DEFAULT_SIZE_THRESHOLD } from './config';

const delayMap = {
debounce: debounce,
Expand All @@ -24,7 +24,6 @@ export class Brush extends AbstractComponent<Required<BrushAttributes>> {
// 绘制mask时的相关属性
private _activeDrawState = false; // 用于标记绘制状态
private _cacheDrawPoints: IPointLike[] = []; // 用于维护鼠标走过的路径,主要用于绘制mask的点
private _cacheStartTime: number; // 用于记录鼠标前后的点击时间,以此判断是否为双击
private _isDrawedBeforeEnd = false;
// 移动mask时的相关属性
private _activeMoveState = false; // 用于标记移动状态
Expand Down Expand Up @@ -203,7 +202,8 @@ export class Brush extends AbstractComponent<Required<BrushAttributes>> {
private _drawing(e: FederatedPointerEvent) {
const pos = this.eventPosToStagePos(e);
const { x1 = 0, x2 = 0, y1 = 0, y2 = 0 } = this._operatingMask?._AABBBounds;
this._isDrawedBeforeEnd = !!(Math.abs(x2 - x1) > SIZE_THRESHOLD || Math.abs(y1 - y2) > SIZE_THRESHOLD);
const { sizeThreshold = DEFAULT_SIZE_THRESHOLD } = this.attribute as BrushAttributes;
this._isDrawedBeforeEnd = !!(Math.abs(x2 - x1) > sizeThreshold || Math.abs(y1 - y2) > sizeThreshold);

// 如果当前点的位置和上一次点的位置一致,则无需更新
if (this._cacheDrawPoints.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vrender-components/src/brush/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ export const DEFAULT_BRUSH_ATTRIBUTES = {
}
};

export const SIZE_THRESHOLD = 5;
export const DEFAULT_SIZE_THRESHOLD = 5;
4 changes: 4 additions & 0 deletions packages/vrender-components/src/brush/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export interface BrushAttributes extends IGroupGraphicAttribute {
* @default true
*/
removeOnClick?: boolean;
/**
* brush选框的大小阈值
*/
sizeThreshold?: number;
/**
* 事件触发延迟类型
* @default 'throttle'
Expand Down

0 comments on commit 4551702

Please sign in to comment.