@visactor/vrender-components 0.22.7-alpha.4 → 0.22.7-alpha.5

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.
Files changed (54) hide show
  1. package/cjs/crosshair/base.js +1 -2
  2. package/cjs/crosshair/type.js +2 -1
  3. package/cjs/data-zoom/data-zoom.d.ts +0 -1
  4. package/cjs/data-zoom/data-zoom.js +14 -19
  5. package/cjs/data-zoom/data-zoom.js.map +1 -1
  6. package/cjs/index.d.ts +1 -1
  7. package/cjs/index.js +1 -1
  8. package/cjs/index.js.map +1 -1
  9. package/cjs/poptip/contribution.js +4 -2
  10. package/cjs/poptip/contribution.js.map +1 -1
  11. package/cjs/poptip/poptip.d.ts +5 -0
  12. package/cjs/poptip/poptip.js +87 -18
  13. package/cjs/poptip/poptip.js.map +1 -1
  14. package/cjs/poptip/type.d.ts +4 -1
  15. package/cjs/poptip/type.js.map +1 -1
  16. package/cjs/scrollbar/scrollbar.d.ts +0 -1
  17. package/cjs/scrollbar/scrollbar.js +10 -17
  18. package/cjs/scrollbar/scrollbar.js.map +1 -1
  19. package/cjs/slider/slider.d.ts +0 -1
  20. package/cjs/slider/slider.js +22 -30
  21. package/cjs/slider/slider.js.map +1 -1
  22. package/cjs/switch/switch.js +2 -2
  23. package/cjs/switch/switch.js.map +1 -1
  24. package/dist/index.es.js +202 -99
  25. package/es/crosshair/base.js +1 -2
  26. package/es/crosshair/type.js +2 -1
  27. package/es/data-zoom/data-zoom.d.ts +0 -1
  28. package/es/data-zoom/data-zoom.js +11 -18
  29. package/es/data-zoom/data-zoom.js.map +1 -1
  30. package/es/index.d.ts +1 -1
  31. package/es/index.js +1 -1
  32. package/es/index.js.map +1 -1
  33. package/es/poptip/contribution.js +4 -2
  34. package/es/poptip/contribution.js.map +1 -1
  35. package/es/poptip/poptip.d.ts +5 -0
  36. package/es/poptip/poptip.js +85 -19
  37. package/es/poptip/poptip.js.map +1 -1
  38. package/es/poptip/type.d.ts +4 -1
  39. package/es/poptip/type.js.map +1 -1
  40. package/es/scrollbar/scrollbar.d.ts +0 -1
  41. package/es/scrollbar/scrollbar.js +9 -18
  42. package/es/scrollbar/scrollbar.js.map +1 -1
  43. package/es/slider/slider.d.ts +0 -1
  44. package/es/slider/slider.js +21 -31
  45. package/es/slider/slider.js.map +1 -1
  46. package/es/switch/switch.js +2 -2
  47. package/es/switch/switch.js.map +1 -1
  48. package/package.json +4 -4
  49. package/cjs/util/event.d.ts +0 -1
  50. package/cjs/util/event.js +0 -14
  51. package/cjs/util/event.js.map +0 -1
  52. package/es/util/event.d.ts +0 -1
  53. package/es/util/event.js +0 -6
  54. package/es/util/event.js.map +0 -1
package/dist/index.es.js CHANGED
@@ -2835,6 +2835,7 @@ function applyStrokeStyle(ctx, character) {
2835
2835
  ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
2836
2836
  }
2837
2837
  function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
2838
+ if (desc.length <= 1) return 0;
2838
2839
  if (!width || width <= 0) return 0;
2839
2840
  const textMeasure = application.graphicUtil.textMeasure;
2840
2841
  let index = guessIndex,
@@ -2868,6 +2869,13 @@ function testLetter2(string, index) {
2868
2869
  }
2869
2870
  function measureTextCanvas(text, character) {
2870
2871
  let mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "actual";
2872
+ var _a;
2873
+ if ("" === text) return {
2874
+ ascent: 0,
2875
+ height: 0,
2876
+ descent: 0,
2877
+ width: 0
2878
+ };
2871
2879
  const measurement = application.graphicUtil.textMeasure.measureText(text, character),
2872
2880
  result = {
2873
2881
  ascent: 0,
@@ -2877,7 +2885,9 @@ function measureTextCanvas(text, character) {
2877
2885
  },
2878
2886
  ascent = "actual" === mode ? measurement.actualBoundingBoxAscent : measurement.fontBoundingBoxAscent,
2879
2887
  descent = "actual" === mode ? measurement.actualBoundingBoxDescent : measurement.fontBoundingBoxDescent;
2880
- return "number" != typeof ascent || "number" != typeof descent ? (result.width = Math.floor(measurement.width), result.height = character.fontSize || 0, result.ascent = result.height, result.descent = 0) : (result.width = Math.floor(measurement.width), result.height = Math.floor(ascent + descent), result.ascent = Math.floor(ascent), result.descent = result.height - result.ascent), result;
2888
+ "number" != typeof ascent || "number" != typeof descent ? (result.width = Math.floor(measurement.width), result.height = character.fontSize || 0, result.ascent = result.height, result.descent = 0) : (result.width = Math.floor(measurement.width), result.height = Math.floor(ascent + descent), result.ascent = Math.floor(ascent), result.descent = result.height - result.ascent);
2889
+ const space = null !== (_a = character.space) && void 0 !== _a ? _a : 0;
2890
+ return result.width += space, result;
2881
2891
  }
2882
2892
 
2883
2893
  var __decorate$O = undefined && undefined.__decorate || function (decorators, target, key, desc) {
@@ -4162,7 +4172,7 @@ class FederatedEvent {
4162
4172
  }
4163
4173
  _composedDetailPath(params) {
4164
4174
  if (params && params.graphic) {
4165
- const g = this.pickParams.graphic;
4175
+ const g = params.graphic;
4166
4176
  if (g.stage) {
4167
4177
  const path = g.stage.eventSystem.manager.propagationPath(g);
4168
4178
  this.detailPath.push(path), this._composedDetailPath(params.params);
@@ -8830,6 +8840,7 @@ function getFixedLRTB(left, right, top, bottom) {
8830
8840
  }
8831
8841
  class Paragraph {
8832
8842
  constructor(text, newLine, character, ascentDescentMode) {
8843
+ var _a, _b;
8833
8844
  this.fontSize = character.fontSize || 16, this.textBaseline = character.textBaseline || "alphabetic", this.ascentDescentMode = ascentDescentMode;
8834
8845
  const lineHeight = calculateLineHeight(character.lineHeight, this.fontSize);
8835
8846
  this.lineHeight = "number" == typeof lineHeight ? lineHeight > this.fontSize ? lineHeight : this.fontSize : Math.floor(1.2 * this.fontSize), this.height = this.lineHeight;
@@ -8842,7 +8853,7 @@ class Paragraph {
8842
8853
  let halfDetaHeight = 0,
8843
8854
  deltaAscent = 0,
8844
8855
  deltaDescent = 0;
8845
- this.height > height && (halfDetaHeight = (this.height - height) / 2, deltaAscent = Math.ceil(halfDetaHeight), deltaDescent = Math.floor(halfDetaHeight)), "top" === this.textBaseline ? (this.ascent = halfDetaHeight, this.descent = height - halfDetaHeight) : "bottom" === this.textBaseline ? (this.ascent = height - halfDetaHeight, this.descent = halfDetaHeight) : "middle" === this.textBaseline ? (this.ascent = this.height / 2, this.descent = this.height / 2) : (this.ascent = ascent + deltaAscent, this.descent = descent + deltaDescent), this.length = text.length, this.width = width || 0, this.text = text || "", this.newLine = newLine || !1, this.character = character, this.left = 0, this.top = 0, this.ellipsis = "normal", this.ellipsisWidth = 0, this.ellipsisOtherParagraphWidth = 0, "vertical" === character.direction && (this.direction = character.direction, this.widthOrigin = this.width, this.heightOrigin = this.height, this.width = this.heightOrigin, this.height = this.widthOrigin, this.lineHeight = this.height), this.ellipsisStr = "...";
8856
+ this.height > height && (halfDetaHeight = (this.height - height) / 2, deltaAscent = Math.ceil(halfDetaHeight), deltaDescent = Math.floor(halfDetaHeight)), "top" === this.textBaseline ? (this.ascent = halfDetaHeight, this.descent = height - halfDetaHeight) : "bottom" === this.textBaseline ? (this.ascent = height - halfDetaHeight, this.descent = halfDetaHeight) : "middle" === this.textBaseline ? (this.ascent = this.height / 2, this.descent = this.height / 2) : (this.ascent = ascent + deltaAscent, this.descent = descent + deltaDescent), this.length = text.length, this.width = width || 0, this.text = text || "", this.newLine = newLine || !1, this.character = character, this.left = 0, this.top = 0, this.ellipsis = "normal", this.ellipsisWidth = 0, this.ellipsisOtherParagraphWidth = 0, this.space = character.space, this.dx = null !== (_a = character.dx) && void 0 !== _a ? _a : 0, this.dy = null !== (_b = character.dy) && void 0 !== _b ? _b : 0, "vertical" === character.direction && (this.direction = character.direction, this.widthOrigin = this.width, this.heightOrigin = this.height, this.width = this.heightOrigin, this.height = this.widthOrigin, this.lineHeight = this.height), this.ellipsisStr = "...";
8846
8857
  }
8847
8858
  updateWidth() {
8848
8859
  const {
@@ -8861,11 +8872,11 @@ class Paragraph {
8861
8872
  if ("hide" === this.ellipsis) return;
8862
8873
  if ("add" === this.ellipsis) text += this.ellipsisStr, "right" !== textAlign && "end" !== textAlign || (left -= this.ellipsisWidth);else if ("replace" === this.ellipsis) {
8863
8874
  const index = getStrByWithCanvas(text, ("vertical" === direction ? this.height : this.width) - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.character, text.length - 1);
8864
- if (text = text.slice(0, index), text += this.ellipsisStr, "right" === textAlign || "end" === textAlign) {
8875
+ if (text = text.slice(0, index), text += this.ellipsisStr, "right" === textAlign || "end" === textAlign) if ("vertical" === direction) ;else {
8865
8876
  const {
8866
8877
  width: width
8867
8878
  } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
8868
- "vertical" === direction || (left -= this.ellipsisWidth - width);
8879
+ left -= this.ellipsisWidth - width;
8869
8880
  }
8870
8881
  }
8871
8882
  }
@@ -8876,20 +8887,21 @@ class Paragraph {
8876
8887
  });
8877
8888
  }
8878
8889
  draw(ctx, top, ascent, deltaLeft, isLineFirst, textAlign, lineHeight) {
8890
+ var _a;
8879
8891
  let baseline = top + ascent,
8880
8892
  text = this.text,
8881
- left = this.left + deltaLeft;
8893
+ left = this.left + deltaLeft + (null !== (_a = this.space) && void 0 !== _a ? _a : 0) / 2;
8882
8894
  baseline += this.top;
8883
8895
  let direction = this.direction;
8884
8896
  if (this.verticalEllipsis) text = this.ellipsisStr, direction = "vertical", baseline -= this.ellipsisWidth / 2;else {
8885
8897
  if ("hide" === this.ellipsis) return;
8886
8898
  if ("add" === this.ellipsis) text += this.ellipsisStr, "right" !== textAlign && "end" !== textAlign || (left -= this.ellipsisWidth);else if ("replace" === this.ellipsis) {
8887
8899
  const index = getStrByWithCanvas(text, ("vertical" === direction ? this.height : this.width) - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.character, text.length - 1);
8888
- if (text = text.slice(0, index), text += this.ellipsisStr, "right" === textAlign || "end" === textAlign) {
8900
+ if (text = text.slice(0, index), text += this.ellipsisStr, "right" === textAlign || "end" === textAlign) if ("vertical" === direction) ;else {
8889
8901
  const {
8890
8902
  width: width
8891
8903
  } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);
8892
- "vertical" === direction || (left -= this.ellipsisWidth - width);
8904
+ left -= this.ellipsisWidth - width;
8893
8905
  }
8894
8906
  }
8895
8907
  }
@@ -8904,7 +8916,7 @@ class Paragraph {
8904
8916
  const {
8905
8917
  lineWidth = 1
8906
8918
  } = this.character;
8907
- if (this.character.stroke && lineWidth && ctx.strokeText(text, left, baseline), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill) if (this.character.lineThrough || this.character.underline) {
8919
+ if (this.character.stroke && lineWidth && ctx.strokeText(text, left, baseline + this.dy), this.character.fill && ctx.fillText(text, left, baseline + this.dy), this.character.fill) if (this.character.lineThrough || this.character.underline) {
8908
8920
  if (this.character.underline) {
8909
8921
  const top = 1 + baseline,
8910
8922
  lrtb = getFixedLRTB(left, left + (this.widthOrigin || this.width), top, top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1));
@@ -14909,13 +14921,6 @@ const SCROLLBAR_START_EVENT = 'scrollDown';
14909
14921
  const SCROLLBAR_EVENT = 'scrollDrag';
14910
14922
  const SCROLLBAR_END_EVENT = 'scrollUp';
14911
14923
 
14912
- function getEndTriggersOfDrag() {
14913
- if (vglobal.env === 'browser') {
14914
- return ['pointerup', 'pointerleave', 'pointercancel'];
14915
- }
14916
- return ['pointerup', 'pointerleave', 'pointerupoutside'];
14917
- }
14918
-
14919
14924
  const delayMap$2 = {
14920
14925
  debounce: debounce,
14921
14926
  throttle: throttle
@@ -14949,7 +14954,6 @@ class ScrollBar extends AbstractComponent {
14949
14954
  }
14950
14955
  };
14951
14956
  this._onSliderPointerDown = (e) => {
14952
- this._clearDragEvents();
14953
14957
  const { stopSliderDownPropagation = true } = this.attribute;
14954
14958
  if (stopSliderDownPropagation) {
14955
14959
  e.stopPropagation();
@@ -14961,12 +14965,15 @@ class ScrollBar extends AbstractComponent {
14961
14965
  pos: this._prePos,
14962
14966
  event: e
14963
14967
  });
14964
- const triggers = getEndTriggersOfDrag();
14965
- const obj = vglobal.env === 'browser' ? vglobal : this.stage;
14966
- obj.addEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });
14967
- triggers.forEach((trigger) => {
14968
- obj.addEventListener(trigger, this._onSliderPointerUp);
14969
- });
14968
+ if (vglobal.env === 'browser') {
14969
+ vglobal.addEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });
14970
+ vglobal.addEventListener('pointerup', this._onSliderPointerUp);
14971
+ }
14972
+ else {
14973
+ this.stage.addEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });
14974
+ this.stage.addEventListener('pointerup', this._onSliderPointerUp);
14975
+ this.stage.addEventListener('pointerupoutside', this._onSliderPointerUp);
14976
+ }
14970
14977
  };
14971
14978
  this._computeScrollValue = (e) => {
14972
14979
  const { direction } = this.attribute;
@@ -15010,7 +15017,15 @@ class ScrollBar extends AbstractComponent {
15010
15017
  pre: preRange,
15011
15018
  value: clampRange(range, limitRange[0], limitRange[1])
15012
15019
  });
15013
- this._clearDragEvents();
15020
+ if (vglobal.env === 'browser') {
15021
+ vglobal.removeEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });
15022
+ vglobal.removeEventListener('pointerup', this._onSliderPointerUp);
15023
+ }
15024
+ else {
15025
+ this.stage.removeEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });
15026
+ this.stage.removeEventListener('pointerup', this._onSliderPointerUp);
15027
+ this.stage.removeEventListener('pointerupoutside', this._onSliderPointerUp);
15028
+ }
15014
15029
  };
15015
15030
  }
15016
15031
  setScrollRange(range, render = true) {
@@ -15143,14 +15158,6 @@ class ScrollBar extends AbstractComponent {
15143
15158
  ? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)
15144
15159
  : clampRange([y1 + min * height, y1 + max * height], y1, height - sliderSize);
15145
15160
  }
15146
- _clearDragEvents() {
15147
- const triggers = getEndTriggersOfDrag();
15148
- const obj = vglobal.env === 'browser' ? vglobal : this.stage;
15149
- obj.removeEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });
15150
- triggers.forEach((trigger) => {
15151
- obj.removeEventListener(trigger, this._onSliderPointerUp);
15152
- });
15153
- }
15154
15161
  _reset() {
15155
15162
  this._sliderRenderBounds = null;
15156
15163
  this._sliderLimitRange = null;
@@ -16232,7 +16239,7 @@ class PopTip extends AbstractComponent {
16232
16239
  }
16233
16240
  render() {
16234
16241
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
16235
- const { titleStyle = {}, position, contentStyle = {}, panel, logoSymbol, logoText, logoTextStyle = {}, triangleMode = 'default', space = 4, minWidth = 0, maxWidth = Infinity, padding = 4, maxWidthPercent, visible, state, dx = 0, dy = 0 } = this.attribute;
16242
+ const { titleStyle = {}, position, contentStyle = {}, panel, logoSymbol, poptipAnchor = 'position', logoText, logoTextStyle = {}, triangleMode = 'default', space = 4, minWidth = 0, maxWidth = Infinity, padding = 4, maxWidthPercent, visible, state, dx = 0, dy = 0, positionBounds } = this.attribute;
16236
16243
  let { title = '', content = '' } = this.attribute;
16237
16244
  title = this.attribute.titleFormatMethod ? this.attribute.titleFormatMethod(title) : title;
16238
16245
  content = this.attribute.contentFormatMethod ? this.attribute.contentFormatMethod(content) : content;
@@ -16314,11 +16321,12 @@ class PopTip extends AbstractComponent {
16314
16321
  poptipHeight += contentShape.AABBBounds.height();
16315
16322
  }
16316
16323
  }
16317
- const layout = position === 'auto';
16324
+ const layout = position === 'auto' || isArray(position);
16325
+ const positionList = isArray(position) ? position : this.positionList;
16318
16326
  let maxBBoxI;
16319
16327
  let maxBBoxSize = -Infinity;
16320
- for (let i = 0; i < this.positionList.length + 1; i++) {
16321
- const p = layout ? this.positionList[i === this.positionList.length ? maxBBoxI : i] : position;
16328
+ for (let i = 0; i < positionList.length + 1; i++) {
16329
+ const p = layout ? positionList[i === positionList.length ? maxBBoxI : i] : position;
16322
16330
  let symbolType = 'arrow2Left';
16323
16331
  let offsetX = (isArray(symbolSize) ? symbolSize[0] : symbolSize) / 4;
16324
16332
  let offsetY = 0;
@@ -16327,16 +16335,21 @@ class PopTip extends AbstractComponent {
16327
16335
  }
16328
16336
  else if (triangleMode === 'concise') {
16329
16337
  symbolType = conciseSymbolMap[p];
16330
- offsetX = ['tl', 'bl', 'rt', 'rb'].includes(position)
16338
+ offsetX = ['tl', 'bl', 'rt', 'rb'].includes(p)
16331
16339
  ? (isArray(symbolSize) ? symbolSize[0] : symbolSize) / 2
16332
16340
  : -(isArray(symbolSize) ? symbolSize[0] : symbolSize) / 2;
16333
- offsetY = ['tl', 'tr', 'lb', 'rb'].includes(position)
16341
+ offsetY = ['tl', 'tr', 'lb', 'rb'].includes(p)
16334
16342
  ? -(isArray(symbolSize) ? symbolSize[1] : symbolSize) / 2
16335
16343
  : (isArray(symbolSize) ? symbolSize[1] : symbolSize) / 2;
16336
16344
  }
16337
16345
  const { angle, offset } = this.getAngleAndOffset(p, popTipWidth, poptipHeight, isArray(spaceSize) ? spaceSize : [spaceSize, spaceSize - lineWidth], symbolType);
16346
+ let anchorPoint = { x: 0, y: 0 };
16347
+ if (poptipAnchor === 'bounds' && positionBounds) {
16348
+ anchorPoint = this.calculateAnchorPoint(p, positionBounds);
16349
+ }
16350
+ let bgSymbol;
16338
16351
  if (isBoolean(bgVisible)) {
16339
- const bgSymbol = group.createOrUpdateChild('poptip-symbol-panel', Object.assign(Object.assign({}, backgroundStyle), { visible: bgVisible && (contentVisible || titleVisible), x: offsetX, y: offsetY, strokeBoundsBuffer: -1, boundsPadding: -2, anchor: [0, 0], symbolType, angle: angle, dx: offset[0], dy: offset[1] - ((_j = backgroundStyle.space) !== null && _j !== void 0 ? _j : 0), size: symbolSize, zIndex: 9 }), 'symbol');
16352
+ bgSymbol = group.createOrUpdateChild('poptip-symbol-panel', Object.assign(Object.assign({}, backgroundStyle), { visible: bgVisible && (contentVisible || titleVisible), x: offsetX, y: offsetY, strokeBoundsBuffer: -1, boundsPadding: -2, anchor: [0, 0], symbolType, angle: angle, dx: offset[0], dy: offset[1] - ((_j = backgroundStyle.space) !== null && _j !== void 0 ? _j : 0), size: symbolSize, zIndex: 9 }), 'symbol');
16340
16353
  if (!isEmpty(state === null || state === void 0 ? void 0 : state.panel)) {
16341
16354
  bgSymbol.states = state.panel;
16342
16355
  }
@@ -16352,8 +16365,8 @@ class PopTip extends AbstractComponent {
16352
16365
  }
16353
16366
  }
16354
16367
  group.setAttributes({
16355
- x: -offset[0] + dx,
16356
- y: -offset[1] + dy,
16368
+ x: -offset[0] + dx + anchorPoint.x,
16369
+ y: -offset[1] + dy + anchorPoint.y,
16357
16370
  anchor: [offsetX, offsetY]
16358
16371
  });
16359
16372
  if (logoSymbol) {
@@ -16375,20 +16388,61 @@ class PopTip extends AbstractComponent {
16375
16388
  group.createOrUpdateChild('poptip-logo-text', Object.assign(Object.assign({}, logoTextStyle), { x: 0, y: poptipHeight / 2, visible: bgVisible && (contentVisible || titleVisible), text: logoText, textAlign: 'center', textBaseline: 'middle', zIndex: 10 }), 'text');
16376
16389
  }
16377
16390
  }
16378
- if (layout && range) {
16391
+ if (range) {
16379
16392
  _tBounds.setValue(0, 0, popTipWidth, poptipHeight).transformWithMatrix(group.globalTransMatrix);
16380
16393
  const b = _tBounds;
16381
16394
  const stageBounds = new Bounds().setValue(0, 0, range[0], range[1]);
16382
- if (rectInsideAnotherRect(b, stageBounds, false)) {
16383
- break;
16395
+ if (layout) {
16396
+ if (rectInsideAnotherRect(b, stageBounds, false)) {
16397
+ break;
16398
+ }
16399
+ else {
16400
+ const bbox = getRectIntersect(b, stageBounds, false);
16401
+ const size = (bbox.x2 - bbox.x1) * (bbox.y2 - bbox.y1);
16402
+ if (size > maxBBoxSize) {
16403
+ maxBBoxSize = size;
16404
+ maxBBoxI = i;
16405
+ }
16406
+ }
16384
16407
  }
16385
- else {
16386
- const bbox = getRectIntersect(b, stageBounds, false);
16387
- const size = (bbox.x2 - bbox.x1) * (bbox.y2 - bbox.y1);
16388
- if (size > maxBBoxSize) {
16389
- maxBBoxSize = size;
16390
- maxBBoxI = i;
16408
+ if (['top', 'bottom', 'left', 'right'].includes(p)) {
16409
+ const isVerticalPosition = p === 'top' || p === 'bottom';
16410
+ const isHorizontalPosition = p === 'left' || p === 'right';
16411
+ let mainDirectionOverlap = false;
16412
+ if (isVerticalPosition) {
16413
+ mainDirectionOverlap = (p === 'top' && b.y1 < 0) || (p === 'bottom' && b.y2 > stageBounds.y2);
16414
+ }
16415
+ else if (isHorizontalPosition) {
16416
+ mainDirectionOverlap = (p === 'left' && b.x1 < 0) || (p === 'right' && b.x2 > stageBounds.x2);
16391
16417
  }
16418
+ if (!mainDirectionOverlap) {
16419
+ let secondaryOffset = 0;
16420
+ const szNumber = (isArray(symbolSize) ? symbolSize[1] : symbolSize) / 2;
16421
+ if (isVerticalPosition) {
16422
+ if (b.x1 < 0) {
16423
+ secondaryOffset = -b.x1;
16424
+ }
16425
+ else if (b.x2 > stageBounds.x2) {
16426
+ secondaryOffset = stageBounds.x2 - b.x2;
16427
+ }
16428
+ group.setAttribute('x', group.attribute.x + secondaryOffset);
16429
+ bgSymbol.setAttribute('dx', min(max(bgSymbol.attribute.dx - secondaryOffset, szNumber), b.width() - szNumber));
16430
+ }
16431
+ else if (isHorizontalPosition) {
16432
+ if (b.y1 < 0) {
16433
+ secondaryOffset = -b.y1;
16434
+ }
16435
+ else if (b.y2 > stageBounds.y2) {
16436
+ secondaryOffset = stageBounds.y2 - b.y2;
16437
+ }
16438
+ group.setAttribute('y', group.attribute.y + secondaryOffset);
16439
+ bgSymbol.setAttribute('dy', min(max(bgSymbol.attribute.dy - secondaryOffset, szNumber), b.height() - szNumber));
16440
+ }
16441
+ break;
16442
+ }
16443
+ }
16444
+ if (!layout) {
16445
+ break;
16392
16446
  }
16393
16447
  }
16394
16448
  else {
@@ -16396,6 +16450,35 @@ class PopTip extends AbstractComponent {
16396
16450
  }
16397
16451
  }
16398
16452
  }
16453
+ calculateAnchorPoint(position, positionBounds) {
16454
+ if (!positionBounds) {
16455
+ return { x: 0, y: 0 };
16456
+ }
16457
+ const { x, y } = this.attribute;
16458
+ const { x1, y1, x2, y2 } = positionBounds;
16459
+ const width = x2 - x1;
16460
+ const height = y2 - y1;
16461
+ switch (position) {
16462
+ case 'top':
16463
+ case 'tl':
16464
+ case 'tr':
16465
+ return { x: x1 + width / 2 - x, y: y1 - y };
16466
+ case 'bottom':
16467
+ case 'bl':
16468
+ case 'br':
16469
+ return { x: x1 + width / 2 - x, y: y2 - y };
16470
+ case 'left':
16471
+ case 'lt':
16472
+ case 'lb':
16473
+ return { x: x1 - x, y: y1 + height / 2 - y };
16474
+ case 'right':
16475
+ case 'rt':
16476
+ case 'rb':
16477
+ return { x: x2 - x, y: y1 + height / 2 - y };
16478
+ default:
16479
+ return { x: 0, y: 0 };
16480
+ }
16481
+ }
16399
16482
  getAngleAndOffset(position, width, height, size, symbolType) {
16400
16483
  const sizeH = symbolType === 'arrow2Left' ? size[1] / 2 : size[1];
16401
16484
  switch (position) {
@@ -16527,7 +16610,7 @@ let PopTipRenderContribution = class PopTipRenderContribution {
16527
16610
  poptip.content = (_a = poptip.content) !== null && _a !== void 0 ? _a : graphic.attribute.text;
16528
16611
  }
16529
16612
  const matrix = graphic.globalTransMatrix;
16530
- this.poptipComponent.setAttributes(Object.assign(Object.assign({ visibleAll: true, pickable: false, childrenPickable: false }, poptip), { x: matrix.e, y: matrix.f }));
16613
+ this.poptipComponent.setAttributes(Object.assign(Object.assign({ visibleAll: true, pickable: false, childrenPickable: false, poptipAnchor: 'bounds' }, poptip), { x: matrix.e, y: matrix.f, positionBounds: graphic.globalAABBBounds }));
16531
16614
  drawContext.stage.tryInitInteractiveLayer();
16532
16615
  const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');
16533
16616
  if (interactiveLayer) {
@@ -23016,7 +23099,6 @@ class DataZoom extends AbstractComponent {
23016
23099
  };
23017
23100
  this._statePointToData = state => state;
23018
23101
  this._onHandlerPointerDown = (e, tag) => {
23019
- this._clearDragEvents();
23020
23102
  e.stopPropagation();
23021
23103
  if (tag === 'start') {
23022
23104
  this._activeTag = DataZoomActiveTag.startHandler;
@@ -23041,12 +23123,11 @@ class DataZoom extends AbstractComponent {
23041
23123
  this._activeState = true;
23042
23124
  this._activeCache.startPos = this.eventPosToStagePos(e);
23043
23125
  this._activeCache.lastPos = this.eventPosToStagePos(e);
23044
- const evtTarget = vglobal.env === 'browser' ? vglobal : this.stage;
23045
- const triggers = getEndTriggersOfDrag();
23046
- evtTarget.addEventListener('pointermove', this._onHandlerPointerMove, { capture: true });
23047
- triggers.forEach((trigger) => {
23048
- evtTarget.addEventListener(trigger, this._onHandlerPointerUp);
23049
- });
23126
+ if (vglobal.env === 'browser') {
23127
+ vglobal.addEventListener('pointermove', this._onHandlerPointerMove, { capture: true });
23128
+ vglobal.addEventListener('pointerup', this._onHandlerPointerUp);
23129
+ }
23130
+ this.addEventListener('pointermove', this._onHandlerPointerMove, { capture: true });
23050
23131
  };
23051
23132
  this._pointerMove = (e) => {
23052
23133
  e.stopPropagation();
@@ -23114,7 +23195,12 @@ class DataZoom extends AbstractComponent {
23114
23195
  end: this.state.end,
23115
23196
  tag: this._activeTag
23116
23197
  });
23117
- this._clearDragEvents();
23198
+ if (vglobal.env === 'browser') {
23199
+ vglobal.removeEventListener('pointermove', this._onHandlerPointerMove, { capture: true });
23200
+ vglobal.removeEventListener('pointerup', this._onHandlerPointerUp);
23201
+ }
23202
+ this.removeEventListener('pointermove', this._onHandlerPointerMove, { capture: true });
23203
+ this.removeEventListener('pointerup', this._onHandlerPointerUp);
23118
23204
  };
23119
23205
  const { position, showDetail } = attributes;
23120
23206
  this._activeCache.startPos = position;
@@ -23162,6 +23248,8 @@ class DataZoom extends AbstractComponent {
23162
23248
  if (this._selectedPreviewGroup) {
23163
23249
  this._selectedPreviewGroup.addEventListener('pointerdown', (e) => this._onHandlerPointerDown(e, selectedTag));
23164
23250
  }
23251
+ this.addEventListener('pointerup', this._onHandlerPointerUp);
23252
+ this.addEventListener('pointerupoutside', this._onHandlerPointerUp);
23165
23253
  if (showDetail === 'auto') {
23166
23254
  this.addEventListener('pointerenter', this._onHandlerPointerEnter);
23167
23255
  this.addEventListener('pointerleave', this._onHandlerPointerLeave);
@@ -23193,14 +23281,6 @@ class DataZoom extends AbstractComponent {
23193
23281
  var _a, _b;
23194
23282
  return (_b = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.eventPointTransform(e)) !== null && _b !== void 0 ? _b : { x: 0, y: 0 };
23195
23283
  }
23196
- _clearDragEvents() {
23197
- const evtTarget = vglobal.env === 'browser' ? vglobal : this.stage;
23198
- const triggers = getEndTriggersOfDrag();
23199
- evtTarget.removeEventListener('pointermove', this._onHandlerPointerMove, { capture: true });
23200
- triggers.forEach((trigger) => {
23201
- evtTarget.removeEventListener(trigger, this._onHandlerPointerUp);
23202
- });
23203
- }
23204
23284
  _onHandlerPointerEnter(e) {
23205
23285
  e.stopPropagation();
23206
23286
  this._showText = true;
@@ -27225,17 +27305,23 @@ class Slider extends AbstractComponent {
27225
27305
  };
27226
27306
  this._onHandlerPointerdown = (e) => {
27227
27307
  e.stopPropagation();
27228
- this._clearAllDragEvents();
27229
27308
  this._isChanging = true;
27230
27309
  const { x, y } = this.stage.eventPointTransform(e);
27231
27310
  this._currentHandler = e.target;
27232
27311
  this._prePos = this._isHorizontal ? x : y;
27233
- const triggers = getEndTriggersOfDrag();
27234
- const obj = vglobal.env === 'browser' ? vglobal : this.stage;
27235
- obj.addEventListener('pointermove', this._onHandlerPointerMove, { capture: true });
27236
- triggers.forEach((trigger) => {
27237
- obj.addEventListener(trigger, this._onHandlerPointerUp);
27238
- });
27312
+ if (vglobal.env === 'browser') {
27313
+ vglobal.addEventListener('pointermove', this._onHandlerPointerMove, {
27314
+ capture: true
27315
+ });
27316
+ vglobal.addEventListener('pointerup', this._onHandlerPointerUp);
27317
+ }
27318
+ else {
27319
+ this.stage.addEventListener('pointermove', this._onHandlerPointerMove, {
27320
+ capture: true
27321
+ });
27322
+ this.stage.addEventListener('pointerup', this._onHandlerPointerUp);
27323
+ this.stage.addEventListener('pointerupoutside', this._onHandlerPointerUp);
27324
+ }
27239
27325
  };
27240
27326
  this._onHandlerPointerMove = (e) => {
27241
27327
  var _a, _b;
@@ -27278,20 +27364,38 @@ class Slider extends AbstractComponent {
27278
27364
  e.preventDefault();
27279
27365
  this._isChanging = false;
27280
27366
  this._currentHandler = null;
27281
- this._clearAllDragEvents();
27367
+ if (vglobal.env === 'browser') {
27368
+ vglobal.removeEventListener('pointermove', this._onHandlerPointerMove, {
27369
+ capture: true
27370
+ });
27371
+ vglobal.removeEventListener('pointerup', this._onHandlerPointerUp);
27372
+ }
27373
+ else {
27374
+ this.stage.removeEventListener('pointermove', this._onHandlerPointerMove, {
27375
+ capture: true
27376
+ });
27377
+ this.stage.removeEventListener('pointerup', this._onHandlerPointerUp);
27378
+ this.stage.removeEventListener('pointerupoutside', this._onHandlerPointerUp);
27379
+ }
27282
27380
  };
27283
27381
  this._onTrackPointerdown = (e) => {
27284
27382
  e.stopPropagation();
27285
- this._clearAllDragEvents();
27286
27383
  this._isChanging = true;
27287
27384
  const { x, y } = this.stage.eventPointTransform(e);
27288
27385
  this._prePos = this._isHorizontal ? x : y;
27289
- const triggers = getEndTriggersOfDrag();
27290
- const obj = vglobal.env === 'browser' ? vglobal : this.stage;
27291
- obj.addEventListener('pointermove', this._onTrackPointerMove, { capture: true });
27292
- triggers.forEach((trigger) => {
27293
- obj.addEventListener(trigger, this._onTrackPointerUp);
27294
- });
27386
+ if (vglobal.env === 'browser') {
27387
+ vglobal.addEventListener('pointermove', this._onTrackPointerMove, {
27388
+ capture: true
27389
+ });
27390
+ vglobal.addEventListener('pointerup', this._onTrackPointerUp);
27391
+ }
27392
+ else {
27393
+ this.stage.addEventListener('pointermove', this._onTrackPointerMove, {
27394
+ capture: true
27395
+ });
27396
+ this.stage.addEventListener('pointerup', this._onTrackPointerUp);
27397
+ this.stage.addEventListener('pointerupoutside', this._onTrackPointerUp);
27398
+ }
27295
27399
  };
27296
27400
  this._onTrackPointerMove = (e) => {
27297
27401
  e.stopPropagation();
@@ -27348,11 +27452,22 @@ class Slider extends AbstractComponent {
27348
27452
  this._onTrackPointerUp = (e) => {
27349
27453
  e.preventDefault();
27350
27454
  this._isChanging = false;
27351
- this._clearAllDragEvents();
27455
+ if (vglobal.env === 'browser') {
27456
+ vglobal.removeEventListener('pointermove', this._onTrackPointerMove, {
27457
+ capture: true
27458
+ });
27459
+ vglobal.removeEventListener('pointerup', this._onTrackPointerUp);
27460
+ }
27461
+ else {
27462
+ this.stage.removeEventListener('pointermove', this._onTrackPointerMove, {
27463
+ capture: true
27464
+ });
27465
+ this.stage.removeEventListener('pointerup', this._onTrackPointerUp);
27466
+ this.stage.removeEventListener('pointerupoutside', this._onTrackPointerUp);
27467
+ }
27352
27468
  };
27353
27469
  this._onRailPointerDown = (e) => {
27354
27470
  e.stopPropagation();
27355
- this._clearAllDragEvents();
27356
27471
  this._isChanging = true;
27357
27472
  const { railWidth, railHeight, min, max } = this.attribute;
27358
27473
  if (max === min) {
@@ -27740,18 +27855,6 @@ class Slider extends AbstractComponent {
27740
27855
  this._mainContainer.addEventListener('pointermove', this._onTooltipUpdate);
27741
27856
  this._mainContainer.addEventListener('pointerleave', this._onTooltipHide);
27742
27857
  }
27743
- _clearAllDragEvents() {
27744
- const triggers = getEndTriggersOfDrag();
27745
- const obj = vglobal.env === 'browser' ? vglobal : this.stage;
27746
- obj.removeEventListener('pointermove', this._onHandlerPointerMove, { capture: true });
27747
- triggers.forEach((trigger) => {
27748
- obj.removeEventListener(trigger, this._onHandlerPointerUp);
27749
- });
27750
- obj.removeEventListener('pointermove', this._onTrackPointerMove, { capture: true });
27751
- triggers.forEach((trigger) => {
27752
- obj.removeEventListener(trigger, this._onTrackPointerUp);
27753
- });
27754
- }
27755
27858
  _updateTrack() {
27756
27859
  const { inverse, railWidth, railHeight } = this.attribute;
27757
27860
  const startHandler = this._startHandler;
@@ -31244,10 +31347,10 @@ class Switch extends AbstractComponent {
31244
31347
  });
31245
31348
  this._circle.setAttributes({
31246
31349
  y: circleY,
31247
- x: this.attribute.checked ? circleX : maxWidth - circleX
31350
+ x: !this.attribute.checked ? circleX : maxWidth - circleX
31248
31351
  });
31249
31352
  this._text.setAttributes({
31250
- x: this.attribute.checked ? textX : maxWidth - textX - textWidth,
31353
+ x: !this.attribute.checked ? textX : maxWidth - textX - textWidth,
31251
31354
  y: textY
31252
31355
  });
31253
31356
  }
@@ -31485,6 +31588,6 @@ StoryLabelItem.defaultAttributes = {
31485
31588
  theme: 'default'
31486
31589
  };
31487
31590
 
31488
- const version = "0.22.7-alpha.4";
31591
+ const version = "0.22.7-alpha.5";
31489
31592
 
31490
31593
  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,5 +7,4 @@ export class CrosshairBase extends AbstractComponent {
7
7
  render() {
8
8
  this.renderCrosshair(this);
9
9
  }
10
- }
11
- //# sourceMappingURL=base.js.map
10
+ }
@@ -1 +1,2 @@
1
- export { };
1
+ export { };
2
+ //# sourceMappingURL=type.js.map
@@ -164,7 +164,6 @@ export declare class DataZoom extends AbstractComponent<Required<DataZoomAttribu
164
164
  x: number;
165
165
  y: number;
166
166
  };
167
- private _clearDragEvents;
168
167
  private _onHandlerPointerDown;
169
168
  private _pointerMove;
170
169
  private _onHandlerPointerMove;