@visactor/vrender-components 0.22.5-alpha.1 → 0.22.5-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, pi, isArray, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, cos, sin, isString, pointAt, isNumber, getDecimalPlaces, isNil, Color, sqrt, OBBBounds, has, normalTransform, isValidUrl, isBase64, acos, transformBoundsWithMatrix, getContextFont, rotatePoint, clampAngleByRadian, asin, arrayEqual, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, array, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, normalizeAngle, isValidNumber, flattenArray, isRotateAABBIntersect, isLess, isGreater, cloneDeep, get, last, mixin, isEqual, interpolateString, minInArray, maxInArray, binaryFuzzySearchInNumberRange, calculateAnchorOfBounds, computeQuadrant, polygonContainPoint } from '@visactor/vutils';
1
+ import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, pi, isArray, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, cos, sin, isString, pointAt, isNumber, getDecimalPlaces, isNil, Color, sqrt, OBBBounds, has, normalTransform, isValidUrl, isBase64, acos, transformBoundsWithMatrix, getContextFont, rotatePoint, clampAngleByRadian, asin, arrayEqual, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, normalizeAngle, isValidNumber, flattenArray, array, isRotateAABBIntersect, isLess, isGreater, cloneDeep, get, last, mixin, isEqual, interpolateString, minInArray, maxInArray, binaryFuzzySearchInNumberRange, calculateAnchorOfBounds, computeQuadrant, polygonContainPoint } from '@visactor/vutils';
2
2
  import { isContinuous, isDiscrete, LinearScale } from '@visactor/vscale';
3
3
 
4
4
  class Generator {
@@ -15941,17 +15941,14 @@ class Tag extends AbstractComponent {
15941
15941
  tagWidth += symbolPlaceWidth;
15942
15942
  textX += symbolPlaceWidth;
15943
15943
  let textShape;
15944
- let textWidth;
15945
- let textHeight;
15946
15944
  const isRich = isRichText({ text }) || type === 'rich';
15947
15945
  if (isRich) {
15948
15946
  const richTextAttrs = Object.assign(Object.assign(Object.assign({}, richTextAttributeTransform(Object.assign({ type, text }, textStyle))), textStyle), { visible: isValid(text) && visible !== false, x: textX, y: 0 });
15949
- if (isNil(richTextAttrs.lineHeight)) {
15950
- richTextAttrs.lineHeight = textStyle.fontSize;
15951
- }
15952
15947
  textShape = group.createOrUpdateChild('tag-text', richTextAttrs, 'richtext');
15953
- textWidth = textShape.AABBBounds.width();
15954
- textHeight = textShape.AABBBounds.height();
15948
+ tagWidth += textShape.AABBBounds.width();
15949
+ tagHeight += textShape.AABBBounds.height();
15950
+ tagX += textShape.AABBBounds.x1;
15951
+ tagY += textShape.AABBBounds.y1;
15955
15952
  }
15956
15953
  else {
15957
15954
  const textAttrs = Object.assign(Object.assign({ text: isObject(text) && 'type' in text && text.type === 'text' ? text.text : text, visible: isValid(text) && visible !== false, lineHeight: textStyle === null || textStyle === void 0 ? void 0 : textStyle.fontSize }, textStyle), { x: textX, y: 0 });
@@ -15959,134 +15956,126 @@ class Tag extends AbstractComponent {
15959
15956
  textAttrs.lineHeight = textStyle.fontSize;
15960
15957
  }
15961
15958
  textShape = group.createOrUpdateChild('tag-text', textAttrs, 'text');
15959
+ if (!isEmpty(state === null || state === void 0 ? void 0 : state.text)) {
15960
+ textShape.states = state.text;
15961
+ }
15962
15962
  const textBounds = measureTextSize(textAttrs.text, textStyle, (_b = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.getTheme()) === null || _b === void 0 ? void 0 : _b.text);
15963
- textWidth = textBounds.width;
15964
- textHeight = textBounds.height;
15965
- }
15966
- tagWidth += textWidth;
15967
- const size = (_c = shape.size) !== null && _c !== void 0 ? _c : 10;
15968
- const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1]));
15969
- tagHeight += Math.max(textHeight, shape.visible ? maxSize : 0);
15970
- const { textAlign, textBaseline } = textStyle;
15971
- if (isValid(minWidth) || isValid(maxWidth)) {
15972
- if (isValid(minWidth) && tagWidth < minWidth) {
15973
- tagWidth = minWidth;
15963
+ const textWidth = textBounds.width;
15964
+ const textHeight = textBounds.height;
15965
+ tagWidth += textWidth;
15966
+ const size = (_c = shape.size) !== null && _c !== void 0 ? _c : 10;
15967
+ const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1]));
15968
+ tagHeight += Math.max(textHeight, shape.visible ? maxSize : 0);
15969
+ const { textAlign, textBaseline } = textStyle;
15970
+ if (isValid(minWidth) || isValid(maxWidth)) {
15971
+ if (isValid(minWidth) && tagWidth < minWidth) {
15972
+ tagWidth = minWidth;
15973
+ }
15974
+ if (isValid(maxWidth) && tagWidth > maxWidth) {
15975
+ tagWidth = maxWidth;
15976
+ textShape.setAttribute('maxLineWidth', maxWidth - parsedPadding[1] - parsedPadding[2]);
15977
+ }
15974
15978
  }
15975
- if (isValid(maxWidth) && tagWidth > maxWidth) {
15976
- tagWidth = maxWidth;
15977
- textShape.setAttribute('maxLineWidth', maxWidth - parsedPadding[1] - parsedPadding[2]);
15979
+ tagX = 0;
15980
+ tagY = 0;
15981
+ let flag = 0;
15982
+ if (textAlign === 'left' || textAlign === 'start') {
15983
+ flag = 1;
15978
15984
  }
15979
- }
15980
- tagX = 0;
15981
- tagY = 0;
15982
- let flag = 0;
15983
- if (textAlign === 'left' || textAlign === 'start') {
15984
- flag = 1;
15985
- }
15986
- else if (textAlign === 'right' || textAlign === 'end') {
15987
- flag = -1;
15988
- }
15989
- else if (textAlign === 'center') {
15990
- flag = 0;
15991
- }
15992
- if (!flag) {
15993
- tagX -= tagWidth / 2;
15994
- if (symbol) {
15995
- symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth / 2);
15985
+ else if (textAlign === 'right' || textAlign === 'end') {
15986
+ flag = -1;
15996
15987
  }
15997
- group.setAttribute('x', -symbolPlaceWidth / 2);
15998
- }
15999
- else if (flag < 0) {
16000
- tagX -= tagWidth;
16001
- if (symbol) {
16002
- symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth);
15988
+ else if (textAlign === 'center') {
15989
+ flag = 0;
16003
15990
  }
16004
- group.setAttribute('x', -parsedPadding[1] - symbolPlaceWidth);
16005
- }
16006
- else if (flag > 0) {
16007
- group.setAttribute('x', parsedPadding[3]);
16008
- }
16009
- const shouldCenter = containerTextAlign ? containerTextAlign === 'center' : textAlwaysCenter;
16010
- const shouldRight = containerTextAlign === 'right' || containerTextAlign === 'end';
16011
- const shouldLeft = containerTextAlign === 'left' || containerTextAlign === 'start';
16012
- const updateTextAttrs = (textX, textAlign) => {
16013
- if (textShape.type === 'richtext') {
15991
+ if (!flag) {
15992
+ tagX -= tagWidth / 2;
15993
+ if (symbol) {
15994
+ symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth / 2);
15995
+ }
15996
+ group.setAttribute('x', -symbolPlaceWidth / 2);
15997
+ }
15998
+ else if (flag < 0) {
15999
+ tagX -= tagWidth;
16000
+ if (symbol) {
16001
+ symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth);
16002
+ }
16003
+ group.setAttribute('x', -parsedPadding[1] - symbolPlaceWidth);
16004
+ }
16005
+ else if (flag > 0) {
16006
+ group.setAttribute('x', parsedPadding[3]);
16007
+ }
16008
+ const shouldCenter = containerTextAlign ? containerTextAlign === 'center' : textAlwaysCenter;
16009
+ const shouldRight = containerTextAlign === 'right' || containerTextAlign === 'end';
16010
+ const shouldLeft = containerTextAlign === 'left' || containerTextAlign === 'start';
16011
+ if (shouldCenter && flag) {
16012
+ const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
16013
+ const tsWidth = textWidth + symbolPlaceWidth;
16014
+ const textX = flag === 1
16015
+ ? (containerWidth - tsWidth) / 2 + symbolPlaceWidth + textWidth / 2
16016
+ : parsedPadding[0] + symbolPlaceWidth - (tagWidth / 2 + tsWidth / 2 - symbolPlaceWidth) + textWidth / 2;
16014
16017
  textShape.setAttributes({
16015
16018
  x: textX,
16016
- textAlign,
16017
- textConfig: array(textShape.attribute.textConfig).map(t => {
16018
- return Object.assign(Object.assign({}, t), { textAlign });
16019
- })
16019
+ textAlign: 'center'
16020
16020
  });
16021
+ if (symbol) {
16022
+ const symbolX = textX - textWidth / 2 - symbolPlaceWidth + maxSize / 2;
16023
+ symbol.setAttributes({
16024
+ x: symbolX
16025
+ });
16026
+ }
16021
16027
  }
16022
- else {
16028
+ if (shouldLeft && flag !== 1) {
16029
+ const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
16030
+ const offset = flag === 0
16031
+ ? -containerWidth / 2 + symbolPlaceWidth / 2
16032
+ : -tagWidth + parsedPadding[3] + parsedPadding[1] + symbolPlaceWidth;
16033
+ const textX = offset + symbolPlaceWidth;
16023
16034
  textShape.setAttributes({
16024
16035
  x: textX,
16025
- textAlign
16026
- });
16027
- }
16028
- };
16029
- if (shouldCenter && flag) {
16030
- const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
16031
- const tsWidth = textWidth + symbolPlaceWidth;
16032
- const textX = flag === 1
16033
- ? (containerWidth - tsWidth) / 2 + symbolPlaceWidth + textWidth / 2
16034
- : parsedPadding[0] + symbolPlaceWidth - (tagWidth / 2 + tsWidth / 2 - symbolPlaceWidth) + textWidth / 2;
16035
- updateTextAttrs(textX, 'center');
16036
- if (symbol) {
16037
- const symbolX = textX - textWidth / 2 - symbolPlaceWidth + maxSize / 2;
16038
- symbol.setAttributes({
16039
- x: symbolX
16040
- });
16041
- }
16042
- }
16043
- if (shouldLeft && flag !== 1) {
16044
- const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
16045
- const offset = flag === 0
16046
- ? -containerWidth / 2 + symbolPlaceWidth / 2
16047
- : -tagWidth + parsedPadding[3] + parsedPadding[1] + symbolPlaceWidth;
16048
- const textX = offset + symbolPlaceWidth;
16049
- updateTextAttrs(textX, 'left');
16050
- if (symbol) {
16051
- const symbolX = offset + maxSize / 2;
16052
- symbol.setAttributes({
16053
- x: symbolX
16036
+ textAlign: 'left'
16054
16037
  });
16038
+ if (symbol) {
16039
+ const symbolX = offset + maxSize / 2;
16040
+ symbol.setAttributes({
16041
+ x: symbolX
16042
+ });
16043
+ }
16055
16044
  }
16056
- }
16057
- if (shouldRight && flag !== -1) {
16058
- const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
16059
- const textX = flag === 0 ? containerWidth / 2 + symbolPlaceWidth / 2 : containerWidth;
16060
- updateTextAttrs(textX, 'right');
16061
- if (symbol) {
16062
- const symbolX = textX - textWidth - symbolPlaceWidth + maxSize / 2;
16063
- symbol.setAttributes({
16064
- x: symbolX
16045
+ if (shouldRight && flag !== -1) {
16046
+ const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];
16047
+ const textX = flag === 0 ? containerWidth / 2 + symbolPlaceWidth / 2 : containerWidth;
16048
+ textShape.setAttributes({
16049
+ x: textX,
16050
+ textAlign: 'right'
16065
16051
  });
16052
+ if (symbol) {
16053
+ const symbolX = textX - textWidth - symbolPlaceWidth + maxSize / 2;
16054
+ symbol.setAttributes({
16055
+ x: symbolX
16056
+ });
16057
+ }
16066
16058
  }
16067
- }
16068
- if (textBaseline === 'middle') {
16069
- tagY -= tagHeight / 2;
16070
- if (symbol) {
16071
- symbol.setAttribute('y', 0);
16059
+ if (textBaseline === 'middle') {
16060
+ tagY -= tagHeight / 2;
16061
+ if (symbol) {
16062
+ symbol.setAttribute('y', 0);
16063
+ }
16072
16064
  }
16073
- }
16074
- else if (textBaseline === 'bottom') {
16075
- tagY -= tagHeight;
16076
- if (symbol) {
16077
- symbol.setAttribute('y', -textHeight / 2);
16065
+ else if (textBaseline === 'bottom') {
16066
+ tagY -= tagHeight;
16067
+ if (symbol) {
16068
+ symbol.setAttribute('y', -textHeight / 2);
16069
+ }
16070
+ group.setAttribute('y', -parsedPadding[2]);
16078
16071
  }
16079
- group.setAttribute('y', -parsedPadding[2]);
16080
- }
16081
- else if (textBaseline === 'top') {
16082
- group.setAttribute('y', parsedPadding[0]);
16083
- if (symbol) {
16084
- symbol.setAttribute('y', textHeight / 2);
16072
+ else if (textBaseline === 'top') {
16073
+ group.setAttribute('y', parsedPadding[0]);
16074
+ if (symbol) {
16075
+ symbol.setAttribute('y', textHeight / 2);
16076
+ }
16085
16077
  }
16086
16078
  }
16087
- if (!isEmpty(state === null || state === void 0 ? void 0 : state.text)) {
16088
- textShape.states = state.text;
16089
- }
16090
16079
  const { visible: bgVisible } = panel, backgroundStyle = __rest(panel, ["visible"]);
16091
16080
  if (visible && isBoolean(bgVisible)) {
16092
16081
  const bgRect = this.createOrUpdateChild('tag-panel', Object.assign(Object.assign({}, backgroundStyle), { visible: bgVisible && !!text, width: tagWidth, height: tagHeight, x: tagX, y: tagY }), 'rect');
@@ -29577,7 +29566,7 @@ var IOperateType;
29577
29566
  const DEFAULT_BRUSH_ATTRIBUTES = {
29578
29567
  trigger: 'pointerdown',
29579
29568
  updateTrigger: 'pointermove',
29580
- endTrigger: 'pointerup',
29569
+ endTrigger: ['pointerup', 'pointerleave'],
29581
29570
  resetTrigger: 'pointerupoutside',
29582
29571
  hasMask: true,
29583
29572
  brushMode: 'single',
@@ -29631,6 +29620,7 @@ class Brush extends AbstractComponent {
29631
29620
  this._isDownBeforeUpOutside = true;
29632
29621
  return;
29633
29622
  }
29623
+ this._isDownBeforeUpOutside = false;
29634
29624
  e.stopPropagation();
29635
29625
  const brushMoved = (_a = this.attribute.brushMoved) !== null && _a !== void 0 ? _a : true;
29636
29626
  this._activeMoveState = brushMoved && this._isPosInBrushMask(e);
@@ -29653,6 +29643,14 @@ class Brush extends AbstractComponent {
29653
29643
  : delayMap[this.attribute.delayType](this._onBrushing, this.attribute.delayTime);
29654
29644
  this._onBrushEnd = (e) => {
29655
29645
  var _a;
29646
+ if (this._isDownBeforeUpOutside) {
29647
+ if (!this._isEmptyMask()) {
29648
+ this._clearMask();
29649
+ this._dispatchBrushEvent(IOperateType.brushClear, e);
29650
+ }
29651
+ this._isDownBeforeUpOutside = false;
29652
+ return;
29653
+ }
29656
29654
  if (!this._activeDrawState && !this._activeMoveState) {
29657
29655
  return;
29658
29656
  }
@@ -29660,29 +29658,29 @@ class Brush extends AbstractComponent {
29660
29658
  const { removeOnClick = true } = this.attribute;
29661
29659
  if (this._activeDrawState && !this._isDrawedBeforeEnd && removeOnClick) {
29662
29660
  if ((_a = this._operatingMask) === null || _a === void 0 ? void 0 : _a._AABBBounds.empty()) {
29663
- this._dispatchEvent(IOperateType.brushClear, {
29664
- operateMask: this._operatingMask,
29665
- operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,
29666
- event: e
29667
- });
29661
+ if (!this._isEmptyMask()) {
29662
+ this._clearMask();
29663
+ this._dispatchBrushEvent(IOperateType.brushClear, e);
29664
+ }
29665
+ }
29666
+ else {
29667
+ delete this._brushMaskAABBBoundsDict[this._operatingMask.name];
29668
+ this._container.setAttributes({});
29669
+ this._container.removeChild(this._operatingMask);
29670
+ if (!this._isEmptyMask()) {
29671
+ this._dispatchBrushEvent(IOperateType.brushClear, e);
29672
+ }
29673
+ else {
29674
+ this._dispatchBrushEvent(IOperateType.drawEnd, e);
29675
+ }
29668
29676
  }
29669
- this._container.incrementalClearChild();
29670
- this._brushMaskAABBBoundsDict = {};
29671
29677
  }
29672
29678
  else {
29673
29679
  if (this._activeDrawState) {
29674
- this._dispatchEvent(IOperateType.drawEnd, {
29675
- operateMask: this._operatingMask,
29676
- operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,
29677
- event: e
29678
- });
29680
+ this._dispatchBrushEvent(IOperateType.drawEnd, e);
29679
29681
  }
29680
29682
  if (this._activeMoveState) {
29681
- this._dispatchEvent(IOperateType.moveEnd, {
29682
- operateMask: this._operatingMask,
29683
- operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,
29684
- event: e
29685
- });
29683
+ this._dispatchBrushEvent(IOperateType.moveEnd, e);
29686
29684
  }
29687
29685
  }
29688
29686
  this._activeDrawState = false;
@@ -29694,23 +29692,14 @@ class Brush extends AbstractComponent {
29694
29692
  };
29695
29693
  this._onBrushClear = (e) => {
29696
29694
  e.preventDefault();
29697
- const { removeOnClick = true } = this.attribute;
29698
- if (this._isDownBeforeUpOutside && removeOnClick) {
29699
- this._dispatchEvent(IOperateType.brushClear, {
29700
- operateMask: this._operatingMask,
29701
- operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,
29702
- event: e
29703
- });
29704
- this._container.incrementalClearChild();
29705
- this._brushMaskAABBBoundsDict = {};
29695
+ if (!this._isEmptyMask()) {
29696
+ this._clearMask();
29697
+ this._dispatchBrushEvent(IOperateType.brushClear, e);
29706
29698
  }
29707
29699
  this._activeDrawState = false;
29708
29700
  this._activeMoveState = false;
29709
29701
  this._isDrawedBeforeEnd = false;
29710
29702
  this._isDownBeforeUpOutside = false;
29711
- if (this._operatingMask) {
29712
- this._operatingMask.setAttribute('pickable', false);
29713
- }
29714
29703
  };
29715
29704
  }
29716
29705
  _bindBrushEvents() {
@@ -29718,44 +29707,19 @@ class Brush extends AbstractComponent {
29718
29707
  return;
29719
29708
  }
29720
29709
  const { trigger = DEFAULT_BRUSH_ATTRIBUTES.trigger, updateTrigger = DEFAULT_BRUSH_ATTRIBUTES.updateTrigger, endTrigger = DEFAULT_BRUSH_ATTRIBUTES.endTrigger, resetTrigger = DEFAULT_BRUSH_ATTRIBUTES.resetTrigger } = this.attribute;
29721
- array(trigger).forEach(t => vglobal.addEventListener(t, this._onBrushStart));
29710
+ array(trigger).forEach(t => this.stage.addEventListener(t, this._onBrushStart));
29722
29711
  array(updateTrigger).forEach(t => this.stage.addEventListener(t, this._onBrushingWithDelay));
29723
29712
  array(endTrigger).forEach(t => this.stage.addEventListener(t, this._onBrushEnd));
29724
29713
  array(resetTrigger).forEach(t => this.stage.addEventListener(t, this._onBrushClear));
29725
29714
  }
29726
- _isPosInBrushMask(e) {
29727
- const pos = this.eventPosToStagePos(e);
29728
- const brushMasks = this._container.getChildren();
29729
- for (let i = 0; i < brushMasks.length; i++) {
29730
- const { points = [], dx = 0, dy = 0 } = brushMasks[i].attribute;
29731
- const pointsConsiderOffset = points.map((point) => {
29732
- return {
29733
- x: point.x + dx,
29734
- y: point.y + dy
29735
- };
29736
- });
29737
- if (polygonContainPoint(pointsConsiderOffset, pos.x, pos.y)) {
29738
- this._operatingMask = brushMasks[i];
29739
- return true;
29740
- }
29741
- }
29742
- return false;
29743
- }
29744
29715
  _initDraw(e) {
29745
29716
  const { brushMode } = this.attribute;
29746
29717
  const pos = this.eventPosToStagePos(e);
29747
29718
  this._cacheDrawPoints = [pos];
29748
29719
  this._isDrawedBeforeEnd = false;
29749
- if (brushMode === 'single') {
29750
- this._brushMaskAABBBoundsDict = {};
29751
- this._container.incrementalClearChild();
29752
- }
29720
+ brushMode === 'single' && this._clearMask();
29753
29721
  this._addBrushMask();
29754
- this._dispatchEvent(IOperateType.drawStart, {
29755
- operateMask: this._operatingMask,
29756
- operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,
29757
- event: e
29758
- });
29722
+ this._dispatchBrushEvent(IOperateType.drawStart, e);
29759
29723
  }
29760
29724
  _initMove(e) {
29761
29725
  var _a, _b;
@@ -29772,11 +29736,7 @@ class Brush extends AbstractComponent {
29772
29736
  this._operatingMaskMoveRangeX = [minMoveStepX, maxMoveStepX];
29773
29737
  this._operatingMaskMoveRangeY = [minMoveStepY, maxMoveStepY];
29774
29738
  this._operatingMask.setAttribute('pickable', true);
29775
- this._dispatchEvent(IOperateType.moveStart, {
29776
- operateMask: this._operatingMask,
29777
- operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,
29778
- event: e
29779
- });
29739
+ this._dispatchBrushEvent(IOperateType.moveStart, e);
29780
29740
  }
29781
29741
  _drawing(e) {
29782
29742
  var _a, _b;
@@ -29803,12 +29763,8 @@ class Brush extends AbstractComponent {
29803
29763
  !!(Math.abs(x2 - x1) > sizeThreshold || Math.abs(y1 - y2) > sizeThreshold);
29804
29764
  if (this._isDrawedBeforeEnd) {
29805
29765
  this._brushMaskAABBBoundsDict[this._operatingMask.name] = this._operatingMask.AABBBounds;
29806
- this._dispatchEvent(IOperateType.drawing, {
29807
- operateMask: this._operatingMask,
29808
- operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,
29809
- event: e
29810
- });
29811
29766
  }
29767
+ this._dispatchBrushEvent(IOperateType.drawing, e);
29812
29768
  }
29813
29769
  _moving(e) {
29814
29770
  const startPos = this._cacheMovePoint;
@@ -29827,11 +29783,20 @@ class Brush extends AbstractComponent {
29827
29783
  dy: moveY
29828
29784
  });
29829
29785
  this._brushMaskAABBBoundsDict[this._operatingMask.name] = this._operatingMask.AABBBounds;
29830
- this._dispatchEvent(IOperateType.moving, {
29831
- operateMask: this._operatingMask,
29832
- operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,
29833
- event: e
29834
- });
29786
+ this._dispatchBrushEvent(IOperateType.moving, e);
29787
+ }
29788
+ render() {
29789
+ this.releaseBrushEvents();
29790
+ this._bindBrushEvents();
29791
+ const group = this.createOrUpdateChild('brush-container', {}, 'group');
29792
+ this._container = group;
29793
+ }
29794
+ releaseBrushEvents() {
29795
+ const { trigger = DEFAULT_BRUSH_ATTRIBUTES.trigger, updateTrigger = DEFAULT_BRUSH_ATTRIBUTES.updateTrigger, endTrigger = DEFAULT_BRUSH_ATTRIBUTES.endTrigger, resetTrigger = DEFAULT_BRUSH_ATTRIBUTES.resetTrigger } = this.attribute;
29796
+ array(trigger).forEach(t => this.stage.removeEventListener(t, this._onBrushStart));
29797
+ array(updateTrigger).forEach(t => this.stage.removeEventListener(t, this._onBrushingWithDelay));
29798
+ array(endTrigger).forEach(t => this.stage.removeEventListener(t, this._onBrushEnd));
29799
+ array(resetTrigger).forEach(t => this.stage.removeEventListener(t, this._onBrushClear));
29835
29800
  }
29836
29801
  _computeMaskPoints() {
29837
29802
  const { brushType, xRange = [0, 0], yRange = [0, 0] } = this.attribute;
@@ -29900,12 +29865,30 @@ class Brush extends AbstractComponent {
29900
29865
  _addBrushMask() {
29901
29866
  var _a;
29902
29867
  const { brushStyle, hasMask } = this.attribute;
29903
- const brushMask = graphicCreator.polygon(Object.assign(Object.assign({ points: cloneDeep(this._cacheDrawPoints), cursor: 'move', pickable: false }, brushStyle), { opacity: hasMask ? (_a = brushStyle.opacity) !== null && _a !== void 0 ? _a : 1 : 0 }));
29868
+ const brushMask = graphicCreator.polygon(Object.assign(Object.assign({ points: cloneDeep(this._cacheDrawPoints), cursor: 'move', pickable: false }, brushStyle), { opacity: hasMask ? ((_a = brushStyle.opacity) !== null && _a !== void 0 ? _a : 1) : 0 }));
29904
29869
  brushMask.name = `brush-${Date.now()}`;
29905
29870
  this._operatingMask = brushMask;
29906
29871
  this._container.add(brushMask);
29907
29872
  this._brushMaskAABBBoundsDict[brushMask.name] = brushMask.AABBBounds;
29908
29873
  }
29874
+ _isPosInBrushMask(e) {
29875
+ const pos = this.eventPosToStagePos(e);
29876
+ const brushMasks = this._container.getChildren();
29877
+ for (let i = 0; i < brushMasks.length; i++) {
29878
+ const { points = [], dx = 0, dy = 0 } = brushMasks[i].attribute;
29879
+ const pointsConsiderOffset = points.map((point) => {
29880
+ return {
29881
+ x: point.x + dx,
29882
+ y: point.y + dy
29883
+ };
29884
+ });
29885
+ if (polygonContainPoint(pointsConsiderOffset, pos.x, pos.y)) {
29886
+ this._operatingMask = brushMasks[i];
29887
+ return true;
29888
+ }
29889
+ }
29890
+ return false;
29891
+ }
29909
29892
  _outOfInteractiveRange(e) {
29910
29893
  const { interactiveRange } = this.attribute;
29911
29894
  const { minY = -Infinity, maxY = Infinity, minX = -Infinity, maxX = Infinity } = interactiveRange;
@@ -29918,17 +29901,21 @@ class Brush extends AbstractComponent {
29918
29901
  eventPosToStagePos(e) {
29919
29902
  return this.stage.eventPointTransform(e);
29920
29903
  }
29921
- render() {
29922
- this._bindBrushEvents();
29923
- const group = this.createOrUpdateChild('brush-container', {}, 'group');
29924
- this._container = group;
29904
+ _dispatchBrushEvent(operateType, e) {
29905
+ this._dispatchEvent(operateType, {
29906
+ operateMask: this._operatingMask,
29907
+ operatedMaskAABBBounds: this._brushMaskAABBBoundsDict,
29908
+ event: e
29909
+ });
29925
29910
  }
29926
- releaseBrushEvents() {
29927
- const { delayType = 'throttle', delayTime = 0, trigger = DEFAULT_BRUSH_ATTRIBUTES.trigger, updateTrigger = DEFAULT_BRUSH_ATTRIBUTES.updateTrigger, endTrigger = DEFAULT_BRUSH_ATTRIBUTES.endTrigger, resetTrigger = DEFAULT_BRUSH_ATTRIBUTES.resetTrigger } = this.attribute;
29928
- array(trigger).forEach(t => vglobal.removeEventListener(t, this._onBrushStart));
29929
- array(updateTrigger).forEach(t => this.stage.removeEventListener(t, this._onBrushingWithDelay));
29930
- array(endTrigger).forEach(t => this.stage.removeEventListener(t, this._onBrushEnd));
29931
- array(resetTrigger).forEach(t => this.stage.removeEventListener(t, this._onBrushClear));
29911
+ _clearMask() {
29912
+ this._brushMaskAABBBoundsDict = {};
29913
+ this._container.incrementalClearChild();
29914
+ this._operatingMask = null;
29915
+ }
29916
+ _isEmptyMask() {
29917
+ return (isEmpty(this._brushMaskAABBBoundsDict) ||
29918
+ Object.keys(this._brushMaskAABBBoundsDict).every(key => this._brushMaskAABBBoundsDict[key].empty()));
29932
29919
  }
29933
29920
  }
29934
29921
  Brush.defaultAttributes = DEFAULT_BRUSH_ATTRIBUTES;
@@ -31471,6 +31458,6 @@ StoryLabelItem.defaultAttributes = {
31471
31458
  theme: 'default'
31472
31459
  };
31473
31460
 
31474
- const version = "0.22.5-alpha.1";
31461
+ const version = "0.22.5-alpha.3";
31475
31462
 
31476
31463
  export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PolygonSectorCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, StoryLabelItem, Switch, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, WeatherBox, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, loadScrollbar, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, scrollbarModule, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
@@ -7,7 +7,7 @@ export declare class Brush extends AbstractComponent<Required<BrushAttributes>>
7
7
  static defaultAttributes: {
8
8
  trigger: string;
9
9
  updateTrigger: string;
10
- endTrigger: string;
10
+ endTrigger: string[];
11
11
  resetTrigger: string;
12
12
  hasMask: boolean;
13
13
  brushMode: string;
@@ -44,7 +44,6 @@ export declare class Brush extends AbstractComponent<Required<BrushAttributes>>
44
44
  private _brushMaskAABBBoundsDict;
45
45
  constructor(attributes: BrushAttributes, options?: ComponentOptions);
46
46
  private _bindBrushEvents;
47
- private _isPosInBrushMask;
48
47
  private _onBrushStart;
49
48
  private _onBrushing;
50
49
  private _onBrushingWithDelay;
@@ -54,13 +53,17 @@ export declare class Brush extends AbstractComponent<Required<BrushAttributes>>
54
53
  private _initMove;
55
54
  private _drawing;
56
55
  private _moving;
56
+ protected render(): void;
57
+ releaseBrushEvents(): void;
57
58
  private _computeMaskPoints;
58
59
  private _addBrushMask;
60
+ private _isPosInBrushMask;
59
61
  private _outOfInteractiveRange;
60
62
  protected eventPosToStagePos(e: FederatedPointerEvent): {
61
63
  x: number;
62
64
  y: number;
63
65
  };
64
- protected render(): void;
65
- releaseBrushEvents(): void;
66
+ private _dispatchBrushEvent;
67
+ private _clearMask;
68
+ private _isEmptyMask;
66
69
  }