@visactor/vrender-components 0.19.0-alpha.0 → 0.19.0

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 (203) hide show
  1. package/cjs/axis/base.js +4 -5
  2. package/cjs/axis/base.js.map +1 -1
  3. package/cjs/brush/brush.js +14 -16
  4. package/cjs/brush/brush.js.map +1 -1
  5. package/cjs/brush/type.js +1 -2
  6. package/cjs/checkbox/checkbox.d.ts +2 -2
  7. package/cjs/checkbox/checkbox.js +4 -3
  8. package/cjs/checkbox/checkbox.js.map +1 -1
  9. package/cjs/checkbox/register.js +1 -1
  10. package/cjs/checkbox/register.js.map +1 -1
  11. package/cjs/checkbox/type.d.ts +2 -2
  12. package/cjs/checkbox/type.js.map +1 -1
  13. package/cjs/core/base.js +2 -1
  14. package/cjs/core/base.js.map +1 -1
  15. package/cjs/core/type.d.ts +17 -3
  16. package/cjs/core/type.js.map +1 -1
  17. package/cjs/data-zoom/data-zoom.js +2 -7
  18. package/cjs/data-zoom/data-zoom.js.map +1 -1
  19. package/cjs/index.d.ts +2 -1
  20. package/cjs/index.js +3 -2
  21. package/cjs/index.js.map +1 -1
  22. package/cjs/label/arc.d.ts +2 -2
  23. package/cjs/label/arc.js +8 -5
  24. package/cjs/label/arc.js.map +1 -1
  25. package/cjs/label/base.d.ts +2 -2
  26. package/cjs/label/base.js +2 -3
  27. package/cjs/label/base.js.map +1 -1
  28. package/cjs/label/index.js +1 -2
  29. package/cjs/label/line.js +1 -1
  30. package/cjs/label/polygon.js +1 -1
  31. package/cjs/label/rect.js +3 -40
  32. package/cjs/label/rect.js.map +1 -1
  33. package/cjs/label/register.js +1 -1
  34. package/cjs/label/symbol.js +1 -1
  35. package/cjs/label/type.d.ts +4 -4
  36. package/cjs/label/type.js +1 -1
  37. package/cjs/label/type.js.map +1 -1
  38. package/cjs/legend/base.js +1 -1
  39. package/cjs/legend/constant.js +1 -1
  40. package/cjs/legend/discrete/discrete.js +8 -11
  41. package/cjs/legend/discrete/discrete.js.map +1 -1
  42. package/cjs/legend/index.js +1 -1
  43. package/cjs/legend/register.js +1 -1
  44. package/cjs/legend/type.js +2 -1
  45. package/cjs/legend/util.js +1 -1
  46. package/cjs/marker/animate/animate.d.ts +3 -3
  47. package/cjs/marker/animate/animate.js +3 -3
  48. package/cjs/marker/animate/animate.js.map +1 -1
  49. package/cjs/marker/arc-area.d.ts +0 -2
  50. package/cjs/marker/arc-area.js +21 -18
  51. package/cjs/marker/arc-area.js.map +1 -1
  52. package/cjs/marker/arc-line.d.ts +4 -0
  53. package/cjs/marker/arc-line.js +20 -26
  54. package/cjs/marker/arc-line.js.map +1 -1
  55. package/cjs/marker/area.d.ts +0 -2
  56. package/cjs/marker/area.js +9 -8
  57. package/cjs/marker/area.js.map +1 -1
  58. package/cjs/marker/common-line.d.ts +4 -3
  59. package/cjs/marker/common-line.js +3 -2
  60. package/cjs/marker/common-line.js.map +1 -1
  61. package/cjs/marker/config.d.ts +12 -8
  62. package/cjs/marker/config.js +71 -13
  63. package/cjs/marker/config.js.map +1 -1
  64. package/cjs/marker/line.d.ts +5 -5
  65. package/cjs/marker/line.js +7 -69
  66. package/cjs/marker/line.js.map +1 -1
  67. package/cjs/marker/point.d.ts +1 -1
  68. package/cjs/marker/point.js +1 -1
  69. package/cjs/marker/point.js.map +1 -1
  70. package/cjs/marker/register.js.map +1 -1
  71. package/cjs/marker/type.d.ts +6 -6
  72. package/cjs/marker/type.js.map +1 -1
  73. package/cjs/poptip/poptip.js +6 -4
  74. package/cjs/poptip/poptip.js.map +1 -1
  75. package/cjs/poptip/register.js +2 -2
  76. package/cjs/poptip/register.js.map +1 -1
  77. package/cjs/radio/index.d.ts +2 -0
  78. package/cjs/radio/index.js +21 -0
  79. package/cjs/radio/index.js.map +1 -0
  80. package/cjs/radio/radio.d.ts +16 -0
  81. package/cjs/radio/radio.js +89 -0
  82. package/cjs/radio/radio.js.map +1 -0
  83. package/cjs/radio/register.d.ts +1 -0
  84. package/cjs/radio/register.js +15 -0
  85. package/cjs/radio/register.js.map +1 -0
  86. package/cjs/radio/type.d.ts +21 -0
  87. package/cjs/radio/type.js +6 -0
  88. package/cjs/radio/type.js.map +1 -0
  89. package/cjs/scrollbar/scrollbar.js +5 -5
  90. package/cjs/scrollbar/scrollbar.js.map +1 -1
  91. package/cjs/slider/slider.js +19 -15
  92. package/cjs/slider/slider.js.map +1 -1
  93. package/cjs/tag/tag.d.ts +1 -1
  94. package/cjs/tag/tag.js.map +1 -1
  95. package/cjs/title/register.js +1 -2
  96. package/cjs/title/register.js.map +1 -1
  97. package/cjs/title/title.js +6 -4
  98. package/cjs/title/title.js.map +1 -1
  99. package/cjs/util/text.d.ts +4 -0
  100. package/cjs/util/text.js +28 -3
  101. package/cjs/util/text.js.map +1 -1
  102. package/es/axis/base.js +4 -5
  103. package/es/axis/base.js.map +1 -1
  104. package/es/brush/brush.js +15 -17
  105. package/es/brush/brush.js.map +1 -1
  106. package/es/brush/type.js +1 -2
  107. package/es/checkbox/checkbox.d.ts +2 -2
  108. package/es/checkbox/checkbox.js +5 -3
  109. package/es/checkbox/checkbox.js.map +1 -1
  110. package/es/checkbox/register.js +2 -2
  111. package/es/checkbox/register.js.map +1 -1
  112. package/es/checkbox/type.d.ts +2 -2
  113. package/es/checkbox/type.js.map +1 -1
  114. package/es/core/base.js +2 -1
  115. package/es/core/base.js.map +1 -1
  116. package/es/core/type.d.ts +17 -3
  117. package/es/core/type.js.map +1 -1
  118. package/es/data-zoom/data-zoom.js +2 -7
  119. package/es/data-zoom/data-zoom.js.map +1 -1
  120. package/es/index.d.ts +2 -1
  121. package/es/index.js +3 -1
  122. package/es/index.js.map +1 -1
  123. package/es/label/arc.d.ts +2 -2
  124. package/es/label/arc.js +8 -5
  125. package/es/label/arc.js.map +1 -1
  126. package/es/label/base.d.ts +2 -2
  127. package/es/label/base.js +3 -3
  128. package/es/label/base.js.map +1 -1
  129. package/es/label/index.js +1 -2
  130. package/es/label/line.js +1 -1
  131. package/es/label/polygon.js +1 -1
  132. package/es/label/rect.js +3 -41
  133. package/es/label/rect.js.map +1 -1
  134. package/es/label/register.js +1 -1
  135. package/es/label/symbol.js +1 -1
  136. package/es/label/type.d.ts +4 -4
  137. package/es/label/type.js +1 -1
  138. package/es/label/type.js.map +1 -1
  139. package/es/legend/base.js +1 -1
  140. package/es/legend/constant.js +1 -1
  141. package/es/legend/discrete/discrete.js +9 -10
  142. package/es/legend/discrete/discrete.js.map +1 -1
  143. package/es/legend/index.js +1 -1
  144. package/es/legend/register.js +1 -1
  145. package/es/legend/type.js +2 -1
  146. package/es/legend/util.js +1 -1
  147. package/es/marker/animate/animate.d.ts +3 -3
  148. package/es/marker/animate/animate.js +1 -1
  149. package/es/marker/animate/animate.js.map +1 -1
  150. package/es/marker/arc-area.d.ts +0 -2
  151. package/es/marker/arc-area.js +22 -19
  152. package/es/marker/arc-area.js.map +1 -1
  153. package/es/marker/arc-line.d.ts +4 -0
  154. package/es/marker/arc-line.js +22 -28
  155. package/es/marker/arc-line.js.map +1 -1
  156. package/es/marker/area.d.ts +0 -2
  157. package/es/marker/area.js +10 -9
  158. package/es/marker/area.js.map +1 -1
  159. package/es/marker/common-line.d.ts +4 -3
  160. package/es/marker/common-line.js +3 -2
  161. package/es/marker/common-line.js.map +1 -1
  162. package/es/marker/config.d.ts +12 -8
  163. package/es/marker/config.js +74 -12
  164. package/es/marker/config.js.map +1 -1
  165. package/es/marker/line.d.ts +5 -5
  166. package/es/marker/line.js +8 -72
  167. package/es/marker/line.js.map +1 -1
  168. package/es/marker/point.d.ts +1 -1
  169. package/es/marker/point.js +1 -1
  170. package/es/marker/point.js.map +1 -1
  171. package/es/marker/register.js.map +1 -1
  172. package/es/marker/type.d.ts +6 -6
  173. package/es/marker/type.js.map +1 -1
  174. package/es/poptip/poptip.js +6 -4
  175. package/es/poptip/poptip.js.map +1 -1
  176. package/es/poptip/register.js +2 -2
  177. package/es/poptip/register.js.map +1 -1
  178. package/es/radio/index.d.ts +2 -0
  179. package/es/radio/index.js +4 -0
  180. package/es/radio/index.js.map +1 -0
  181. package/es/radio/radio.d.ts +16 -0
  182. package/es/radio/radio.js +88 -0
  183. package/es/radio/radio.js.map +1 -0
  184. package/es/radio/register.d.ts +1 -0
  185. package/es/radio/register.js +6 -0
  186. package/es/radio/register.js.map +1 -0
  187. package/es/radio/type.d.ts +21 -0
  188. package/es/radio/type.js +2 -0
  189. package/es/radio/type.js.map +1 -0
  190. package/es/scrollbar/scrollbar.js +5 -5
  191. package/es/scrollbar/scrollbar.js.map +1 -1
  192. package/es/slider/slider.js +19 -15
  193. package/es/slider/slider.js.map +1 -1
  194. package/es/tag/tag.d.ts +1 -1
  195. package/es/tag/tag.js.map +1 -1
  196. package/es/title/register.js +2 -2
  197. package/es/title/register.js.map +1 -1
  198. package/es/title/title.js +6 -4
  199. package/es/title/title.js.map +1 -1
  200. package/es/util/text.d.ts +4 -0
  201. package/es/util/text.js +25 -2
  202. package/es/util/text.js.map +1 -1
  203. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAN,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,qCAAW,CAAA;IACX,2DAAiC,CAAA;IACjC,iEAAuC,CAAA;IACvC,6DAAmC,CAAA;IACnC,mEAAyC,CAAA;IACzC,uDAA6B,CAAA;IAC7B,6DAAmC,CAAA;AACrC,CAAC,EAVW,sBAAsB,KAAtB,sBAAsB,QAUjC;AAED,MAAM,CAAN,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAC3B,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;AAC/B,CAAC,EAVW,sBAAsB,KAAtB,sBAAsB,QAUjC;AAED,MAAM,CAAN,IAAY,2BAQX;AARD,WAAY,2BAA2B;IACrC,8DAA+B,CAAA;IAC/B,0DAA2B,CAAA;IAC3B,gEAAiC,CAAA;IACjC,8DAA+B,CAAA;IAC/B,0DAA2B,CAAA;IAC3B,gEAAiC,CAAA;IACjC,gDAAiB,CAAA;AACnB,CAAC,EARW,2BAA2B,KAA3B,2BAA2B,QAQtC;AAED,MAAM,CAAN,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,uDAA6B,CAAA;AAC/B,CAAC,EAPW,sBAAsB,KAAtB,sBAAsB,QAOjC","file":"type.js","sourcesContent":["import type {\n EasingType,\n IArcGraphicAttribute,\n IGroup,\n IGroupGraphicAttribute,\n IImageGraphicAttribute,\n ILineGraphicAttribute,\n IPolygonAttribute,\n IPolygonGraphicAttribute,\n IRectGraphicAttribute,\n IRichTextGraphicAttribute,\n ISymbolGraphicAttribute,\n ITextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type {\n ArcSegmentAttributes,\n CommonSegmentAttributes,\n ILineGraphicWithCornerRadius,\n SegmentAttributes,\n SymbolAttributes\n} from '../segment';\nimport type { TagAttributes } from '../tag';\nimport type { Point, State } from '../core/type';\n\nexport enum IMarkLineLabelPosition {\n start = 'start',\n middle = 'middle',\n end = 'end',\n insideStartTop = 'insideStartTop',\n insideStartBottom = 'insideStartBottom',\n insideMiddleTop = 'insideMiddleTop',\n insideMiddleBottom = 'insideMiddleBottom',\n insideEndTop = 'insideEndTop',\n insideEndBottom = 'insideEndBottom'\n}\n\nexport enum IMarkAreaLabelPosition {\n left = 'left',\n right = 'right',\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideLeft = 'insideLeft',\n insideRight = 'insideRight',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom'\n}\n\nexport enum IMarkCommonArcLabelPosition {\n arcInnerStart = 'arcInnerStart',\n arcInnerEnd = 'arcInnerEnd',\n arcInnerMiddle = 'arcInnerMiddle',\n arcOuterStart = 'arcOuterStart',\n arcOuterEnd = 'arcOuterEnd',\n arcOuterMiddle = 'arcOuterMiddle',\n center = 'center'\n}\n\nexport enum IMarkPointItemPosition {\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom',\n insideMiddle = 'insideMiddle'\n}\n\nexport type IMarkBackgroundAttributes = {\n /**\n * 是否绘制背景层\n */\n visible: boolean;\n /**\n * TODO: 根据文字宽度进行背景 panel size自适应\n */\n autoHeight?: boolean;\n /**\n * TODO: 根据文高度度进行背景 panel size自适应\n */\n autoWidth?: boolean;\n} & Partial<SymbolAttributes>;\n\nexport type IMarkLabel = Omit<TagAttributes, 'x' | 'y' | 'panel'> & {\n /**\n * 标签的背景面板配置\n */\n panel?: IMarkBackgroundAttributes;\n};\n\nexport type IMarkRef = {\n /**\n * 自动旋转,沿着线的方向,默认 true\n */\n autoRotate?: boolean;\n /**\n * label 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * label 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * label 相对默认角度的偏移 (label跟随line的角度做自动旋转时,默认按照line的平行向量作为初始角度)\n */\n refAngle?: number;\n};\n\nexport type MarkerAttrs<AnimationType> = IGroupGraphicAttribute & {\n type?: 'line' | 'arc-line' | 'area' | 'arc-area' | 'point';\n /**\n * 是否支持交互\n * @default true\n */\n interactive?: boolean;\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 是否显示marker组件\n * @default true\n */\n visible?: boolean;\n /**\n * 是否将组件在绘制区域内进行剪切\n * @default true\n */\n clipInRange?: boolean;\n /**\n * 组件绘制范围配置\n */\n limitRect?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n} & BaseMarkerAnimation<AnimationType>;\n\n/** animation type */\nexport type BaseMarkerAnimation<T> = {\n animation?: MarkerAnimation<T> | boolean;\n animationEnter?: MarkerUpdateAnimation<T>;\n animationUpdate?: MarkerUpdateAnimation<T>;\n animationExit?: MarkerExitAnimation;\n};\nexport type MarkerAnimation<T> = MarkerUpdateAnimation<T> | MarkerUpdateAnimation<T>;\n\nexport type MarkerUpdateAnimation<T> = {\n type: T;\n} & MarkerExitAnimation;\n\nexport type CommonMarkLineAnimationType = 'clipIn' | 'fadeIn';\n\nexport type CommonMarkAreaAnimationType = 'fadeIn';\n\nexport type MarkPointAnimationType = 'callIn' | 'fadeIn';\n\nexport type MarkerExitAnimation = {\n type: 'fadeOut';\n duration?: number;\n delay?: number;\n easing?: EasingType;\n};\n\nexport type MarkerAnimationState = 'enter' | 'update' | 'exit';\n\n/** state type */\nexport type CommonMarkLineState<LineAttr> = {\n line?: State<LineAttr>;\n lineStartSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n lineEndSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n label?: State<Partial<ITextGraphicAttribute>>;\n labelBackground?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type CommonMarkAreaState<AreaAttr> = {\n area?: State<Partial<AreaAttr>>;\n label?: State<Partial<ITextGraphicAttribute>>;\n labelBackground?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type MarkPointState = {\n line?: State<ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[]>;\n lineStartSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n lineEndSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n symbol?: State<Partial<ISymbolGraphicAttribute>>;\n image?: State<Partial<IImageGraphicAttribute>>;\n text?: State<Partial<ITextGraphicAttribute>>;\n textBackground?: State<Partial<IRectGraphicAttribute>>;\n richText?: State<Partial<IRichTextGraphicAttribute>>;\n customMark?: State<Partial<IGroupGraphicAttribute>>;\n};\n\nexport type CommonMarkLineAttrs<LineAttr, LineLabelPosition, CommonMarkLineAnimationType> =\n MarkerAttrs<CommonMarkLineAnimationType> &\n Omit<CommonSegmentAttributes, 'state' | 'lineStyle'> & {\n /**\n * 标签\n */\n label?: {\n /**\n * label 相对line的位置\n */\n position?: LineLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkRef &\n IMarkLabel;\n state?: CommonMarkLineState<LineAttr>;\n };\n\nexport type MarkLineAttrs = CommonMarkLineAttrs<\n ILineGraphicWithCornerRadius | ILineGraphicAttribute[],\n keyof typeof IMarkLineLabelPosition,\n CommonMarkLineAnimationType\n> & {\n type?: 'line';\n /**\n * 是否对 points 进行多段处理,默认为 false,即直接将所有的点连接成线。\n * 如果需要进行多段处理,需要将 points 属性配置为 Point[][] 类型\n * @default false\n */\n multiSegment?: boolean;\n /**\n * 在 `multiSegment` 属性开启的前提下,用于声明那一段线段用来作为主线段,如果不声明,默认全段为主线段\n */\n mainSegmentIndex?: number;\n /**\n * 构成line的点: 如果是两个点,则为直线;多个点则为曲线\n */\n points: Point[] | Point[][];\n lineStyle?: ILineGraphicAttribute;\n};\n\nexport type MarkArcLineAttrs = CommonMarkLineAttrs<\n IArcGraphicAttribute,\n keyof typeof IMarkCommonArcLabelPosition,\n CommonMarkLineAnimationType\n> & {\n type?: 'arc-line';\n /**\n * 弧线中心位置\n */\n center: {\n x: number;\n y: number;\n };\n /**\n * 弧线半径\n */\n radius: number;\n /**\n * 弧线起始角度(弧度)\n */\n startAngle: number;\n /**\n * 弧线终点角度(弧度)\n */\n endAngle: number;\n lineStyle?: IArcGraphicAttribute;\n};\n\nexport type MarkAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {\n type?: 'area';\n /**\n * 构成area的点\n */\n points: Point[];\n /**\n * 标签\n */\n label?: {\n position?: keyof typeof IMarkAreaLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IPolygonAttribute;\n\n state?: CommonMarkAreaState<IPolygonGraphicAttribute>;\n};\n\nexport type MarkArcAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {\n type?: 'arc-area';\n /**\n * 扇区中心位置\n */\n center: {\n x: number;\n y: number;\n };\n /**\n * 扇区内半径\n */\n innerRadius: number;\n /**\n * 扇区外半径\n */\n outerRadius: number;\n /**\n * 扇区起始角度(弧度)\n */\n startAngle: number;\n /**\n * 扇区终点角度(弧度)\n */\n endAngle: number;\n /**\n * 标签\n */\n label?: {\n position?: keyof typeof IMarkCommonArcLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkRef &\n IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IArcGraphicAttribute;\n\n state?: CommonMarkAreaState<IArcGraphicAttribute>;\n};\n\nexport type IItemContent = IMarkRef & {\n /**\n * 标注类型\n * Tips: 保留'richText'与之前的定义做兼容\n */\n type?: 'symbol' | 'text' | 'image' | 'richText' | 'custom';\n position?: keyof typeof IMarkPointItemPosition;\n /**\n * x 方向偏移量\n */\n offsetX?: number;\n /**\n * y 方向偏移量\n */\n offsetY?: number;\n /**\n * type为symbol时, symbol的样式\n */\n symbolStyle?: ISymbolGraphicAttribute;\n /**\n * type为image时, image的样式\n */\n imageStyle?: IImageGraphicAttribute;\n /**\n * type为text时, text的配置\n * 'text'类型的ItemContent新增三种子类型:'text','rich','html'。配置在textStyle.type上,继承自TagAttributes。\n */\n textStyle?: IMarkLabel;\n /**\n * type为rich text时, rich text的样式\n */\n richTextStyle?: IRichTextGraphicAttribute;\n /**\n * type为custom时,允许以callback的方式传入需要render的item\n */\n renderCustomCallback?: () => IGroup;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n};\n\nexport type IItemLine = {\n /** TODO:'type-opo' */\n type?: 'type-s' | 'type-do' | 'type-po' | 'type-op';\n visible?: boolean;\n /**\n * 垂直于引导线的装饰线,参考案例: https://observablehq.com/@mikelotis/edmonton-population-history-line-chart\n */\n decorativeLine?: {\n visible?: boolean;\n length?: number;\n };\n} & Omit<SegmentAttributes, 'points'>;\n\nexport type MarkPointAttrs = Omit<MarkerAttrs<MarkPointAnimationType>, 'labelStyle'> & {\n /**\n * markPoint的位置(也是path的起点)\n */\n position: Point;\n /**\n * 标注引导线\n */\n itemLine?: IItemLine;\n\n /**\n * 标注内容\n */\n itemContent?: IItemContent;\n\n state?: MarkPointState;\n} & BaseMarkerAnimation<MarkPointAnimationType>;\n"]}
1
+ {"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAN,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,qCAAW,CAAA;IACX,2DAAiC,CAAA;IACjC,iEAAuC,CAAA;IACvC,6DAAmC,CAAA;IACnC,mEAAyC,CAAA;IACzC,uDAA6B,CAAA;IAC7B,6DAAmC,CAAA;AACrC,CAAC,EAVW,sBAAsB,KAAtB,sBAAsB,QAUjC;AAED,MAAM,CAAN,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAC3B,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;AAC/B,CAAC,EAVW,sBAAsB,KAAtB,sBAAsB,QAUjC;AAED,MAAM,CAAN,IAAY,2BAQX;AARD,WAAY,2BAA2B;IACrC,8DAA+B,CAAA;IAC/B,0DAA2B,CAAA;IAC3B,gEAAiC,CAAA;IACjC,8DAA+B,CAAA;IAC/B,0DAA2B,CAAA;IAC3B,gEAAiC,CAAA;IACjC,gDAAiB,CAAA;AACnB,CAAC,EARW,2BAA2B,KAA3B,2BAA2B,QAQtC;AAED,MAAM,CAAN,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,uDAA6B,CAAA;AAC/B,CAAC,EAPW,sBAAsB,KAAtB,sBAAsB,QAOjC","file":"type.js","sourcesContent":["import type {\n EasingType,\n IArcGraphicAttribute,\n IGroup,\n IGroupGraphicAttribute,\n IImageGraphicAttribute,\n ILineGraphicAttribute,\n IPolygonAttribute,\n IPolygonGraphicAttribute,\n IRectGraphicAttribute,\n IRichTextGraphicAttribute,\n ISymbolGraphicAttribute,\n ITextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type {\n ArcSegmentAttributes,\n CommonSegmentAttributes,\n ILineGraphicWithCornerRadius,\n SegmentAttributes,\n SymbolAttributes\n} from '../segment';\nimport type { TagAttributes } from '../tag';\nimport type { Point, State } from '../core/type';\n\nexport enum IMarkLineLabelPosition {\n start = 'start',\n middle = 'middle',\n end = 'end',\n insideStartTop = 'insideStartTop',\n insideStartBottom = 'insideStartBottom',\n insideMiddleTop = 'insideMiddleTop',\n insideMiddleBottom = 'insideMiddleBottom',\n insideEndTop = 'insideEndTop',\n insideEndBottom = 'insideEndBottom'\n}\n\nexport enum IMarkAreaLabelPosition {\n left = 'left',\n right = 'right',\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideLeft = 'insideLeft',\n insideRight = 'insideRight',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom'\n}\n\nexport enum IMarkCommonArcLabelPosition {\n arcInnerStart = 'arcInnerStart',\n arcInnerEnd = 'arcInnerEnd',\n arcInnerMiddle = 'arcInnerMiddle',\n arcOuterStart = 'arcOuterStart',\n arcOuterEnd = 'arcOuterEnd',\n arcOuterMiddle = 'arcOuterMiddle',\n center = 'center'\n}\n\nexport enum IMarkPointItemPosition {\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom',\n insideMiddle = 'insideMiddle'\n}\n\nexport type IMarkBackgroundAttributes = {\n /**\n * 是否绘制背景层\n */\n visible: boolean;\n /**\n * TODO: 根据文字宽度进行背景 panel size自适应\n */\n autoHeight?: boolean;\n /**\n * TODO: 根据文高度度进行背景 panel size自适应\n */\n autoWidth?: boolean;\n} & Partial<SymbolAttributes>;\n\nexport type IMarkLabel = Omit<TagAttributes, 'x' | 'y' | 'panel'> & {\n /**\n * 标签的背景面板配置\n */\n panel?: IMarkBackgroundAttributes;\n};\n\nexport type IMarkRef = {\n /**\n * 自动旋转,沿着线的方向\n * @default\n * mark-line/mark-area/mark-point: false - 旧逻辑里autoRotate是false, 保持不变\n * mark-arc-line/mark-arc-area: true - 新增逻辑, 如果不开启的话, 效果不太好, 所以默认true\n * mark-point - 旧逻辑里autoRotate是true, 保持不变\n */\n autoRotate?: boolean;\n /**\n * label 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * label 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * label 相对默认角度的偏移 (label跟随line的角度做自动旋转时,默认按照line的平行向量作为初始角度)\n */\n refAngle?: number;\n};\n\nexport type MarkerAttrs<AnimationType> = IGroupGraphicAttribute & {\n type?: 'line' | 'arc-line' | 'area' | 'arc-area' | 'point';\n /**\n * 是否支持交互\n * @default true\n */\n interactive?: boolean;\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 是否显示marker组件\n * @default true\n */\n visible?: boolean;\n /**\n * 是否将组件在绘制区域内进行剪切\n * @default true\n */\n clipInRange?: boolean;\n /**\n * 组件绘制范围配置\n */\n limitRect?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n} & BaseMarkerAnimation<AnimationType>;\n\n/** animation type */\nexport type BaseMarkerAnimation<T> = {\n animation?: MarkerAnimation<T> | boolean;\n animationEnter?: MarkerUpdateAnimation<T>;\n animationUpdate?: MarkerUpdateAnimation<T>;\n animationExit?: MarkerExitAnimation;\n};\nexport type MarkerAnimation<T> = MarkerUpdateAnimation<T> | MarkerUpdateAnimation<T>;\n\nexport type MarkerUpdateAnimation<T> = {\n type: T;\n} & MarkerExitAnimation;\n\nexport type MarkCommonLineAnimationType = 'clipIn' | 'fadeIn';\n\nexport type CommonMarkAreaAnimationType = 'fadeIn';\n\nexport type MarkPointAnimationType = 'callIn' | 'fadeIn';\n\nexport type MarkerExitAnimation = {\n type: 'fadeOut';\n duration?: number;\n delay?: number;\n easing?: EasingType;\n};\n\nexport type MarkerAnimationState = 'enter' | 'update' | 'exit';\n\n/** state type */\nexport type MarkCommonLineState<LineAttr> = {\n line?: State<LineAttr>;\n lineStartSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n lineEndSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n label?: State<Partial<ITextGraphicAttribute>>;\n labelBackground?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type CommonMarkAreaState<AreaAttr> = {\n area?: State<Partial<AreaAttr>>;\n label?: State<Partial<ITextGraphicAttribute>>;\n labelBackground?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type MarkPointState = {\n line?: State<ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[]>;\n lineStartSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n lineEndSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n symbol?: State<Partial<ISymbolGraphicAttribute>>;\n image?: State<Partial<IImageGraphicAttribute>>;\n text?: State<Partial<ITextGraphicAttribute>>;\n textBackground?: State<Partial<IRectGraphicAttribute>>;\n richText?: State<Partial<IRichTextGraphicAttribute>>;\n customMark?: State<Partial<IGroupGraphicAttribute>>;\n};\n\nexport type MarkCommonLineAttrs<LineAttr, LineLabelPosition, MarkCommonLineAnimationType> =\n MarkerAttrs<MarkCommonLineAnimationType> &\n Omit<CommonSegmentAttributes, 'state' | 'lineStyle'> & {\n /**\n * 标签\n */\n label?: {\n /**\n * label 相对line的位置\n */\n position?: LineLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkRef &\n IMarkLabel;\n state?: MarkCommonLineState<LineAttr>;\n };\n\nexport type MarkLineAttrs = MarkCommonLineAttrs<\n ILineGraphicWithCornerRadius | ILineGraphicAttribute[],\n keyof typeof IMarkLineLabelPosition,\n MarkCommonLineAnimationType\n> & {\n type?: 'line';\n /**\n * 是否对 points 进行多段处理,默认为 false,即直接将所有的点连接成线。\n * 如果需要进行多段处理,需要将 points 属性配置为 Point[][] 类型\n * @default false\n */\n multiSegment?: boolean;\n /**\n * 在 `multiSegment` 属性开启的前提下,用于声明那一段线段用来作为主线段,如果不声明,默认全段为主线段\n */\n mainSegmentIndex?: number;\n /**\n * 构成line的点: 如果是两个点,则为直线;多个点则为曲线\n */\n points: Point[] | Point[][];\n lineStyle?: ILineGraphicAttribute;\n};\n\nexport type MarkArcLineAttrs = MarkCommonLineAttrs<\n IArcGraphicAttribute,\n keyof typeof IMarkCommonArcLabelPosition,\n MarkCommonLineAnimationType\n> & {\n type?: 'arc-line';\n /**\n * 弧线中心位置\n */\n center: {\n x: number;\n y: number;\n };\n /**\n * 弧线半径\n */\n radius: number;\n /**\n * 弧线起始角度(弧度)\n */\n startAngle: number;\n /**\n * 弧线终点角度(弧度)\n */\n endAngle: number;\n lineStyle?: IArcGraphicAttribute;\n};\n\nexport type MarkAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {\n type?: 'area';\n /**\n * 构成area的点\n */\n points: Point[];\n /**\n * 标签\n */\n label?: {\n position?: keyof typeof IMarkAreaLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IPolygonAttribute;\n\n state?: CommonMarkAreaState<IPolygonGraphicAttribute>;\n};\n\nexport type MarkArcAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {\n type?: 'arc-area';\n /**\n * 扇区中心位置\n */\n center: {\n x: number;\n y: number;\n };\n /**\n * 扇区内半径\n */\n innerRadius: number;\n /**\n * 扇区外半径\n */\n outerRadius: number;\n /**\n * 扇区起始角度(弧度)\n */\n startAngle: number;\n /**\n * 扇区终点角度(弧度)\n */\n endAngle: number;\n /**\n * 标签\n */\n label?: {\n position?: keyof typeof IMarkCommonArcLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkRef &\n IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IArcGraphicAttribute;\n\n state?: CommonMarkAreaState<IArcGraphicAttribute>;\n};\n\nexport type IItemContent = IMarkRef & {\n /**\n * 标注类型\n * Tips: 保留'richText'与之前的定义做兼容\n */\n type?: 'symbol' | 'text' | 'image' | 'richText' | 'custom';\n position?: keyof typeof IMarkPointItemPosition;\n /**\n * x 方向偏移量\n */\n offsetX?: number;\n /**\n * y 方向偏移量\n */\n offsetY?: number;\n /**\n * type为symbol时, symbol的样式\n */\n symbolStyle?: ISymbolGraphicAttribute;\n /**\n * type为image时, image的样式\n */\n imageStyle?: IImageGraphicAttribute;\n /**\n * type为text时, text的配置\n * 'text'类型的ItemContent新增三种子类型:'text','rich','html'。配置在textStyle.type上,继承自TagAttributes。\n */\n textStyle?: IMarkLabel;\n /**\n * type为rich text时, rich text的样式\n */\n richTextStyle?: IRichTextGraphicAttribute;\n /**\n * type为custom时,允许以callback的方式传入需要render的item\n */\n renderCustomCallback?: () => IGroup;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n};\n\nexport type IItemLine = {\n /** TODO:'type-opo' */\n type?: 'type-s' | 'type-do' | 'type-po' | 'type-op';\n visible?: boolean;\n /**\n * 垂直于引导线的装饰线,参考案例: https://observablehq.com/@mikelotis/edmonton-population-history-line-chart\n */\n decorativeLine?: {\n visible?: boolean;\n length?: number;\n };\n} & Omit<SegmentAttributes, 'points'>;\n\nexport type MarkPointAttrs = Omit<MarkerAttrs<MarkPointAnimationType>, 'labelStyle'> & {\n /**\n * markPoint的位置(也是path的起点)\n */\n position: Point;\n /**\n * 标注引导线\n */\n itemLine?: IItemLine;\n\n /**\n * 标注内容\n */\n itemContent?: IItemContent;\n\n state?: MarkPointState;\n} & BaseMarkerAnimation<MarkPointAnimationType>;\n"]}
@@ -35,28 +35,30 @@ export class PopTip extends AbstractComponent {
35
35
  zIndex: 1
36
36
  }, "group"), maxLineWidth = maxWidth - parsedPadding[1] - parsedPadding[3], titleVisible = isValid(title) && !1 !== visible, titleAttrs = Object.assign(Object.assign({
37
37
  text: isArray(title) ? title : [ title ],
38
- visible: titleVisible
38
+ visible: titleVisible,
39
+ wrap: !0
39
40
  }, titleStyle), {
40
41
  x: parsedPadding[3],
41
42
  y: parsedPadding[0],
42
43
  maxLineWidth: maxLineWidth,
43
44
  textAlign: "left",
44
45
  textBaseline: "top"
45
- }), titleShape = group.createOrUpdateChild("poptip-title", titleAttrs, "wrapText");
46
+ }), titleShape = group.createOrUpdateChild("poptip-title", titleAttrs, "text");
46
47
  isEmpty(null == state ? void 0 : state.title) || (titleShape.states = state.title);
47
48
  const titleBounds = titleShape.AABBBounds, titleHeight = titleBounds.height(), titleWidth = titleBounds.width();
48
49
  let height = titleHeight + space;
49
50
  titleVisible || (height = 0);
50
51
  const contentVisible = isValid(content) && !1 !== visible, contentAttrs = Object.assign(Object.assign({
51
52
  text: isArray(content) ? content : [ content ],
52
- visible: contentVisible
53
+ visible: contentVisible,
54
+ wrap: !0
53
55
  }, contentStyle), {
54
56
  x: parsedPadding[3],
55
57
  y: parsedPadding[0] + height,
56
58
  maxLineWidth: maxLineWidth,
57
59
  textAlign: "left",
58
60
  textBaseline: "top"
59
- }), contentShape = group.createOrUpdateChild("poptip-content", contentAttrs, "wrapText");
61
+ }), contentShape = group.createOrUpdateChild("poptip-content", contentAttrs, "text");
60
62
  isEmpty(null == state ? void 0 : state.content) || (contentShape.states = state.content);
61
63
  const contentBounds = contentShape.AABBBounds, contentHeight = contentBounds.height(), contentWidth = contentBounds.width();
62
64
  contentVisible && (height += contentHeight);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/poptip/poptip.ts"],"names":[],"mappings":";;;;;;;;;;;AAaA,OAAO,EACL,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,EACP,GAAG,EACH,KAAK,EACL,gBAAgB,EAChB,EAAE,EACF,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,QAAQ,GAAG,IAAI,UAAU,EAAE,CAAC;AAElC,mBAAmB,EAAE,CAAC;AACtB,MAAM,OAAO,MAAO,SAAQ,iBAA6C;IAyBvE,YAAY,UAA4B,EAAE,OAA0B;QAClE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAzB7F,SAAI,GAAG,QAAQ,CAAC;QA2OhB,iBAAY,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAjNlG,CAAC;IAES,MAAM;;QACd,MAAM,EACJ,UAAU,GAAG,EAA2B,EACxC,QAAQ,EACR,YAAY,GAAG,EAA2B,EAC1C,KAAK,GAAG,EAAyE,EACjF,KAAK,GAAG,CAAC,EACT,QAAQ,G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AAI;gBACP,OAAO;oBACL,KAAK,EAAE,EAAE;oBACT,MAAM,EAAE,CAAC,KAAK,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;oBACzC,UAAU,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;iBACjD,CAAC;SACL;IACH,CAAC;;AAzRM,wBAAiB,GAA8B;IACpD,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,IAAI;IACb,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,YAAY,EAAE;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,eAAe,EAAE,GAAG;IACpB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,EAAE;CACZ,CAAC","file":"poptip.js","sourcesContent":["/**\n * @description PopTip组件\n */\nimport type {\n IGroup,\n IRect,\n ISymbol,\n ISymbolGraphicAttribute,\n IText,\n ITextGraphicAttribute,\n TextAlignType,\n TextBaselineType\n} from '@visactor/vrender-core';\nimport {\n AABBBounds,\n Bounds,\n getRectIntersect,\n isArray,\n isBoolean,\n isEmpty,\n isValid,\n max,\n merge,\n normalizePadding,\n pi,\n rectInsideAnotherRect\n} from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { BackgroundAttributes, ComponentOptions } from '../interface';\nimport type { PopTipAttributes } from './type';\nimport { loadPoptipComponent } from './register';\n\nconst _tBounds = new AABBBounds();\n\nloadPoptipComponent();\nexport class PopTip extends AbstractComponent<Required<PopTipAttributes>> {\n name = 'poptip';\n\n static defaultAttributes: Partial<PopTipAttributes> = {\n position: 'rt',\n visible: true,\n title: null,\n content: null,\n titleStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'left',\n textBaseline: 'top'\n },\n contentStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'left',\n textBaseline: 'top'\n },\n maxWidthPercent: 0.8,\n space: 8,\n padding: 10\n };\n\n constructor(attributes: PopTipAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, PopTip.defaultAttributes, attributes));\n }\n\n protected render() {\n const {\n titleStyle = {} as ITextGraphicAttribute,\n position,\n contentStyle = {} as ITextGraphicAttribute,\n panel = {} as BackgroundAttributes & ISymbolGraphicAttribute & { space?: number },\n space = 4,\n minWidth = 0,\n maxWidth = Infinity,\n padding = 4,\n maxWidthPercent,\n visible,\n state,\n dx = 0,\n dy = 0\n } = this.attribute as PopTipAttributes;\n\n let { title = '', content = '' } = this.attribute as PopTipAttributes;\n\n title = this.attribute.titleFormatMethod ? this.attribute.titleFormatMethod(title) : title;\n content = this.attribute.contentFormatMethod ? this.attribute.contentFormatMethod(content) : content;\n\n const parsedPadding = normalizePadding(padding);\n\n const group = this.createOrUpdateChild('poptip-content', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup;\n\n const maxLineWidth = maxWidth - parsedPadding[1] - parsedPadding[3];\n\n const titleVisible = isValid(title) && visible !== false;\n const titleAttrs = {\n text: isArray(title) ? title : ([title] as any),\n visible: titleVisible,\n ...titleStyle,\n x: parsedPadding[3],\n y: parsedPadding[0],\n maxLineWidth,\n textAlign: 'left' as TextAlignType,\n textBaseline: 'top' as TextBaselineType\n };\n\n const titleShape = group.createOrUpdateChild('poptip-title', titleAttrs, 'wrapText') as IText;\n if (!isEmpty(state?.title)) {\n titleShape.states = state.title;\n }\n\n const titleBounds = titleShape.AABBBounds;\n const titleHeight = titleBounds.height();\n const titleWidth = titleBounds.width();\n let height = titleHeight + space;\n if (!titleVisible) {\n height = 0;\n }\n\n const contentVisible = isValid(content) && visible !== false;\n const contentAttrs = {\n text: isArray(content) ? content : ([content] as any),\n visible: contentVisible,\n ...contentStyle,\n x: parsedPadding[3],\n y: parsedPadding[0] + height,\n maxLineWidth,\n textAlign: 'left' as TextAlignType,\n textBaseline: 'top' as TextBaselineType\n };\n\n const contentShape = group.createOrUpdateChild('poptip-content', contentAttrs, 'wrapText') as IText;\n if (!isEmpty(state?.content)) {\n contentShape.states = state.content;\n }\n\n const contentBounds = contentShape.AABBBounds;\n const contentHeight = contentBounds.height();\n const contentWidth = contentBounds.width();\n\n if (contentVisible) {\n height += contentHeight;\n }\n\n // 计算整个popTip的宽高\n let popTipWidth = max(\n titleWidth + parsedPadding[1] + parsedPadding[3],\n contentWidth + parsedPadding[1] + parsedPadding[3]\n );\n if (popTipWidth > maxWidth) {\n popTipWidth = maxWidth;\n } else if (popTipWidth < minWidth) {\n popTipWidth = minWidth;\n }\n let poptipHeight = parsedPadding[0] + parsedPadding[2] + height;\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n const symbolSize = backgroundStyle.size ?? 12;\n const spaceSize: number | [number, number] = isArray(symbolSize)\n ? [symbolSize[0] + (backgroundStyle.space ?? 0), symbolSize[1] + (backgroundStyle.space ?? 0)]\n : (symbolSize as number) + (backgroundStyle.space ?? 0);\n const lineWidth = backgroundStyle.lineWidth ?? 1;\n const range: [number, number] | undefined = (this as any).stage\n ? [\n (this as any).stage.viewWidth ?? (this as any).stage.width,\n (this as any).stage.viewHeight ?? (this as any).stage.height\n ]\n : undefined;\n\n if (range) {\n // 尝试进行换行\n const b = (this as any).AABBBounds;\n const leftWidth = this.attribute.x ?? b.x1;\n const rightWidth = range[0] - b.x1;\n let maxSpace = Math.max(leftWidth, rightWidth);\n // 减一些buffer,buffer不能超过maxSpace的20%\n const buf = (isArray(symbolSize) ? symbolSize[0] : 12) + 3;\n maxSpace = Math.min(maxSpace - buf, maxSpace * maxWidthPercent);\n // 需要进行换行\n if (maxSpace < popTipWidth) {\n popTipWidth = maxSpace;\n const buf = parsedPadding[1] + parsedPadding[3];\n titleShape.setAttribute('maxLineWidth', maxSpace - buf);\n contentShape.setAttribute('maxLineWidth', maxSpace - buf);\n poptipHeight = parsedPadding[0] + parsedPadding[2];\n if (titleVisible) {\n poptipHeight += titleShape.AABBBounds.height() + space;\n }\n poptipHeight += contentShape.AABBBounds.height();\n }\n }\n\n const layout = position === 'auto';\n // 最多循环this.positionList次\n let maxBBoxI: number;\n let maxBBoxSize: number = -Infinity;\n for (let i = 0; i < this.positionList.length + 1; i++) {\n const p = layout ? this.positionList[i === this.positionList.length ? maxBBoxI : i] : position;\n const { angle, offset, rectOffset } = this.getAngleAndOffset(\n p,\n popTipWidth,\n poptipHeight,\n isArray(spaceSize) ? (spaceSize as [number, number]) : [spaceSize, spaceSize - lineWidth]\n );\n if (isBoolean(bgVisible)) {\n const offsetX = (isArray(symbolSize) ? symbolSize[0] : symbolSize) / 4;\n const bgSymbol = group.createOrUpdateChild(\n 'poptip-symbol-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && (contentVisible || titleVisible),\n x: offsetX,\n y: 0,\n strokeBoundsBuffer: -1,\n boundsPadding: -2,\n anchor: [0, 0],\n symbolType: 'arrow2Left',\n angle: angle,\n dx: offset[0],\n dy: offset[1],\n size: symbolSize,\n zIndex: -9\n },\n 'symbol'\n ) as ISymbol;\n if (!isEmpty(state?.panel)) {\n bgSymbol.states = state.panel;\n }\n\n const bgRect = group.createOrUpdateChild(\n 'poptip-rect-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && (contentVisible || titleVisible),\n x: 0,\n y: 0,\n width: popTipWidth,\n height: poptipHeight,\n zIndex: -8\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n }\n\n group.setAttributes({\n x: -offset[0] + dx,\n y: -offset[1] + dy\n });\n\n if (layout && range) {\n _tBounds.setValue(0, 0, popTipWidth, poptipHeight).transformWithMatrix(group.globalTransMatrix);\n const b = _tBounds;\n const stageBounds = new Bounds().setValue(0, 0, range[0], range[1]);\n if (rectInsideAnotherRect(b, stageBounds, false)) {\n break;\n } else {\n const bbox = getRectIntersect(b, stageBounds, false);\n const size = (bbox.x2 - bbox.x1) * (bbox.y2 - bbox.y1);\n if (size > maxBBoxSize) {\n maxBBoxSize = size;\n maxBBoxI = i;\n }\n }\n } else {\n break;\n }\n }\n }\n\n positionList = ['top', 'tl', 'tr', 'bottom', 'bl', 'br', 'left', 'lt', 'lb', 'right', 'rt', 'rb'];\n\n getAngleAndOffset(\n position: string,\n width: number,\n height: number,\n size: [number, number]\n ): { angle: number; offset: [number, number]; rectOffset: [number, number] } {\n // const sizeW = size[0];\n const sizeH = size[1] / 2;\n switch (position) {\n case 'tl':\n return {\n angle: (pi / 2) * 3,\n offset: [width / 4, height + sizeH],\n rectOffset: [-width / 4, -height - size[1]]\n };\n case 'top':\n return { angle: (pi / 2) * 3, offset: [width / 2, height + sizeH], rectOffset: [0, -height - size[1]] };\n case 'tr':\n return {\n angle: (pi / 2) * 3,\n offset: [(width / 4) * 3, height + sizeH],\n rectOffset: [(width / 4) * 3, -height - size[1]]\n };\n case 'rt':\n return { angle: 0, offset: [-sizeH, height / 5], rectOffset: [(width / 4) * 3, -height - size[1]] };\n case 'right':\n return { angle: 0, offset: [-sizeH, height / 2], rectOffset: [(width / 4) * 3, -height - size[1]] };\n case 'rb':\n return { angle: 0, offset: [-sizeH, (height / 5) * 4], rectOffset: [(width / 4) * 3, -height - size[1]] };\n case 'bl':\n return { angle: pi / 2, offset: [width / 4, -sizeH], rectOffset: [-width / 4, -height - size[1]] };\n case 'bottom':\n return { angle: pi / 2, offset: [width / 2, -sizeH], rectOffset: [0, -height - size[1]] };\n case 'br':\n return { angle: pi / 2, offset: [(width / 4) * 3, -sizeH], rectOffset: [(width / 4) * 3, -height - size[1]] };\n case 'lt':\n return { angle: pi, offset: [width + sizeH, height / 5], rectOffset: [-width / 4, -height - size[1]] };\n case 'left':\n return { angle: pi, offset: [width + sizeH, height / 2], rectOffset: [0, -height - size[1]] };\n case 'lb':\n return {\n angle: pi,\n offset: [width + sizeH, (height / 5) * 4],\n rectOffset: [(width / 4) * 3, -height - size[1]]\n };\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/poptip/poptip.ts"],"names":[],"mappings":";;;;;;;;;;;AAaA,OAAO,EACL,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,EACP,GAAG,EACH,KAAK,EACL,gBAAgB,EAChB,EAAE,EACF,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,QAAQ,GAAG,IAAI,UAAU,EAAE,CAAC;AAElC,mBAAmB,EAAE,CAAC;AACtB,MAAM,OAAO,MAAO,SAAQ,iBAA6C;IAyBvE,YAAY,UAA4B,EAAE,OAA0B;QAClE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAzB7F,SAAI,GAAG,QAAQ,CAAC;QA6OhB,iBAAY,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAnNlG,CAAC;IAES,MAAM;;QACd,MAAM,EACJ,UAAU,GAAG,EAA2B,EACxC,QAAQ,EACR,YAAY,GAAG,EAA2B,EAC1C,KAAK,GAAG,EAAyE,EACjF,KAAK,GAAG,CAAC,EACT,QAAQ,GAAG,CAAC,EACZ,QAAQ,GAAG,QA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YAChG,KAAK,IAAI;gBACP,OAAO;oBACL,KAAK,EAAE,EAAE;oBACT,MAAM,EAAE,CAAC,KAAK,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;oBACzC,UAAU,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;iBACjD,CAAC;SACL;IACH,CAAC;;AA3RM,wBAAiB,GAA8B;IACpD,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,IAAI;IACb,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,YAAY,EAAE;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,eAAe,EAAE,GAAG;IACpB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,EAAE;CACZ,CAAC","file":"poptip.js","sourcesContent":["/**\n * @description PopTip组件\n */\nimport type {\n IGroup,\n IRect,\n ISymbol,\n ISymbolGraphicAttribute,\n IText,\n ITextGraphicAttribute,\n TextAlignType,\n TextBaselineType\n} from '@visactor/vrender-core';\nimport {\n AABBBounds,\n Bounds,\n getRectIntersect,\n isArray,\n isBoolean,\n isEmpty,\n isValid,\n max,\n merge,\n normalizePadding,\n pi,\n rectInsideAnotherRect\n} from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { BackgroundAttributes, ComponentOptions } from '../interface';\nimport type { PopTipAttributes } from './type';\nimport { loadPoptipComponent } from './register';\n\nconst _tBounds = new AABBBounds();\n\nloadPoptipComponent();\nexport class PopTip extends AbstractComponent<Required<PopTipAttributes>> {\n name = 'poptip';\n\n static defaultAttributes: Partial<PopTipAttributes> = {\n position: 'rt',\n visible: true,\n title: null,\n content: null,\n titleStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'left',\n textBaseline: 'top'\n },\n contentStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'left',\n textBaseline: 'top'\n },\n maxWidthPercent: 0.8,\n space: 8,\n padding: 10\n };\n\n constructor(attributes: PopTipAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, PopTip.defaultAttributes, attributes));\n }\n\n protected render() {\n const {\n titleStyle = {} as ITextGraphicAttribute,\n position,\n contentStyle = {} as ITextGraphicAttribute,\n panel = {} as BackgroundAttributes & ISymbolGraphicAttribute & { space?: number },\n space = 4,\n minWidth = 0,\n maxWidth = Infinity,\n padding = 4,\n maxWidthPercent,\n visible,\n state,\n dx = 0,\n dy = 0\n } = this.attribute as PopTipAttributes;\n\n let { title = '', content = '' } = this.attribute as PopTipAttributes;\n\n title = this.attribute.titleFormatMethod ? this.attribute.titleFormatMethod(title) : title;\n content = this.attribute.contentFormatMethod ? this.attribute.contentFormatMethod(content) : content;\n\n const parsedPadding = normalizePadding(padding);\n\n const group = this.createOrUpdateChild('poptip-content', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup;\n\n const maxLineWidth = maxWidth - parsedPadding[1] - parsedPadding[3];\n\n const titleVisible = isValid(title) && visible !== false;\n const titleAttrs = {\n text: isArray(title) ? title : ([title] as any),\n visible: titleVisible,\n wrap: true,\n ...titleStyle,\n x: parsedPadding[3],\n y: parsedPadding[0],\n maxLineWidth,\n textAlign: 'left' as TextAlignType,\n textBaseline: 'top' as TextBaselineType\n };\n\n const titleShape = group.createOrUpdateChild('poptip-title', titleAttrs, 'text') as IText;\n if (!isEmpty(state?.title)) {\n titleShape.states = state.title;\n }\n\n const titleBounds = titleShape.AABBBounds;\n const titleHeight = titleBounds.height();\n const titleWidth = titleBounds.width();\n let height = titleHeight + space;\n if (!titleVisible) {\n height = 0;\n }\n\n const contentVisible = isValid(content) && visible !== false;\n const contentAttrs = {\n text: isArray(content) ? content : ([content] as any),\n visible: contentVisible,\n wrap: true,\n ...contentStyle,\n x: parsedPadding[3],\n y: parsedPadding[0] + height,\n maxLineWidth,\n textAlign: 'left' as TextAlignType,\n textBaseline: 'top' as TextBaselineType\n };\n\n const contentShape = group.createOrUpdateChild('poptip-content', contentAttrs, 'text') as IText;\n if (!isEmpty(state?.content)) {\n contentShape.states = state.content;\n }\n\n const contentBounds = contentShape.AABBBounds;\n const contentHeight = contentBounds.height();\n const contentWidth = contentBounds.width();\n\n if (contentVisible) {\n height += contentHeight;\n }\n\n // 计算整个popTip的宽高\n let popTipWidth = max(\n titleWidth + parsedPadding[1] + parsedPadding[3],\n contentWidth + parsedPadding[1] + parsedPadding[3]\n );\n if (popTipWidth > maxWidth) {\n popTipWidth = maxWidth;\n } else if (popTipWidth < minWidth) {\n popTipWidth = minWidth;\n }\n let poptipHeight = parsedPadding[0] + parsedPadding[2] + height;\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n const symbolSize = backgroundStyle.size ?? 12;\n const spaceSize: number | [number, number] = isArray(symbolSize)\n ? [symbolSize[0] + (backgroundStyle.space ?? 0), symbolSize[1] + (backgroundStyle.space ?? 0)]\n : (symbolSize as number) + (backgroundStyle.space ?? 0);\n const lineWidth = backgroundStyle.lineWidth ?? 1;\n const range: [number, number] | undefined = (this as any).stage\n ? [\n (this as any).stage.viewWidth ?? (this as any).stage.width,\n (this as any).stage.viewHeight ?? (this as any).stage.height\n ]\n : undefined;\n\n if (range) {\n // 尝试进行换行\n const b = (this as any).AABBBounds;\n const leftWidth = this.attribute.x ?? b.x1;\n const rightWidth = range[0] - b.x1;\n let maxSpace = Math.max(leftWidth, rightWidth);\n // 减一些buffer,buffer不能超过maxSpace的20%\n const buf = (isArray(symbolSize) ? symbolSize[0] : 12) + 3;\n maxSpace = Math.min(maxSpace - buf, maxSpace * maxWidthPercent);\n // 需要进行换行\n if (maxSpace < popTipWidth) {\n popTipWidth = maxSpace;\n const buf = parsedPadding[1] + parsedPadding[3];\n titleShape.setAttribute('maxLineWidth', maxSpace - buf);\n contentShape.setAttribute('maxLineWidth', maxSpace - buf);\n poptipHeight = parsedPadding[0] + parsedPadding[2];\n if (titleVisible) {\n poptipHeight += titleShape.AABBBounds.height() + space;\n }\n poptipHeight += contentShape.AABBBounds.height();\n }\n }\n\n const layout = position === 'auto';\n // 最多循环this.positionList次\n let maxBBoxI: number;\n let maxBBoxSize: number = -Infinity;\n for (let i = 0; i < this.positionList.length + 1; i++) {\n const p = layout ? this.positionList[i === this.positionList.length ? maxBBoxI : i] : position;\n const { angle, offset, rectOffset } = this.getAngleAndOffset(\n p,\n popTipWidth,\n poptipHeight,\n isArray(spaceSize) ? (spaceSize as [number, number]) : [spaceSize, spaceSize - lineWidth]\n );\n if (isBoolean(bgVisible)) {\n const offsetX = (isArray(symbolSize) ? symbolSize[0] : symbolSize) / 4;\n const bgSymbol = group.createOrUpdateChild(\n 'poptip-symbol-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && (contentVisible || titleVisible),\n x: offsetX,\n y: 0,\n strokeBoundsBuffer: -1,\n boundsPadding: -2,\n anchor: [0, 0],\n symbolType: 'arrow2Left',\n angle: angle,\n dx: offset[0],\n dy: offset[1],\n size: symbolSize,\n zIndex: -9\n },\n 'symbol'\n ) as ISymbol;\n if (!isEmpty(state?.panel)) {\n bgSymbol.states = state.panel;\n }\n\n const bgRect = group.createOrUpdateChild(\n 'poptip-rect-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && (contentVisible || titleVisible),\n x: 0,\n y: 0,\n width: popTipWidth,\n height: poptipHeight,\n zIndex: -8\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n }\n\n group.setAttributes({\n x: -offset[0] + dx,\n y: -offset[1] + dy\n });\n\n if (layout && range) {\n _tBounds.setValue(0, 0, popTipWidth, poptipHeight).transformWithMatrix(group.globalTransMatrix);\n const b = _tBounds;\n const stageBounds = new Bounds().setValue(0, 0, range[0], range[1]);\n if (rectInsideAnotherRect(b, stageBounds, false)) {\n break;\n } else {\n const bbox = getRectIntersect(b, stageBounds, false);\n const size = (bbox.x2 - bbox.x1) * (bbox.y2 - bbox.y1);\n if (size > maxBBoxSize) {\n maxBBoxSize = size;\n maxBBoxI = i;\n }\n }\n } else {\n break;\n }\n }\n }\n\n positionList = ['top', 'tl', 'tr', 'bottom', 'bl', 'br', 'left', 'lt', 'lb', 'right', 'rt', 'rb'];\n\n getAngleAndOffset(\n position: string,\n width: number,\n height: number,\n size: [number, number]\n ): { angle: number; offset: [number, number]; rectOffset: [number, number] } {\n // const sizeW = size[0];\n const sizeH = size[1] / 2;\n switch (position) {\n case 'tl':\n return {\n angle: (pi / 2) * 3,\n offset: [width / 4, height + sizeH],\n rectOffset: [-width / 4, -height - size[1]]\n };\n case 'top':\n return { angle: (pi / 2) * 3, offset: [width / 2, height + sizeH], rectOffset: [0, -height - size[1]] };\n case 'tr':\n return {\n angle: (pi / 2) * 3,\n offset: [(width / 4) * 3, height + sizeH],\n rectOffset: [(width / 4) * 3, -height - size[1]]\n };\n case 'rt':\n return { angle: 0, offset: [-sizeH, height / 5], rectOffset: [(width / 4) * 3, -height - size[1]] };\n case 'right':\n return { angle: 0, offset: [-sizeH, height / 2], rectOffset: [(width / 4) * 3, -height - size[1]] };\n case 'rb':\n return { angle: 0, offset: [-sizeH, (height / 5) * 4], rectOffset: [(width / 4) * 3, -height - size[1]] };\n case 'bl':\n return { angle: pi / 2, offset: [width / 4, -sizeH], rectOffset: [-width / 4, -height - size[1]] };\n case 'bottom':\n return { angle: pi / 2, offset: [width / 2, -sizeH], rectOffset: [0, -height - size[1]] };\n case 'br':\n return { angle: pi / 2, offset: [(width / 4) * 3, -sizeH], rectOffset: [(width / 4) * 3, -height - size[1]] };\n case 'lt':\n return { angle: pi, offset: [width + sizeH, height / 5], rectOffset: [-width / 4, -height - size[1]] };\n case 'left':\n return { angle: pi, offset: [width + sizeH, height / 2], rectOffset: [0, -height - size[1]] };\n case 'lb':\n return {\n angle: pi,\n offset: [width + sizeH, (height / 5) * 4],\n rectOffset: [(width / 4) * 3, -height - size[1]]\n };\n }\n }\n}\n"]}
@@ -2,10 +2,10 @@ import { merge } from "@visactor/vutils";
2
2
 
3
3
  import { DEFAULT_THEME, theme } from "./theme";
4
4
 
5
- import { registerGroup, registerRect, registerSymbol, registerWrapText } from "@visactor/vrender-kits";
5
+ import { registerGroup, registerRect, registerSymbol, registerText } from "@visactor/vrender-kits";
6
6
 
7
7
  export function loadPoptipComponent() {
8
- registerGroup(), registerWrapText(), registerSymbol(), registerRect();
8
+ registerGroup(), registerText(), registerSymbol(), registerRect();
9
9
  }
10
10
 
11
11
  export function setPoptipTheme(defaultPoptipTheme) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/poptip/register.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEvG,MAAM,UAAU,mBAAmB;IACjC,aAAa,EAAE,CAAC;IAChB,gBAAgB,EAAE,CAAC;IACnB,cAAc,EAAE,CAAC;IACjB,YAAY,EAAE,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,kBAAoC;IACjE,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,kBAAkB,CAAC,CAAC;AACzD,CAAC","file":"register.js","sourcesContent":["import { container } from '@visactor/vrender-core';\nimport { merge } from '@visactor/vutils';\nimport type { PopTipAttributes } from './type';\nimport { DEFAULT_THEME, theme } from './theme';\nimport { registerGroup, registerRect, registerSymbol, registerWrapText } from '@visactor/vrender-kits';\n\nexport function loadPoptipComponent() {\n registerGroup();\n registerWrapText();\n registerSymbol();\n registerRect();\n}\n\nexport function setPoptipTheme(defaultPoptipTheme: PopTipAttributes) {\n merge(theme.poptip, DEFAULT_THEME, defaultPoptipTheme);\n}\n"]}
1
+ {"version":3,"sources":["../src/poptip/register.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEnG,MAAM,UAAU,mBAAmB;IACjC,aAAa,EAAE,CAAC;IAChB,YAAY,EAAE,CAAC;IACf,cAAc,EAAE,CAAC;IACjB,YAAY,EAAE,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,kBAAoC;IACjE,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,kBAAkB,CAAC,CAAC;AACzD,CAAC","file":"register.js","sourcesContent":["import { container } from '@visactor/vrender-core';\nimport { merge } from '@visactor/vutils';\nimport type { PopTipAttributes } from './type';\nimport { DEFAULT_THEME, theme } from './theme';\nimport { registerGroup, registerRect, registerSymbol, registerText } from '@visactor/vrender-kits';\n\nexport function loadPoptipComponent() {\n registerGroup();\n registerText();\n registerSymbol();\n registerRect();\n}\n\nexport function setPoptipTheme(defaultPoptipTheme: PopTipAttributes) {\n merge(theme.poptip, DEFAULT_THEME, defaultPoptipTheme);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './radio';
2
+ export * from './type';
@@ -0,0 +1,4 @@
1
+ export * from "./radio";
2
+
3
+ export * from "./type";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/radio/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["export * from './radio';\nexport * from './type';\n"]}
@@ -0,0 +1,16 @@
1
+ import { AbstractComponent } from '../core/base';
2
+ import type { RadioAttributes } from './type';
3
+ import { Arc, WrapText } from '@visactor/vrender-core';
4
+ import type { ComponentOptions } from '../interface';
5
+ export declare class Radio extends AbstractComponent<Required<RadioAttributes>> {
6
+ static defaultAttributes: Partial<RadioAttributes>;
7
+ _circle: Arc;
8
+ _text: WrapText;
9
+ constructor(attributes: RadioAttributes, options?: ComponentOptions);
10
+ render(): void;
11
+ renderCircle(): void;
12
+ renderText(): void;
13
+ renderGroup(): void;
14
+ layout(): void;
15
+ private _handlePointerUp;
16
+ }
@@ -0,0 +1,88 @@
1
+ import { merge } from "@visactor/vutils";
2
+
3
+ import { AbstractComponent } from "../core/base";
4
+
5
+ import { Arc, WrapText } from "@visactor/vrender-core";
6
+
7
+ import { loadRadioComponent } from "./register";
8
+
9
+ loadRadioComponent();
10
+
11
+ export class Radio extends AbstractComponent {
12
+ constructor(attributes, options) {
13
+ super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, Radio.defaultAttributes, attributes)),
14
+ this._handlePointerUp = () => {
15
+ this.attribute.disabled || this.attribute.checked || (this.setAttribute("checked", !0),
16
+ this._dispatchEvent("radio_checked", {
17
+ eventType: "radio_checked",
18
+ target: this
19
+ }), this.stage.renderNextFrame());
20
+ }, this.renderGroup(), this.onBeforeAttributeUpdate = (val, attributes, key) => {
21
+ "interactive" in val && this.setAttribute("pickable", val.interactive), "disabled" in val && this.setAttribute("cursor", val.disable ? this.attribute.disableCursor : this.attribute.cursor);
22
+ }, this.addEventListener("pointerup", this._handlePointerUp);
23
+ }
24
+ render() {
25
+ this.removeAllChild(!0), this.renderCircle(), this.renderText(), this.layout();
26
+ }
27
+ renderCircle() {
28
+ this._circle = new Arc(merge({}, this.attribute.circle));
29
+ const isChecked = this.attribute.checked;
30
+ isChecked && this.attribute.disabled ? this._circle.setAttributes({
31
+ fill: this.attribute.circle.disableCheckedFill,
32
+ stroke: this.attribute.circle.disableCheckedStroke
33
+ }) : isChecked && this._circle.setAttributes({
34
+ fill: this.attribute.circle.checkedFill,
35
+ stroke: this.attribute.circle.checkedStroke
36
+ }), this.appendChild(this._circle);
37
+ }
38
+ renderText() {
39
+ this._text = new WrapText(merge({}, this.attribute.text)), this.attribute.disabled && this._text.setAttribute("fill", this.attribute.text.disableFill),
40
+ this.appendChild(this._text);
41
+ }
42
+ renderGroup() {
43
+ this.attribute.interactive || this.setAttribute("pickable", !1), this.attribute.disabled && this.setAttribute("cursor", this.attribute.disableCursor);
44
+ }
45
+ layout() {
46
+ const circleHeight = 2 * (this.attribute.circle.outerRadius + this.attribute.circle.lineWidth), textHeight = this._text.AABBBounds.height(), maxHeight = Math.max(circleHeight, textHeight), circleY = maxHeight / 2 - circleHeight / 2 + this.attribute.circle.outerRadius + this.attribute.circle.lineWidth, textY = maxHeight / 2 - textHeight / 2, circleWidth = 2 * (this.attribute.circle.outerRadius + this.attribute.circle.lineWidth), circleX = this.attribute.circle.outerRadius + this.attribute.circle.lineWidth, textX = circleWidth + this.attribute.spaceBetweenTextAndIcon;
47
+ this._circle.setAttributes({
48
+ x: circleX,
49
+ y: circleY
50
+ }), this._text.setAttributes({
51
+ x: textX,
52
+ y: textY
53
+ });
54
+ }
55
+ }
56
+
57
+ Radio.defaultAttributes = {
58
+ interactive: !0,
59
+ disabled: !1,
60
+ checked: !1,
61
+ cursor: "pointer",
62
+ disableCursor: "not-allowed",
63
+ spaceBetweenTextAndIcon: 8,
64
+ text: {
65
+ text: "text",
66
+ fontSize: 14,
67
+ fill: "#000",
68
+ disableFill: "rgb(201,205,212)",
69
+ textBaseline: "top",
70
+ pickable: !1
71
+ },
72
+ circle: {
73
+ outerRadius: 7,
74
+ innerRadius: 3,
75
+ startAngle: 0,
76
+ endAngle: 2 * Math.PI,
77
+ lineWidth: 1,
78
+ fill: "#fff",
79
+ stroke: "rgb(229,230,235)",
80
+ disableFill: "rgb(242,243,245)",
81
+ checkedFill: "rgb(22, 93, 255)",
82
+ checkedStroke: "rgb(22, 93, 255)",
83
+ disableCheckedFill: "rgb(148, 191, 255)",
84
+ disableCheckedStroke: "rgb(148, 191, 255)",
85
+ pickable: !1
86
+ }
87
+ };
88
+ //# sourceMappingURL=radio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/radio/radio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,kBAAkB,EAAE,CAAC;AACrB,MAAM,OAAO,KAAM,SAAQ,iBAA4C;IAmCrE,YAAY,UAA2B,EAAE,OAA0B;QACjE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAgFpF,qBAAgB,GAAG,GAAG,EAAE;YAC9B,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;gBAErD,OAAO;aACR;YACD,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAEnC,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE;gBACnC,SAAS,EAAE,eAAe;gBAC1B,MAAM,EAAE,IAAI;aACb,CAAC,CAAC;YAEH,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAC/B,CAAC,CAAC;QA5FA,IAAI,CAAC,WAAW,EAAE,CAAC;QAEnB,IAAI,CAAC,uBAAuB,GAAG,CAAC,GAAQ,EAAE,UAAe,EAAE,GAA6B,EAAE,EAAE;YAC1F,IAA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W,EAAE,kBAAkB;QAC/B,WAAW,EAAE,kBAAkB;QAC/B,aAAa,EAAE,kBAAkB;QACjC,kBAAkB,EAAE,oBAAoB;QACxC,oBAAoB,EAAE,oBAAoB;QAC1C,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC","file":"radio.js","sourcesContent":["import { merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { RadioAttributes } from './type';\nimport { Arc, WrapText } from '@visactor/vrender-core';\nimport type { ComponentOptions } from '../interface';\nimport { loadRadioComponent } from './register';\n\nloadRadioComponent();\nexport class Radio extends AbstractComponent<Required<RadioAttributes>> {\n static defaultAttributes: Partial<RadioAttributes> = {\n interactive: true,\n disabled: false,\n checked: false,\n cursor: 'pointer',\n disableCursor: 'not-allowed',\n spaceBetweenTextAndIcon: 8,\n text: {\n text: 'text',\n fontSize: 14,\n fill: '#000',\n disableFill: 'rgb(201,205,212)',\n textBaseline: 'top',\n pickable: false\n },\n circle: {\n outerRadius: 7,\n innerRadius: 3,\n startAngle: 0,\n endAngle: 2 * Math.PI,\n lineWidth: 1,\n fill: '#fff',\n stroke: 'rgb(229,230,235)',\n disableFill: 'rgb(242,243,245)',\n checkedFill: 'rgb(22, 93, 255)',\n checkedStroke: 'rgb(22, 93, 255)',\n disableCheckedFill: 'rgb(148, 191, 255)',\n disableCheckedStroke: 'rgb(148, 191, 255)',\n pickable: false\n }\n };\n _circle: Arc;\n _text: WrapText;\n\n constructor(attributes: RadioAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Radio.defaultAttributes, attributes));\n this.renderGroup();\n\n this.onBeforeAttributeUpdate = (val: any, attributes: any, key: null | string | string[]) => {\n if ('interactive' in val) {\n this.setAttribute('pickable', val.interactive);\n }\n if ('disabled' in val) {\n this.setAttribute('cursor', val.disable ? this.attribute.disableCursor : this.attribute.cursor);\n }\n return undefined;\n };\n\n this.addEventListener('pointerup', this._handlePointerUp);\n }\n\n render() {\n this.removeAllChild(true);\n\n this.renderCircle();\n this.renderText();\n this.layout();\n }\n\n renderCircle() {\n this._circle = new Arc(merge({}, this.attribute.circle));\n const isChecked = this.attribute.checked;\n if (isChecked && this.attribute.disabled) {\n this._circle.setAttributes({\n fill: this.attribute.circle.disableCheckedFill,\n stroke: this.attribute.circle.disableCheckedStroke\n });\n } else if (isChecked) {\n this._circle.setAttributes({\n fill: this.attribute.circle.checkedFill,\n stroke: this.attribute.circle.checkedStroke\n });\n }\n this.appendChild(this._circle);\n }\n\n renderText() {\n this._text = new WrapText(merge({}, this.attribute.text));\n if (this.attribute.disabled) {\n this._text.setAttribute('fill', this.attribute.text.disableFill);\n }\n this.appendChild(this._text);\n }\n\n renderGroup() {\n if (!this.attribute.interactive) {\n this.setAttribute('pickable', false);\n }\n if (this.attribute.disabled) {\n this.setAttribute('cursor', this.attribute.disableCursor);\n }\n }\n\n layout() {\n const circleHeight = (this.attribute.circle.outerRadius + this.attribute.circle.lineWidth) * 2;\n const textHeight = this._text.AABBBounds.height();\n const maxHeight = Math.max(circleHeight, textHeight);\n const circleY =\n maxHeight / 2 - circleHeight / 2 + this.attribute.circle.outerRadius + this.attribute.circle.lineWidth;\n const textY = maxHeight / 2 - textHeight / 2;\n\n const circleWidth = (this.attribute.circle.outerRadius + this.attribute.circle.lineWidth) * 2;\n const circleX = this.attribute.circle.outerRadius + this.attribute.circle.lineWidth;\n const textX = circleWidth + this.attribute.spaceBetweenTextAndIcon;\n\n this._circle.setAttributes({\n x: circleX,\n y: circleY\n });\n this._text.setAttributes({\n x: textX,\n y: textY\n });\n }\n\n private _handlePointerUp = () => {\n if (this.attribute.disabled || this.attribute.checked) {\n // checked do nothing\n return;\n }\n this.setAttribute('checked', true);\n\n this._dispatchEvent('radio_checked', {\n eventType: 'radio_checked',\n target: this\n });\n\n this.stage.renderNextFrame();\n };\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare function loadRadioComponent(): void;
@@ -0,0 +1,6 @@
1
+ import { registerGroup, registerImage, registerRect, registerWrapText } from "@visactor/vrender-kits";
2
+
3
+ export function loadRadioComponent() {
4
+ registerGroup(), registerRect(), registerWrapText(), registerImage();
5
+ }
6
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/radio/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEtG,MAAM,UAAU,kBAAkB;IAChC,aAAa,EAAE,CAAC;IAChB,YAAY,EAAE,CAAC;IACf,gBAAgB,EAAE,CAAC;IACnB,aAAa,EAAE,CAAC;AAClB,CAAC","file":"register.js","sourcesContent":["import { registerGroup, registerImage, registerRect, registerWrapText } from '@visactor/vrender-kits';\n\nexport function loadRadioComponent() {\n registerGroup();\n registerRect();\n registerWrapText();\n registerImage();\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import type { Cursor, IArcGraphicAttribute, IColor, IGroupGraphicAttribute, IWrapTextGraphicAttribute } from '@visactor/vrender-core';
2
+ export type RadioText = {
3
+ disableFill?: IColor;
4
+ } & IWrapTextGraphicAttribute;
5
+ export type CircleStyle = {
6
+ disableFill?: IColor;
7
+ checkedFill?: IColor;
8
+ checkedStroke?: IColor;
9
+ disableCheckedFill?: IColor;
10
+ disableCheckedStroke?: IColor;
11
+ } & IArcGraphicAttribute;
12
+ export type RadioAttributes = IGroupGraphicAttribute & {
13
+ id?: string;
14
+ interactive?: boolean;
15
+ disabled?: boolean;
16
+ checked?: boolean;
17
+ text?: RadioText;
18
+ circle?: CircleStyle;
19
+ disableCursor?: Cursor;
20
+ spaceBetweenTextAndIcon?: number;
21
+ };
@@ -0,0 +1,2 @@
1
+ export { };
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/radio/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n Cursor,\n IArcGraphicAttribute,\n IColor,\n IGroupGraphicAttribute,\n IWrapTextGraphicAttribute\n} from '@visactor/vrender-core';\n\nexport type RadioText = {\n disableFill?: IColor;\n} & IWrapTextGraphicAttribute;\n\nexport type CircleStyle = {\n disableFill?: IColor;\n checkedFill?: IColor;\n checkedStroke?: IColor;\n disableCheckedFill?: IColor;\n disableCheckedStroke?: IColor;\n} & IArcGraphicAttribute;\n\nexport type RadioAttributes = IGroupGraphicAttribute & {\n id?: string;\n\n interactive?: boolean;\n disabled?: boolean;\n checked?: boolean;\n\n /**\n * 图例文字\n */\n text?: RadioText;\n /**\n * 图例选中图标\n */\n circle?: CircleStyle;\n /**\n * 图例选中图标\n */\n disableCursor?: Cursor;\n spaceBetweenTextAndIcon?: number;\n};\n"]}
@@ -32,8 +32,8 @@ export class ScrollBar extends AbstractComponent {
32
32
  this.stage && !this.stage.autoRender && this.stage.renderNextFrame();
33
33
  }, this._onSliderPointerDown = e => {
34
34
  e.stopPropagation();
35
- const {direction: direction} = this.attribute;
36
- this._prePos = "horizontal" === direction ? e.clientX : e.clientY, this._dispatchEvent("scrollDown", {
35
+ const {direction: direction} = this.attribute, {x: x, y: y} = this.stage.eventPointTransform(e);
36
+ this._prePos = "horizontal" === direction ? x : y, this._dispatchEvent("scrollDown", {
37
37
  pos: this._prePos,
38
38
  event: e
39
39
  }), "browser" === vglobal.env ? (vglobal.addEventListener("pointermove", this._onSliderPointerMoveWithDelay, {
@@ -42,11 +42,11 @@ export class ScrollBar extends AbstractComponent {
42
42
  capture: !0
43
43
  }), this.stage.addEventListener("pointerup", this._onSliderPointerUp), this.stage.addEventListener("pointerupoutside", this._onSliderPointerUp));
44
44
  }, this._computeScrollValue = e => {
45
- const {direction: direction} = this.attribute;
45
+ const {direction: direction} = this.attribute, {x: x, y: y} = this.stage.eventPointTransform(e);
46
46
  let currentScrollValue, currentPos, delta = 0;
47
47
  const {width: width, height: height} = this._getSliderRenderBounds();
48
- return "vertical" === direction ? (currentPos = e.clientY, delta = currentPos - this._prePos,
49
- currentScrollValue = delta / height) : (currentPos = e.clientX, delta = currentPos - this._prePos,
48
+ return "vertical" === direction ? (currentPos = y, delta = currentPos - this._prePos,
49
+ currentScrollValue = delta / height) : (currentPos = x, delta = currentPos - this._prePos,
50
50
  currentScrollValue = delta / width), [ currentPos, currentScrollValue ];
51
51
  }, this._onSliderPointerMove = e => {
52
52
  e.stopPropagation();
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/scrollbar/scrollbar.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAIjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAW9C,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,QAAQ;CACnB,CAAC;AAEF,sBAAsB,EAAE,CAAC;AAEzB,MAAM,OAAO,SAAU,SAAQ,iBAAgD;IAmC7E,YAAY,UAA+B,EAAE,OAA0B;QACrE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAnChG,SAAI,GAAG,WAAW,CAAC;QAsPX,uBAAkB,GAAG,CAAC,CAAwB,EAAE,EAAE;YAGxD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YAC3B,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,SAAgC,CAAC;YAClF,MAAM,UAAU,GAAG,IAA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AI;IACX,UAAU,EAAE,EAAE;IACd,WAAW,EAAE;QACX,IAAI,EAAE,mBAAmB;KAC1B;IACD,SAAS,EAAE;QACT,IAAI,EAAE,mBAAmB;KAC1B;IACD,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACnB,SAAS,EAAE,UAAU;IACrB,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,IAAI;CACf,CAAC","file":"scrollbar.js","sourcesContent":["/**\n * @description 滚动条组件\n */\nimport type { IRectGraphicAttribute, FederatedPointerEvent, IGroup, IRect } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { vglobal } from '@visactor/vrender-core';\nimport { merge, normalizePadding, clamp, clampRange, debounce, throttle } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\n\nimport type { ScrollBarAttributes } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { loadScrollbarComponent } from './register';\nimport { SCROLLBAR_EVENT } from '../constant';\n\ntype ComponentBounds = {\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n width: number;\n height: number;\n};\n\nconst delayMap = {\n debounce: debounce,\n throttle: throttle\n};\n\nloadScrollbarComponent();\n\nexport class ScrollBar extends AbstractComponent<Required<ScrollBarAttributes>> {\n name = 'scrollbar';\n\n static defaultAttributes = {\n direction: 'horizontal',\n round: true,\n sliderSize: 20,\n sliderStyle: {\n fill: 'rgba(0, 0, 0, .5)'\n },\n railStyle: {\n fill: 'rgba(0, 0, 0, .0)'\n },\n padding: 2,\n scrollRange: [0, 1],\n delayType: 'throttle',\n delayTime: 0,\n realTime: true\n };\n\n private _container!: IGroup;\n // 滚动条滑块\n private _slider!: IRect;\n // 滚动条滑轨\n private _rail!: IRect;\n // 滑块可渲染的区域包围盒\n private _sliderRenderBounds!: ComponentBounds | null;\n // 滑块滑动的范围\n private _sliderLimitRange!: [number, number] | null;\n // 保留滑块上一次的位置\n private _prePos!: number;\n // TODO: 临时方案\n private _viewPosition!: { x: number; y: number };\n private _sliderSize!: number;\n\n constructor(attributes: ScrollBarAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, ScrollBar.defaultAttributes, attributes));\n }\n\n setScrollRange(range: [number, number], render = true) {\n const {\n direction = 'horizontal',\n limitRange = [0, 1],\n range: preRange,\n realTime = true\n } = this.attribute as ScrollBarAttributes;\n\n const currScrollRange = clampRange(range, limitRange[0], limitRange[1]);\n if (render) {\n // 更新图形\n const sliderPos = this._getSliderPos(currScrollRange);\n if (this._slider) {\n const sliderSize = sliderPos[1] - sliderPos[0];\n this._sliderSize = sliderSize;\n\n if (direction === 'horizontal') {\n this._slider.setAttributes(\n {\n x: sliderPos[0],\n width: sliderSize\n },\n true\n );\n } else {\n this._slider.setAttributes(\n {\n y: sliderPos[0],\n height: sliderSize\n },\n true\n );\n }\n\n if (this.stage && !this.stage.autoRender) {\n this.stage.renderNextFrame();\n }\n }\n }\n (this.attribute as ScrollBarAttributes).range = currScrollRange;\n // 发射 change 事件\n if (realTime) {\n this._dispatchEvent(SCROLLBAR_EVENT, {\n pre: preRange,\n value: currScrollRange\n });\n }\n }\n\n getScrollRange(): [number, number] {\n return (this.attribute as ScrollBarAttributes).range;\n }\n\n // public setLocation(point: PointLocationCfg) {\n // this.translateTo(point.x, point.y);\n // }\n\n // 绑定事件\n protected bindEvents(): void {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n const { delayType = 'throttle', delayTime = 0 } = this.attribute as ScrollBarAttributes;\n // TODO: wheel 事件支持\n if (this._rail) {\n this._rail.addEventListener(\n 'pointerdown',\n delayMap[delayType](this._onRailPointerDown, delayTime) as EventListener\n );\n }\n if (this._slider) {\n this._slider.addEventListener('pointerdown', this._onSliderPointerDown as EventListener);\n }\n }\n\n protected render() {\n this._reset();\n const {\n direction = 'horizontal',\n width,\n height,\n range,\n limitRange = [0, 1],\n // sliderSize = 20,\n // scrollValue = 0,\n // scrollRange = [0, 1],\n railStyle,\n sliderStyle,\n padding = 2\n } = this.attribute as ScrollBarAttributes;\n\n const group = this.createOrUpdateChild('scrollbar-container', {}, 'group') as IGroup;\n // 绘制轨道\n\n const rail = group.createOrUpdateChild(\n 'scrollbar-rail',\n {\n x: 0,\n y: 0,\n width,\n height,\n ...railStyle\n },\n 'rect'\n ) as IRect;\n this._rail = rail;\n\n // 滑块\n const sliderRenderBounds = this._getSliderRenderBounds();\n const sliderPos = this._getSliderPos(clampRange(range, limitRange[0], limitRange[1]));\n const sliderSize = sliderPos[1] - sliderPos[0];\n this._sliderSize = sliderSize;\n // const sliderRangePos = this._getScrollRange();\n\n let sliderAttribute: IRectGraphicAttribute;\n if (direction === 'horizontal') {\n sliderAttribute = {\n x: sliderPos[0],\n y: sliderRenderBounds.y1,\n width: sliderSize,\n height: sliderRenderBounds.height\n };\n } else {\n sliderAttribute = {\n x: sliderRenderBounds.x1,\n y: sliderPos[0],\n width: sliderRenderBounds.width,\n height: sliderSize\n };\n }\n\n const slider = group.createOrUpdateChild(\n 'slider',\n {\n ...sliderAttribute,\n cornerRadius: this._getDefaultSliderCornerRadius(),\n ...sliderStyle,\n boundsPadding: normalizePadding(padding),\n pickMode: 'imprecise'\n },\n 'rect'\n ) as IRect;\n this._slider = slider;\n this._container = group;\n\n const containerAABBBounds = this._container.AABBBounds;\n this._viewPosition = {\n x: containerAABBBounds.x1,\n y: containerAABBBounds.y1\n };\n }\n\n // 获取滑块渲染的包围盒区域\n private _getSliderRenderBounds() {\n if (this._sliderRenderBounds) {\n return this._sliderRenderBounds;\n }\n const { width, height, padding = 2 } = this.attribute as ScrollBarAttributes;\n const [top, right, bottom, left] = normalizePadding(padding);\n const renderBounds = {\n x1: left,\n y1: top,\n x2: width - right,\n y2: height - bottom,\n width: Math.max(0, width - (left + right)),\n height: Math.max(0, height - (top + bottom))\n };\n this._sliderRenderBounds = renderBounds;\n return renderBounds;\n }\n\n // 获取默认的滑块圆角\n private _getDefaultSliderCornerRadius() {\n const { direction, round } = this.attribute as ScrollBarAttributes;\n\n if (round) {\n const { width, height } = this._getSliderRenderBounds();\n return direction === 'horizontal' ? height : width;\n }\n\n return 0;\n }\n\n // 计算滑块在轨道的位置\n private _getSliderPos(range: [number, number]) {\n const { direction } = this.attribute as ScrollBarAttributes;\n const { width, height, x1, y1 } = this._getSliderRenderBounds();\n\n if (direction === 'horizontal') {\n return [width * range[0] + x1, width * range[1] + x1];\n }\n return [height * range[0] + y1, height * range[1] + y1];\n }\n\n private _getScrollRange() {\n if (this._sliderLimitRange) {\n return this._sliderLimitRange;\n }\n const { limitRange = [0, 1], direction } = this.attribute as ScrollBarAttributes;\n const [min, max] = clampRange(limitRange, 0, 1);\n const { width, height, x1, y1 } = this._getSliderRenderBounds();\n const sliderSize = this._sliderSize;\n\n return direction === 'horizontal'\n ? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)\n : clampRange([y1 + min * height, y1 + max * height], y1, height - sliderSize);\n }\n\n private _onRailPointerDown = (e: FederatedPointerEvent) => {\n // 将事件坐标转换为实际的滑块位置\n // TODO: 这里有问题,应该拿 viewX viewY,同时 graphic 要提供接口获取它的 相对 view 的坐标\n const { viewX, viewY } = e;\n const { direction, width, height, range } = this.attribute as ScrollBarAttributes;\n const sliderSize = this._sliderSize;\n const [min, max] = this._getScrollRange();\n let currentScrollValue;\n if (direction === 'vertical') {\n const relativeY = viewY - this._viewPosition.y;\n const currentYPos = clamp(relativeY - sliderSize / 2, min, max);\n currentScrollValue = relativeY / height;\n this._slider.setAttribute('y', currentYPos, true);\n } else {\n const relativeX = viewX - this._viewPosition.x;\n const currentXPos = clamp(relativeX - sliderSize / 2, min, max);\n currentScrollValue = relativeX / width;\n this._slider.setAttribute('x', currentXPos, true);\n }\n\n this.setScrollRange(\n [currentScrollValue - (range[1] - range[0]) / 2, currentScrollValue + (range[1] - range[0]) / 2],\n false\n );\n\n if (this.stage && !this.stage.autoRender) {\n this.stage.renderNextFrame();\n }\n };\n\n private _onSliderPointerDown = (e: FederatedPointerEvent) => {\n e.stopPropagation();\n const { direction } = this.attribute as ScrollBarAttributes;\n this._prePos = direction === 'horizontal' ? e.clientX : e.clientY;\n this._dispatchEvent('scrollDown', {\n pos: this._prePos,\n event: e\n });\n if (vglobal.env === 'browser') {\n vglobal.addEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n vglobal.addEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.addEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n this.stage.addEventListener('pointerup', this._onSliderPointerUp);\n this.stage.addEventListener('pointerupoutside', this._onSliderPointerUp);\n }\n };\n\n private _computeScrollValue = (e: any) => {\n const { direction } = this.attribute as ScrollBarAttributes;\n let currentScrollValue;\n let currentPos;\n let delta = 0;\n\n const { width, height } = this._getSliderRenderBounds();\n if (direction === 'vertical') {\n currentPos = e.clientY;\n delta = currentPos - this._prePos;\n currentScrollValue = delta / height;\n } else {\n currentPos = e.clientX;\n delta = currentPos - this._prePos;\n currentScrollValue = delta / width;\n }\n return [currentPos, currentScrollValue];\n };\n\n private _onSliderPointerMove = (e: any) => {\n e.stopPropagation();\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n this.setScrollRange([preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue], true);\n this._prePos = currentPos;\n };\n\n private _onSliderPointerMoveWithDelay =\n this.attribute.delayTime === 0\n ? this._onSliderPointerMove\n : delayMap[this.attribute.delayType](this._onSliderPointerMove, this.attribute.delayTime);\n\n private _onSliderPointerUp = (e: any) => {\n e.preventDefault();\n const { realTime = true, range: preRange, limitRange = [0, 1] } = this.attribute as ScrollBarAttributes;\n // 发射 change 事件\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n const range: [number, number] = [preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue];\n\n this._dispatchEvent('scrollUp', {\n pre: preRange,\n value: clampRange(range, limitRange[0], limitRange[1])\n });\n if (vglobal.env === 'browser') {\n vglobal.removeEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n vglobal.removeEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.removeEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n this.stage.removeEventListener('pointerup', this._onSliderPointerUp);\n this.stage.removeEventListener('pointerupoutside', this._onSliderPointerUp);\n }\n };\n\n private _reset() {\n this._sliderRenderBounds = null;\n this._sliderLimitRange = null;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/scrollbar/scrollbar.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAIjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAW9C,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,QAAQ;CACnB,CAAC;AAEF,sBAAsB,EAAE,CAAC;AAEzB,MAAM,OAAO,SAAU,SAAQ,iBAAgD;IAmC7E,YAAY,UAA+B,EAAE,OAA0B;QACrE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAnChG,SAAI,GAAG,WAAW,CAAC;QAsPX,uBAAkB,GAAG,CAAC,CAAwB,EAAE,EAAE;YAGxD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YAC3B,MAAM,EAAE,SAAS,EAAE,K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MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;IAClF,CAAC;IA2GO,MAAM;QACZ,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAChC,CAAC;;AAhWM,2BAAiB,GAAG;IACzB,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,EAAE;IACd,WAAW,EAAE;QACX,IAAI,EAAE,mBAAmB;KAC1B;IACD,SAAS,EAAE;QACT,IAAI,EAAE,mBAAmB;KAC1B;IACD,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACnB,SAAS,EAAE,UAAU;IACrB,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,IAAI;CACf,CAAC","file":"scrollbar.js","sourcesContent":["/**\n * @description 滚动条组件\n */\nimport type { IRectGraphicAttribute, FederatedPointerEvent, IGroup, IRect } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { vglobal } from '@visactor/vrender-core';\nimport { merge, normalizePadding, clamp, clampRange, debounce, throttle } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\n\nimport type { ScrollBarAttributes } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { loadScrollbarComponent } from './register';\nimport { SCROLLBAR_EVENT } from '../constant';\n\ntype ComponentBounds = {\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n width: number;\n height: number;\n};\n\nconst delayMap = {\n debounce: debounce,\n throttle: throttle\n};\n\nloadScrollbarComponent();\n\nexport class ScrollBar extends AbstractComponent<Required<ScrollBarAttributes>> {\n name = 'scrollbar';\n\n static defaultAttributes = {\n direction: 'horizontal',\n round: true,\n sliderSize: 20,\n sliderStyle: {\n fill: 'rgba(0, 0, 0, .5)'\n },\n railStyle: {\n fill: 'rgba(0, 0, 0, .0)'\n },\n padding: 2,\n scrollRange: [0, 1],\n delayType: 'throttle',\n delayTime: 0,\n realTime: true\n };\n\n private _container!: IGroup;\n // 滚动条滑块\n private _slider!: IRect;\n // 滚动条滑轨\n private _rail!: IRect;\n // 滑块可渲染的区域包围盒\n private _sliderRenderBounds!: ComponentBounds | null;\n // 滑块滑动的范围\n private _sliderLimitRange!: [number, number] | null;\n // 保留滑块上一次的位置\n private _prePos!: number;\n // TODO: 临时方案\n private _viewPosition!: { x: number; y: number };\n private _sliderSize!: number;\n\n constructor(attributes: ScrollBarAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, ScrollBar.defaultAttributes, attributes));\n }\n\n setScrollRange(range: [number, number], render = true) {\n const {\n direction = 'horizontal',\n limitRange = [0, 1],\n range: preRange,\n realTime = true\n } = this.attribute as ScrollBarAttributes;\n\n const currScrollRange = clampRange(range, limitRange[0], limitRange[1]);\n if (render) {\n // 更新图形\n const sliderPos = this._getSliderPos(currScrollRange);\n if (this._slider) {\n const sliderSize = sliderPos[1] - sliderPos[0];\n this._sliderSize = sliderSize;\n\n if (direction === 'horizontal') {\n this._slider.setAttributes(\n {\n x: sliderPos[0],\n width: sliderSize\n },\n true\n );\n } else {\n this._slider.setAttributes(\n {\n y: sliderPos[0],\n height: sliderSize\n },\n true\n );\n }\n\n if (this.stage && !this.stage.autoRender) {\n this.stage.renderNextFrame();\n }\n }\n }\n (this.attribute as ScrollBarAttributes).range = currScrollRange;\n // 发射 change 事件\n if (realTime) {\n this._dispatchEvent(SCROLLBAR_EVENT, {\n pre: preRange,\n value: currScrollRange\n });\n }\n }\n\n getScrollRange(): [number, number] {\n return (this.attribute as ScrollBarAttributes).range;\n }\n\n // public setLocation(point: PointLocationCfg) {\n // this.translateTo(point.x, point.y);\n // }\n\n // 绑定事件\n protected bindEvents(): void {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n const { delayType = 'throttle', delayTime = 0 } = this.attribute as ScrollBarAttributes;\n // TODO: wheel 事件支持\n if (this._rail) {\n this._rail.addEventListener(\n 'pointerdown',\n delayMap[delayType](this._onRailPointerDown, delayTime) as EventListener\n );\n }\n if (this._slider) {\n this._slider.addEventListener('pointerdown', this._onSliderPointerDown as EventListener);\n }\n }\n\n protected render() {\n this._reset();\n const {\n direction = 'horizontal',\n width,\n height,\n range,\n limitRange = [0, 1],\n // sliderSize = 20,\n // scrollValue = 0,\n // scrollRange = [0, 1],\n railStyle,\n sliderStyle,\n padding = 2\n } = this.attribute as ScrollBarAttributes;\n\n const group = this.createOrUpdateChild('scrollbar-container', {}, 'group') as IGroup;\n // 绘制轨道\n\n const rail = group.createOrUpdateChild(\n 'scrollbar-rail',\n {\n x: 0,\n y: 0,\n width,\n height,\n ...railStyle\n },\n 'rect'\n ) as IRect;\n this._rail = rail;\n\n // 滑块\n const sliderRenderBounds = this._getSliderRenderBounds();\n const sliderPos = this._getSliderPos(clampRange(range, limitRange[0], limitRange[1]));\n const sliderSize = sliderPos[1] - sliderPos[0];\n this._sliderSize = sliderSize;\n // const sliderRangePos = this._getScrollRange();\n\n let sliderAttribute: IRectGraphicAttribute;\n if (direction === 'horizontal') {\n sliderAttribute = {\n x: sliderPos[0],\n y: sliderRenderBounds.y1,\n width: sliderSize,\n height: sliderRenderBounds.height\n };\n } else {\n sliderAttribute = {\n x: sliderRenderBounds.x1,\n y: sliderPos[0],\n width: sliderRenderBounds.width,\n height: sliderSize\n };\n }\n\n const slider = group.createOrUpdateChild(\n 'slider',\n {\n ...sliderAttribute,\n cornerRadius: this._getDefaultSliderCornerRadius(),\n ...sliderStyle,\n boundsPadding: normalizePadding(padding),\n pickMode: 'imprecise'\n },\n 'rect'\n ) as IRect;\n this._slider = slider;\n this._container = group;\n\n const containerAABBBounds = this._container.AABBBounds;\n this._viewPosition = {\n x: containerAABBBounds.x1,\n y: containerAABBBounds.y1\n };\n }\n\n // 获取滑块渲染的包围盒区域\n private _getSliderRenderBounds() {\n if (this._sliderRenderBounds) {\n return this._sliderRenderBounds;\n }\n const { width, height, padding = 2 } = this.attribute as ScrollBarAttributes;\n const [top, right, bottom, left] = normalizePadding(padding);\n const renderBounds = {\n x1: left,\n y1: top,\n x2: width - right,\n y2: height - bottom,\n width: Math.max(0, width - (left + right)),\n height: Math.max(0, height - (top + bottom))\n };\n this._sliderRenderBounds = renderBounds;\n return renderBounds;\n }\n\n // 获取默认的滑块圆角\n private _getDefaultSliderCornerRadius() {\n const { direction, round } = this.attribute as ScrollBarAttributes;\n\n if (round) {\n const { width, height } = this._getSliderRenderBounds();\n return direction === 'horizontal' ? height : width;\n }\n\n return 0;\n }\n\n // 计算滑块在轨道的位置\n private _getSliderPos(range: [number, number]) {\n const { direction } = this.attribute as ScrollBarAttributes;\n const { width, height, x1, y1 } = this._getSliderRenderBounds();\n\n if (direction === 'horizontal') {\n return [width * range[0] + x1, width * range[1] + x1];\n }\n return [height * range[0] + y1, height * range[1] + y1];\n }\n\n private _getScrollRange() {\n if (this._sliderLimitRange) {\n return this._sliderLimitRange;\n }\n const { limitRange = [0, 1], direction } = this.attribute as ScrollBarAttributes;\n const [min, max] = clampRange(limitRange, 0, 1);\n const { width, height, x1, y1 } = this._getSliderRenderBounds();\n const sliderSize = this._sliderSize;\n\n return direction === 'horizontal'\n ? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)\n : clampRange([y1 + min * height, y1 + max * height], y1, height - sliderSize);\n }\n\n private _onRailPointerDown = (e: FederatedPointerEvent) => {\n // 将事件坐标转换为实际的滑块位置\n // TODO: 这里有问题,应该拿 viewX viewY,同时 graphic 要提供接口获取它的 相对 view 的坐标\n const { viewX, viewY } = e;\n const { direction, width, height, range } = this.attribute as ScrollBarAttributes;\n const sliderSize = this._sliderSize;\n const [min, max] = this._getScrollRange();\n let currentScrollValue;\n if (direction === 'vertical') {\n const relativeY = viewY - this._viewPosition.y;\n const currentYPos = clamp(relativeY - sliderSize / 2, min, max);\n currentScrollValue = relativeY / height;\n this._slider.setAttribute('y', currentYPos, true);\n } else {\n const relativeX = viewX - this._viewPosition.x;\n const currentXPos = clamp(relativeX - sliderSize / 2, min, max);\n currentScrollValue = relativeX / width;\n this._slider.setAttribute('x', currentXPos, true);\n }\n\n this.setScrollRange(\n [currentScrollValue - (range[1] - range[0]) / 2, currentScrollValue + (range[1] - range[0]) / 2],\n false\n );\n\n if (this.stage && !this.stage.autoRender) {\n this.stage.renderNextFrame();\n }\n };\n\n private _onSliderPointerDown = (e: FederatedPointerEvent) => {\n e.stopPropagation();\n const { direction } = this.attribute as ScrollBarAttributes;\n const { x, y } = this.stage.eventPointTransform(e);\n this._prePos = direction === 'horizontal' ? x : y;\n this._dispatchEvent('scrollDown', {\n pos: this._prePos,\n event: e\n });\n if (vglobal.env === 'browser') {\n vglobal.addEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n vglobal.addEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.addEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n this.stage.addEventListener('pointerup', this._onSliderPointerUp);\n this.stage.addEventListener('pointerupoutside', this._onSliderPointerUp);\n }\n };\n\n private _computeScrollValue = (e: any) => {\n const { direction } = this.attribute as ScrollBarAttributes;\n const { x, y } = this.stage.eventPointTransform(e);\n\n let currentScrollValue;\n let currentPos;\n let delta = 0;\n\n const { width, height } = this._getSliderRenderBounds();\n if (direction === 'vertical') {\n currentPos = y;\n delta = currentPos - this._prePos;\n currentScrollValue = delta / height;\n } else {\n currentPos = x;\n delta = currentPos - this._prePos;\n currentScrollValue = delta / width;\n }\n return [currentPos, currentScrollValue];\n };\n\n private _onSliderPointerMove = (e: any) => {\n e.stopPropagation();\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n this.setScrollRange([preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue], true);\n this._prePos = currentPos;\n };\n\n private _onSliderPointerMoveWithDelay =\n this.attribute.delayTime === 0\n ? this._onSliderPointerMove\n : delayMap[this.attribute.delayType](this._onSliderPointerMove, this.attribute.delayTime);\n\n private _onSliderPointerUp = (e: any) => {\n e.preventDefault();\n const { realTime = true, range: preRange, limitRange = [0, 1] } = this.attribute as ScrollBarAttributes;\n // 发射 change 事件\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n const range: [number, number] = [preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue];\n\n this._dispatchEvent('scrollUp', {\n pre: preRange,\n value: clampRange(range, limitRange[0], limitRange[1])\n });\n if (vglobal.env === 'browser') {\n vglobal.removeEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n vglobal.removeEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.removeEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n this.stage.removeEventListener('pointerup', this._onSliderPointerUp);\n this.stage.removeEventListener('pointerupoutside', this._onSliderPointerUp);\n }\n };\n\n private _reset() {\n this._sliderRenderBounds = null;\n this._sliderLimitRange = null;\n }\n}\n"]}