@visactor/vrender-components 0.17.2-alpha.2 → 0.17.2-alpha.4

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 (65) hide show
  1. package/cjs/axis/base.js +2 -12
  2. package/cjs/axis/base.js.map +1 -1
  3. package/cjs/brush/brush.d.ts +3 -12
  4. package/cjs/brush/brush.js +29 -28
  5. package/cjs/brush/brush.js.map +1 -1
  6. package/cjs/checkbox/checkbox.js +4 -8
  7. package/cjs/checkbox/checkbox.js.map +1 -1
  8. package/cjs/core/base.d.ts +2 -0
  9. package/cjs/core/base.js +6 -0
  10. package/cjs/core/base.js.map +1 -1
  11. package/cjs/data-zoom/data-zoom.d.ts +0 -3
  12. package/cjs/data-zoom/data-zoom.js +35 -37
  13. package/cjs/data-zoom/data-zoom.js.map +1 -1
  14. package/cjs/index.d.ts +1 -1
  15. package/cjs/index.js +1 -1
  16. package/cjs/index.js.map +1 -1
  17. package/cjs/legend/discrete/discrete.d.ts +1 -1
  18. package/cjs/legend/discrete/discrete.js +33 -37
  19. package/cjs/legend/discrete/discrete.js.map +1 -1
  20. package/cjs/pager/pager.js +4 -9
  21. package/cjs/pager/pager.js.map +1 -1
  22. package/cjs/player/base-player.js +2 -5
  23. package/cjs/player/base-player.js.map +1 -1
  24. package/cjs/player/controller/controller.d.ts +0 -1
  25. package/cjs/player/controller/controller.js +5 -16
  26. package/cjs/player/controller/controller.js.map +1 -1
  27. package/cjs/scrollbar/scrollbar.d.ts +0 -1
  28. package/cjs/scrollbar/scrollbar.js +2 -8
  29. package/cjs/scrollbar/scrollbar.js.map +1 -1
  30. package/cjs/slider/slider.js +2 -4
  31. package/cjs/slider/slider.js.map +1 -1
  32. package/dist/index.js +257 -166
  33. package/dist/index.min.js +1 -1
  34. package/es/axis/base.js +2 -12
  35. package/es/axis/base.js.map +1 -1
  36. package/es/brush/brush.d.ts +3 -12
  37. package/es/brush/brush.js +31 -30
  38. package/es/brush/brush.js.map +1 -1
  39. package/es/checkbox/checkbox.js +5 -9
  40. package/es/checkbox/checkbox.js.map +1 -1
  41. package/es/core/base.d.ts +2 -0
  42. package/es/core/base.js +7 -1
  43. package/es/core/base.js.map +1 -1
  44. package/es/data-zoom/data-zoom.d.ts +0 -3
  45. package/es/data-zoom/data-zoom.js +36 -37
  46. package/es/data-zoom/data-zoom.js.map +1 -1
  47. package/es/index.d.ts +1 -1
  48. package/es/index.js +1 -1
  49. package/es/index.js.map +1 -1
  50. package/es/legend/discrete/discrete.d.ts +1 -1
  51. package/es/legend/discrete/discrete.js +33 -38
  52. package/es/legend/discrete/discrete.js.map +1 -1
  53. package/es/pager/pager.js +5 -10
  54. package/es/pager/pager.js.map +1 -1
  55. package/es/player/base-player.js +1 -6
  56. package/es/player/base-player.js.map +1 -1
  57. package/es/player/controller/controller.d.ts +0 -1
  58. package/es/player/controller/controller.js +5 -18
  59. package/es/player/controller/controller.js.map +1 -1
  60. package/es/scrollbar/scrollbar.d.ts +0 -1
  61. package/es/scrollbar/scrollbar.js +3 -9
  62. package/es/scrollbar/scrollbar.js.map +1 -1
  63. package/es/slider/slider.js +3 -5
  64. package/es/slider/slider.js.map +1 -1
  65. package/package.json +7 -7
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.BasePlayer = void 0;
6
6
 
7
- const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), slider_1 = require("../slider"), controller_1 = require("./controller"), constant_1 = require("./constant"), utils_1 = require("./utils");
7
+ const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), slider_1 = require("../slider"), controller_1 = require("./controller"), constant_1 = require("./constant"), utils_1 = require("./utils");
8
8
 
9
9
  class BasePlayer extends base_1.AbstractComponent {
10
10
  constructor(attributes, options) {
@@ -162,14 +162,11 @@ class BasePlayer extends base_1.AbstractComponent {
162
162
  this._controller.setAttributes(attrs);
163
163
  }
164
164
  dispatchCustomEvent(eventType, dataIndex) {
165
- var _a;
166
- const changeEvent = new vrender_core_1.CustomEvent(eventType, {
165
+ this._dispatchEvent(eventType, {
167
166
  eventType: eventType,
168
167
  index: dataIndex,
169
168
  value: this._data[dataIndex]
170
169
  });
171
- changeEvent.manager = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventSystem.manager,
172
- this.dispatchEvent(changeEvent);
173
170
  }
174
171
  }
175
172
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/player/base-player.ts"],"names":[],"mappings":";;;AACA,yDAAqD;AACrD,6CAAuE;AACvE,uCAAiD;AAGjD,sCAAmC;AAEnC,6CAA0C;AAU1C,yCAA0E;AAC1E,mCAAuC;AAMvC,MAAa,UAAc,SAAQ,wBAA6C;IAoE9E,YAAY,UAAa,EAAE,OAA0B;QACnD,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAjCvF,UAAK,GAAG,EAAa,CAAC;QAqBxB,gBAAW,GASf,EAAE,CAAC;QAkHC,uBAAkB,GAAG,GAAG,EAAE;;YAChC,IAAI,WAAW,CAAC;YAChB,IAAI,IAAA,sBAAa,EAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;gBAC1C,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;aACvC;iBAAM,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE;gBACpE,WAAW,GAAG,IAAA,YAAG,EAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;aAC3E;YAED,MAAM,KAAK,GAAq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IACb,IAAI,EAAE,EAAa;IACnB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE;QACJ,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,GAAG;KACX;IACD,MAAM,EAAE;QACN,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,EAAE;QACT,EAAE,EAAE,CAAC;QACL,EAAE,EAAE,CAAC;QACL,SAAS,EAAE;YACT,YAAY,EAAE,CAAC;SAChB;QACD,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,EAAE;KACjB;IACD,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,KAAK,kCAAO,sCAA2B,KAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,GAAE;QACpF,KAAK,kCAAO,sCAA2B,KAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAE;QAC1E,OAAO,kCAAO,sCAA2B,KAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,GAAE;QAC5E,QAAQ,kCAAO,sCAA2B,KAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,GAAE;KACjF;CACF,CAAC","file":"base-player.js","sourcesContent":["import type { INode } from '@visactor/vrender-core';\nimport { CustomEvent } from '@visactor/vrender-core';\nimport { isNumber, isValidNumber, max, merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { ComponentOptions, OrientType } from '../interface';\nimport type { SliderAttributes } from '../slider';\nimport { Slider } from '../slider';\nimport type { ControllerAttributes } from './controller';\nimport { Controller } from './controller';\nimport type {\n Datum,\n PlayerEventEnum,\n PlayerAttributes,\n RailStyleType,\n ControllerType,\n TrackStyleType,\n HandlerStyleType\n} from './type';\nimport { RailDefaultSize, defaultControllerAttributes } from './constant';\nimport { isHorizontal } from './utils';\n\n/**\n * 基本播放器组件\n * 提供最基本的布局能力,\n */\nexport class BasePlayer<T> extends AbstractComponent<Required<PlayerAttributes>> {\n static defaultAttributes = {\n visible: true,\n data: [] as Datum[],\n interval: 1000,\n orient: 'bottom',\n align: 'center',\n size: {\n height: 20,\n width: 300\n },\n slider: {\n visible: true,\n space: 10,\n dx: 0,\n dy: 0,\n railStyle: {\n cornerRadius: 5\n },\n trackStyle: {},\n handlerStyle: {}\n },\n controller: {\n visible: true,\n start: { ...defaultControllerAttributes, key: 'start', position: 'start', space: 0 },\n pause: { ...defaultControllerAttributes, key: 'pause', position: 'start' },\n forward: { ...defaultControllerAttributes, key: 'forward', position: 'end' },\n backward: { ...defaultControllerAttributes, key: 'backward', position: 'start' }\n }\n };\n\n // 组件属性\n protected _slider: Slider;\n protected _controller: Controller;\n\n // 数据属性\n protected _data = [] as Datum[];\n protected _minIndex: number;\n protected _maxIndex: number;\n\n // 滑轨属性\n private _sliderVisible: boolean;\n private _railStyle: RailStyleType;\n private _trackStyle: TrackStyleType;\n private _handlerStyle: HandlerStyleType;\n\n // 控件属性\n private _controllerVisible: boolean;\n private _start: ControllerType;\n private _pause: ControllerType;\n private _forward: ControllerType;\n private _backward: ControllerType;\n\n // 布局属性\n private _size: { width: number; height: number };\n private _orient: OrientType;\n\n private _layoutInfo: {\n // 滚动条位置\n slider?: { x: number; y: number; size: number };\n\n // 控件位置\n start?: { x: number; y: number; size: number };\n pause?: { x: number; y: number; size: number };\n backward?: { x: number; y: number; size: number };\n forward?: { x: number; y: number; size: number };\n } = {};\n\n constructor(attributes: T, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, BasePlayer.defaultAttributes, attributes));\n // 先初始化属性, 再初始化Slider、Controller, 最后初始化事件.\n this._initAttributes();\n this._initLayoutInfo();\n this._initController();\n this._initSlider();\n }\n\n /**\n * 初始化属性\n */\n _initAttributes() {\n // 基本布局属性\n this._size = this.attribute.size;\n this._orient = this.attribute.orient;\n\n // Slider范围, 起点一定要从0开始\n this._data = this.attribute.data;\n this._minIndex = 0;\n this._maxIndex = this._data.length - 1;\n\n // 轨道样式\n this._sliderVisible = this.attribute?.slider?.visible;\n this._railStyle = { ...this.attribute?.slider?.railStyle };\n this._trackStyle = { ...this.attribute?.slider?.trackStyle };\n this._handlerStyle = { ...this.attribute?.slider?.handlerStyle };\n\n // 控制器样式\n this._controllerVisible = this.attribute?.controller?.visible;\n this._start = { ...this.attribute?.controller?.start };\n this._pause = { ...this.attribute?.controller?.pause };\n this._forward = { ...this.attribute?.controller?.forward };\n this._backward = { ...this.attribute?.controller?.backward };\n }\n\n private _initLayoutInfo() {\n // 控制器\n const controllers = [this._start, this._backward, this._forward].sort((a, b) => a.order - b.order);\n // 在开始位置的控制器\n const startControllers = controllers.filter(d => d.position !== 'end');\n // 在结束位置的控制器\n const endControllers = controllers.filter(d => d.position === 'end');\n // 滑轨横切面长度\n const railSectionLength =\n (isHorizontal(this._orient) ? this._railStyle.height : this._railStyle.width) ?? RailDefaultSize[1];\n\n // 1. 计算所有组件自身占据的宽度 or 高度\n const controllerPx = controllers.reduce((len, controller) => {\n const size = controller.style.size;\n const maxSize = isNumber(size) ? size : max(size[0], size[1]);\n return len + controller.space + maxSize;\n }, 0);\n\n // 2. 计算slider的总占据像素\n const sliderPx = this._sliderVisible\n ? (isHorizontal(this._orient) ? this._size?.width : this._size?.height) - controllerPx\n : 0;\n\n // 3. 计算slider滑轨的总占据像素\n const railPx = sliderPx - this.attribute.slider.space;\n\n // 4. 计算起点控件坐标\n const startPx = startControllers.reduce((px, controller) => {\n const {\n key,\n space,\n style: { size }\n } = controller;\n const maxSize = isNumber(size) ? size : max(size[0], size[1]);\n this._layoutInfo[key] = {\n ...this._layoutInfo[key],\n size: maxSize,\n x: isHorizontal(this._orient) ? px + space : (this._size.width - maxSize) / 2,\n y: isHorizontal(this._orient) ? (this._size.height - maxSize) / 2 : px + space\n };\n return px + space + maxSize;\n }, 0);\n\n // 5. 计算slider的起点坐标\n this._layoutInfo.slider = {\n ...this._layoutInfo.slider,\n size: railPx,\n x: isHorizontal(this._orient)\n ? startPx + this.attribute.slider.space\n : (this._size.width - railSectionLength) / 2,\n y: isHorizontal(this._orient)\n ? (this._size.height - railSectionLength) / 2\n : startPx + this.attribute.slider.space\n };\n\n // 6. 计算终点控件坐标\n endControllers.reduce((px, controller) => {\n const {\n key,\n space,\n style: { size }\n } = controller;\n const maxSize = isNumber(size) ? size : max(size[0], size[1]);\n this._layoutInfo[key] = {\n ...this._layoutInfo[key],\n size: maxSize,\n x: isHorizontal(this._orient) ? px + space : (this._size.width - maxSize) / 2,\n y: isHorizontal(this._orient) ? (this._size.height - maxSize) / 2 : px + space\n };\n return px + space + maxSize;\n }, startPx + sliderPx);\n }\n\n /**\n * 初始化滑动条\n */\n private _updateSliderAttrs = () => {\n let handlerSize;\n if (isValidNumber(this._handlerStyle.size)) {\n handlerSize = this._handlerStyle.size;\n } else if (this._handlerStyle.size && this._handlerStyle.size.length) {\n handlerSize = max(this._handlerStyle.size[0], this._handlerStyle.size[1]);\n }\n\n const attrs: SliderAttributes = {\n visible: this._sliderVisible,\n // 重要参数\n min: this._minIndex,\n max: this._maxIndex,\n value: this.attribute.dataIndex ?? 0,\n railWidth: this._railStyle.width,\n railHeight: this._railStyle.height,\n railStyle: this._railStyle,\n trackStyle: this._trackStyle,\n handlerSize: isValidNumber(handlerSize) ? handlerSize : undefined,\n handlerStyle: this._handlerStyle,\n // 不重要, 但需要预设的参数\n dy: this.attribute.slider.dy,\n dx: this.attribute.slider.dx,\n slidable: true,\n range: false,\n handlerText: { visible: false },\n startText: { visible: false },\n endText: { visible: false },\n disableTriggerEvent: this.attribute.disableTriggerEvent\n };\n\n // 横向布局\n if (isHorizontal(this._orient)) {\n // 滑动条水平居中\n const railWidth = Math.max(0, this._layoutInfo.slider.size);\n const railHeight = this._railStyle.height ?? RailDefaultSize[1];\n\n // 属性修改\n attrs.layout = 'horizontal';\n attrs.railHeight = railHeight;\n attrs.railWidth = railWidth;\n attrs.x = this._layoutInfo.slider.x;\n attrs.y = this._layoutInfo.slider.y;\n }\n // 纵向布局\n else {\n // 滑动条垂直居中\n const railHeight = Math.max(0, this._layoutInfo.slider.size);\n const railWidth = this._railStyle.width ?? RailDefaultSize[1];\n\n // 属性修改\n attrs.layout = 'vertical';\n attrs.railWidth = railWidth;\n attrs.railHeight = railHeight;\n attrs.x = this._layoutInfo.slider.x;\n attrs.y = this._layoutInfo.slider.y;\n }\n return attrs;\n };\n\n private _initSlider = () => {\n const attrs = this._updateSliderAttrs();\n this._slider = new Slider(attrs);\n if (this._sliderVisible) {\n this.add(this._slider as unknown as INode);\n }\n };\n\n /**\n * 初始化控制器\n */\n private _updateControllerAttrs = () => {\n const attrs: ControllerAttributes = {\n start: this._start,\n pause: this._pause,\n forward: this._forward,\n backward: this._backward,\n disableTriggerEvent: this.attribute.disableTriggerEvent\n };\n // 横向布局\n if (isHorizontal(this._orient)) {\n attrs.layout = 'horizontal';\n attrs.start = {\n ...attrs.start,\n style: {\n ...attrs.start.style,\n x: this._layoutInfo.start.x,\n y: this._layoutInfo.start.y\n }\n };\n attrs.pause = {\n ...attrs.pause,\n // 暂停按钮, 复用开始按钮的布局\n style: {\n ...attrs.pause.style,\n x: this._layoutInfo.start.x,\n y: this._layoutInfo.start.y\n }\n };\n attrs.backward = {\n ...attrs.backward,\n style: {\n ...attrs.backward.style,\n x: this._layoutInfo.backward.x,\n y: this._layoutInfo.backward.y\n }\n };\n attrs.forward = {\n ...attrs.forward,\n style: {\n ...attrs.forward.style,\n x: this._layoutInfo.forward.x,\n y: this._layoutInfo.forward.y\n }\n };\n }\n // 纵向布局\n else {\n attrs.layout = 'vertical';\n attrs.start = {\n ...attrs.start,\n style: {\n ...attrs.start.style,\n x: this._layoutInfo.start.x,\n y: this._layoutInfo.start.y\n }\n };\n attrs.pause = {\n ...attrs.pause,\n style: {\n ...attrs.pause.style,\n // 暂停按钮, 复用开始按钮的布局\n x: this._layoutInfo.start.x,\n y: this._layoutInfo.start.y\n }\n };\n attrs.backward = {\n ...attrs.backward,\n style: {\n ...attrs.backward.style,\n x: this._layoutInfo.backward.x,\n y: this._layoutInfo.backward.y\n }\n };\n attrs.forward = {\n ...attrs.forward,\n style: {\n ...attrs.forward.style,\n x: this._layoutInfo.forward.x,\n y: this._layoutInfo.forward.y\n }\n };\n }\n return attrs;\n };\n\n private _initController = () => {\n const attrs = this._updateControllerAttrs();\n this._controller = new Controller(attrs);\n if (this._controllerVisible) {\n this.add(this._controller as unknown as INode);\n }\n };\n\n /**\n * 渲染\n */\n render() {\n this._initLayoutInfo();\n this.renderSlider();\n this.renderController();\n }\n\n /**\n * 更新滑动条\n */\n renderSlider() {\n const attrs = this._updateSliderAttrs();\n this._slider.setAttributes(attrs);\n }\n\n /**\n * 更新控制器\n */\n renderController() {\n const attrs = this._updateControllerAttrs();\n this._controller.setAttributes(attrs);\n }\n\n /**\n * 触发事件\n * @param eventType 事件类型\n * @param dataIndex 数据下标\n */\n dispatchCustomEvent(eventType: PlayerEventEnum, dataIndex: number) {\n const changeEvent = new CustomEvent(eventType, {\n eventType,\n index: dataIndex,\n value: this._data[dataIndex]\n } as unknown);\n // @ts-ignore; 需要在 vrender 的事件系统支持\n changeEvent.manager = this.stage?.eventSystem.manager;\n this.dispatchEvent(changeEvent);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/player/base-player.ts"],"names":[],"mappings":";;;AACA,6CAAuE;AACvE,uCAAiD;AAGjD,sCAAmC;AAEnC,6CAA0C;AAU1C,yCAA0E;AAC1E,mCAAuC;AAMvC,MAAa,UAAc,SAAQ,wBAA6C;IAoE9E,YAAY,UAAa,EAAE,OAA0B;QACnD,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAjCvF,UAAK,GAAG,EAAa,CAAC;QAqBxB,gBAAW,GAS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C5C,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAOD,mBAAmB,CAAC,SAA0B,EAAE,SAAiB;QAC/D,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE;YAC7B,SAAS;YACT,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;SAC7B,CAAC,CAAC;IACL,CAAC;;AA5XH,gCA6XC;AA5XQ,4BAAiB,GAAG;IACzB,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,EAAa;IACnB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE;QACJ,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,GAAG;KACX;IACD,MAAM,EAAE;QACN,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,EAAE;QACT,EAAE,EAAE,CAAC;QACL,EAAE,EAAE,CAAC;QACL,SAAS,EAAE;YACT,YAAY,EAAE,CAAC;SAChB;QACD,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,EAAE;KACjB;IACD,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,KAAK,kCAAO,sCAA2B,KAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,GAAE;QACpF,KAAK,kCAAO,sCAA2B,KAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAE;QAC1E,OAAO,kCAAO,sCAA2B,KAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,GAAE;QAC5E,QAAQ,kCAAO,sCAA2B,KAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,GAAE;KACjF;CACF,CAAC","file":"base-player.js","sourcesContent":["import type { INode } from '@visactor/vrender-core';\nimport { isNumber, isValidNumber, max, merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { ComponentOptions, OrientType } from '../interface';\nimport type { SliderAttributes } from '../slider';\nimport { Slider } from '../slider';\nimport type { ControllerAttributes } from './controller';\nimport { Controller } from './controller';\nimport type {\n Datum,\n PlayerEventEnum,\n PlayerAttributes,\n RailStyleType,\n ControllerType,\n TrackStyleType,\n HandlerStyleType\n} from './type';\nimport { RailDefaultSize, defaultControllerAttributes } from './constant';\nimport { isHorizontal } from './utils';\n\n/**\n * 基本播放器组件\n * 提供最基本的布局能力,\n */\nexport class BasePlayer<T> extends AbstractComponent<Required<PlayerAttributes>> {\n static defaultAttributes = {\n visible: true,\n data: [] as Datum[],\n interval: 1000,\n orient: 'bottom',\n align: 'center',\n size: {\n height: 20,\n width: 300\n },\n slider: {\n visible: true,\n space: 10,\n dx: 0,\n dy: 0,\n railStyle: {\n cornerRadius: 5\n },\n trackStyle: {},\n handlerStyle: {}\n },\n controller: {\n visible: true,\n start: { ...defaultControllerAttributes, key: 'start', position: 'start', space: 0 },\n pause: { ...defaultControllerAttributes, key: 'pause', position: 'start' },\n forward: { ...defaultControllerAttributes, key: 'forward', position: 'end' },\n backward: { ...defaultControllerAttributes, key: 'backward', position: 'start' }\n }\n };\n\n // 组件属性\n protected _slider: Slider;\n protected _controller: Controller;\n\n // 数据属性\n protected _data = [] as Datum[];\n protected _minIndex: number;\n protected _maxIndex: number;\n\n // 滑轨属性\n private _sliderVisible: boolean;\n private _railStyle: RailStyleType;\n private _trackStyle: TrackStyleType;\n private _handlerStyle: HandlerStyleType;\n\n // 控件属性\n private _controllerVisible: boolean;\n private _start: ControllerType;\n private _pause: ControllerType;\n private _forward: ControllerType;\n private _backward: ControllerType;\n\n // 布局属性\n private _size: { width: number; height: number };\n private _orient: OrientType;\n\n private _layoutInfo: {\n // 滚动条位置\n slider?: { x: number; y: number; size: number };\n\n // 控件位置\n start?: { x: number; y: number; size: number };\n pause?: { x: number; y: number; size: number };\n backward?: { x: number; y: number; size: number };\n forward?: { x: number; y: number; size: number };\n } = {};\n\n constructor(attributes: T, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, BasePlayer.defaultAttributes, attributes));\n // 先初始化属性, 再初始化Slider、Controller, 最后初始化事件.\n this._initAttributes();\n this._initLayoutInfo();\n this._initController();\n this._initSlider();\n }\n\n /**\n * 初始化属性\n */\n _initAttributes() {\n // 基本布局属性\n this._size = this.attribute.size;\n this._orient = this.attribute.orient;\n\n // Slider范围, 起点一定要从0开始\n this._data = this.attribute.data;\n this._minIndex = 0;\n this._maxIndex = this._data.length - 1;\n\n // 轨道样式\n this._sliderVisible = this.attribute?.slider?.visible;\n this._railStyle = { ...this.attribute?.slider?.railStyle };\n this._trackStyle = { ...this.attribute?.slider?.trackStyle };\n this._handlerStyle = { ...this.attribute?.slider?.handlerStyle };\n\n // 控制器样式\n this._controllerVisible = this.attribute?.controller?.visible;\n this._start = { ...this.attribute?.controller?.start };\n this._pause = { ...this.attribute?.controller?.pause };\n this._forward = { ...this.attribute?.controller?.forward };\n this._backward = { ...this.attribute?.controller?.backward };\n }\n\n private _initLayoutInfo() {\n // 控制器\n const controllers = [this._start, this._backward, this._forward].sort((a, b) => a.order - b.order);\n // 在开始位置的控制器\n const startControllers = controllers.filter(d => d.position !== 'end');\n // 在结束位置的控制器\n const endControllers = controllers.filter(d => d.position === 'end');\n // 滑轨横切面长度\n const railSectionLength =\n (isHorizontal(this._orient) ? this._railStyle.height : this._railStyle.width) ?? RailDefaultSize[1];\n\n // 1. 计算所有组件自身占据的宽度 or 高度\n const controllerPx = controllers.reduce((len, controller) => {\n const size = controller.style.size;\n const maxSize = isNumber(size) ? size : max(size[0], size[1]);\n return len + controller.space + maxSize;\n }, 0);\n\n // 2. 计算slider的总占据像素\n const sliderPx = this._sliderVisible\n ? (isHorizontal(this._orient) ? this._size?.width : this._size?.height) - controllerPx\n : 0;\n\n // 3. 计算slider滑轨的总占据像素\n const railPx = sliderPx - this.attribute.slider.space;\n\n // 4. 计算起点控件坐标\n const startPx = startControllers.reduce((px, controller) => {\n const {\n key,\n space,\n style: { size }\n } = controller;\n const maxSize = isNumber(size) ? size : max(size[0], size[1]);\n this._layoutInfo[key] = {\n ...this._layoutInfo[key],\n size: maxSize,\n x: isHorizontal(this._orient) ? px + space : (this._size.width - maxSize) / 2,\n y: isHorizontal(this._orient) ? (this._size.height - maxSize) / 2 : px + space\n };\n return px + space + maxSize;\n }, 0);\n\n // 5. 计算slider的起点坐标\n this._layoutInfo.slider = {\n ...this._layoutInfo.slider,\n size: railPx,\n x: isHorizontal(this._orient)\n ? startPx + this.attribute.slider.space\n : (this._size.width - railSectionLength) / 2,\n y: isHorizontal(this._orient)\n ? (this._size.height - railSectionLength) / 2\n : startPx + this.attribute.slider.space\n };\n\n // 6. 计算终点控件坐标\n endControllers.reduce((px, controller) => {\n const {\n key,\n space,\n style: { size }\n } = controller;\n const maxSize = isNumber(size) ? size : max(size[0], size[1]);\n this._layoutInfo[key] = {\n ...this._layoutInfo[key],\n size: maxSize,\n x: isHorizontal(this._orient) ? px + space : (this._size.width - maxSize) / 2,\n y: isHorizontal(this._orient) ? (this._size.height - maxSize) / 2 : px + space\n };\n return px + space + maxSize;\n }, startPx + sliderPx);\n }\n\n /**\n * 初始化滑动条\n */\n private _updateSliderAttrs = () => {\n let handlerSize;\n if (isValidNumber(this._handlerStyle.size)) {\n handlerSize = this._handlerStyle.size;\n } else if (this._handlerStyle.size && this._handlerStyle.size.length) {\n handlerSize = max(this._handlerStyle.size[0], this._handlerStyle.size[1]);\n }\n\n const attrs: SliderAttributes = {\n visible: this._sliderVisible,\n // 重要参数\n min: this._minIndex,\n max: this._maxIndex,\n value: this.attribute.dataIndex ?? 0,\n railWidth: this._railStyle.width,\n railHeight: this._railStyle.height,\n railStyle: this._railStyle,\n trackStyle: this._trackStyle,\n handlerSize: isValidNumber(handlerSize) ? handlerSize : undefined,\n handlerStyle: this._handlerStyle,\n // 不重要, 但需要预设的参数\n dy: this.attribute.slider.dy,\n dx: this.attribute.slider.dx,\n slidable: true,\n range: false,\n handlerText: { visible: false },\n startText: { visible: false },\n endText: { visible: false },\n disableTriggerEvent: this.attribute.disableTriggerEvent\n };\n\n // 横向布局\n if (isHorizontal(this._orient)) {\n // 滑动条水平居中\n const railWidth = Math.max(0, this._layoutInfo.slider.size);\n const railHeight = this._railStyle.height ?? RailDefaultSize[1];\n\n // 属性修改\n attrs.layout = 'horizontal';\n attrs.railHeight = railHeight;\n attrs.railWidth = railWidth;\n attrs.x = this._layoutInfo.slider.x;\n attrs.y = this._layoutInfo.slider.y;\n }\n // 纵向布局\n else {\n // 滑动条垂直居中\n const railHeight = Math.max(0, this._layoutInfo.slider.size);\n const railWidth = this._railStyle.width ?? RailDefaultSize[1];\n\n // 属性修改\n attrs.layout = 'vertical';\n attrs.railWidth = railWidth;\n attrs.railHeight = railHeight;\n attrs.x = this._layoutInfo.slider.x;\n attrs.y = this._layoutInfo.slider.y;\n }\n return attrs;\n };\n\n private _initSlider = () => {\n const attrs = this._updateSliderAttrs();\n this._slider = new Slider(attrs);\n if (this._sliderVisible) {\n this.add(this._slider as unknown as INode);\n }\n };\n\n /**\n * 初始化控制器\n */\n private _updateControllerAttrs = () => {\n const attrs: ControllerAttributes = {\n start: this._start,\n pause: this._pause,\n forward: this._forward,\n backward: this._backward,\n disableTriggerEvent: this.attribute.disableTriggerEvent\n };\n // 横向布局\n if (isHorizontal(this._orient)) {\n attrs.layout = 'horizontal';\n attrs.start = {\n ...attrs.start,\n style: {\n ...attrs.start.style,\n x: this._layoutInfo.start.x,\n y: this._layoutInfo.start.y\n }\n };\n attrs.pause = {\n ...attrs.pause,\n // 暂停按钮, 复用开始按钮的布局\n style: {\n ...attrs.pause.style,\n x: this._layoutInfo.start.x,\n y: this._layoutInfo.start.y\n }\n };\n attrs.backward = {\n ...attrs.backward,\n style: {\n ...attrs.backward.style,\n x: this._layoutInfo.backward.x,\n y: this._layoutInfo.backward.y\n }\n };\n attrs.forward = {\n ...attrs.forward,\n style: {\n ...attrs.forward.style,\n x: this._layoutInfo.forward.x,\n y: this._layoutInfo.forward.y\n }\n };\n }\n // 纵向布局\n else {\n attrs.layout = 'vertical';\n attrs.start = {\n ...attrs.start,\n style: {\n ...attrs.start.style,\n x: this._layoutInfo.start.x,\n y: this._layoutInfo.start.y\n }\n };\n attrs.pause = {\n ...attrs.pause,\n style: {\n ...attrs.pause.style,\n // 暂停按钮, 复用开始按钮的布局\n x: this._layoutInfo.start.x,\n y: this._layoutInfo.start.y\n }\n };\n attrs.backward = {\n ...attrs.backward,\n style: {\n ...attrs.backward.style,\n x: this._layoutInfo.backward.x,\n y: this._layoutInfo.backward.y\n }\n };\n attrs.forward = {\n ...attrs.forward,\n style: {\n ...attrs.forward.style,\n x: this._layoutInfo.forward.x,\n y: this._layoutInfo.forward.y\n }\n };\n }\n return attrs;\n };\n\n private _initController = () => {\n const attrs = this._updateControllerAttrs();\n this._controller = new Controller(attrs);\n if (this._controllerVisible) {\n this.add(this._controller as unknown as INode);\n }\n };\n\n /**\n * 渲染\n */\n render() {\n this._initLayoutInfo();\n this.renderSlider();\n this.renderController();\n }\n\n /**\n * 更新滑动条\n */\n renderSlider() {\n const attrs = this._updateSliderAttrs();\n this._slider.setAttributes(attrs);\n }\n\n /**\n * 更新控制器\n */\n renderController() {\n const attrs = this._updateControllerAttrs();\n this._controller.setAttributes(attrs);\n }\n\n /**\n * 触发事件\n * @param eventType 事件类型\n * @param dataIndex 数据下标\n */\n dispatchCustomEvent(eventType: PlayerEventEnum, dataIndex: number) {\n this._dispatchEvent(eventType, {\n eventType,\n index: dataIndex,\n value: this._data[dataIndex]\n });\n }\n}\n"]}
@@ -21,7 +21,6 @@ export declare class Controller extends AbstractComponent<Required<ControllerAtt
21
21
  private _initBackward;
22
22
  private _initForward;
23
23
  private _initEvents;
24
- private _createCustomEvent;
25
24
  render(): void;
26
25
  renderPlay: () => void;
27
26
  renderBackward: () => void;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.Controller = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), vrender_core_1 = require("@visactor/vrender-core"), base_1 = require("../../core/base"), assets_1 = require("./assets"), icon_1 = require("./icon"), constant_1 = require("./constant");
7
+ const vutils_1 = require("@visactor/vutils"), base_1 = require("../../core/base"), assets_1 = require("./assets"), icon_1 = require("./icon"), constant_1 = require("./constant");
8
8
 
9
9
  class Controller extends base_1.AbstractComponent {
10
10
  constructor(attributes, options) {
@@ -53,13 +53,6 @@ class Controller extends base_1.AbstractComponent {
53
53
  })), this._forwardController.addEventListener("pointerdown", (e => {
54
54
  e.stopPropagation(), this.forward();
55
55
  })));
56
- }, this._createCustomEvent = eventType => {
57
- var _a;
58
- const customEvent = new vrender_core_1.CustomEvent(eventType, {
59
- eventType: eventType
60
- });
61
- return customEvent.manager = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventSystem.manager,
62
- customEvent;
63
56
  }, this.renderPlay = () => {
64
57
  this._isPaused ? this._playController.setAttributes(Object.assign({
65
58
  symbolType: this._playController.getComputedAttribute("symbolType")
@@ -71,17 +64,13 @@ class Controller extends base_1.AbstractComponent {
71
64
  }, this.renderForward = () => {
72
65
  this._forwardController.setAttributes(this._forwardAttr.style);
73
66
  }, this.play = () => {
74
- const onPlayEvent = this._createCustomEvent(constant_1.ControllerEventEnum.OnPlay);
75
- this.dispatchEvent(onPlayEvent);
67
+ this._dispatchEvent("ControllerEventEnum.OnPlay");
76
68
  }, this.pause = () => {
77
- const onPauseEvent = this._createCustomEvent(constant_1.ControllerEventEnum.OnPause);
78
- this.dispatchEvent(onPauseEvent);
69
+ this._dispatchEvent("ControllerEventEnum.OnPause");
79
70
  }, this.forward = () => {
80
- const onPlayEvent = this._createCustomEvent(constant_1.ControllerEventEnum.OnForward);
81
- this.dispatchEvent(onPlayEvent);
71
+ this._dispatchEvent("ControllerEventEnum.OnForward");
82
72
  }, this.backward = () => {
83
- const onPlayEvent = this._createCustomEvent(constant_1.ControllerEventEnum.OnBackward);
84
- this.dispatchEvent(onPlayEvent);
73
+ this._dispatchEvent("ControllerEventEnum.OnBackward");
85
74
  }, this.togglePlay = () => {
86
75
  this._playController.setAttributes(this._startAttr.style), this._isPaused = !0;
87
76
  }, this.togglePause = () => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/player/controller/controller.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAEhD,yDAAqD;AACrD,0CAAoD;AAGpD,qCAAsF;AACtF,iCAAoC;AACpC,yCAAqE;AAGrE,MAAa,UAAW,SAAQ,wBAAiD;IA4B/E,YAAY,UAAgC,EAAE,OAA0B;QACtE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAZzF,cAAS,GAAG,IAAI,CAAC;QAoBzB,qBAAgB,GAAG,GAAG,EAAE;YACtB,IAAI,CAAC,UAAU,GAAG;gBAChB,KAAK,8CACH,UAAU,EAAE,iBAAQ,IACjB,UAAU,CAAC,qBAAqB,KACnC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,KAClC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAC9B;aACF,CAAC;YACF,IAAI,CAAC,UAAU,GAAG;gBAChB,KAAK,8CACH,UAAU,EAAE,kBAAS,IAClB,UAAU,CAAC,qBAAqB,KACnC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,KAClC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAC9B;aACF,CAAC;YACF,IAAI,CAAC,YAAY,GAAG;gBAClB,KAAK,gDACA,UAAU,CAAC,qBAAqB,KACnC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,KACpC,IAAI,CAAC,SAAS,CAAC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AC;QAClB,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;;AA7JH,gCAkNC;AAjNQ,gCAAqB,GAA4B;IACtD,OAAO,EAAE,IAAI;IACb,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,WAAW;IACrB,MAAM,EAAE,SAAS;CAClB,CAAC;AACK,4BAAiB,GAAyB;IAC/C,CAAC,6BAAkB,CAAC,KAAK,CAAC,EAAE,EAAE;IAC9B,CAAC,6BAAkB,CAAC,KAAK,CAAC,EAAE,EAAE;IAC9B,CAAC,6BAAkB,CAAC,QAAQ,CAAC,EAAE,EAAE;IACjC,CAAC,6BAAkB,CAAC,OAAO,CAAC,EAAE,EAAE;CACjC,CAAC","file":"controller.js","sourcesContent":["import { isNil, merge } from '@visactor/vutils';\nimport type { FederatedPointerEvent, ISymbolGraphicAttribute } from '@visactor/vrender-core';\nimport { CustomEvent } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../../core/base';\nimport type { BaseGraphicAttributes } from '../../core/type';\nimport type { ControllerAttributes, LayoutType } from './type';\nimport { iconRight, iconPause, iconPlay, iconLeft, iconUp, iconDown } from './assets';\nimport { PlayerIcon } from './icon';\nimport { ControllerEventEnum, ControllerTypeEnum } from './constant';\nimport type { ComponentOptions } from '../../interface';\n\nexport class Controller extends AbstractComponent<Required<ControllerAttributes>> {\n static defaultControllerAttr: ISymbolGraphicAttribute = {\n visible: true,\n x: 0,\n y: 0,\n size: 20,\n fill: '#91caff',\n pickMode: 'imprecise',\n cursor: 'pointer'\n };\n static defaultAttributes: ControllerAttributes = {\n [ControllerTypeEnum.Start]: {},\n [ControllerTypeEnum.Pause]: {},\n [ControllerTypeEnum.Backward]: {},\n [ControllerTypeEnum.Forward]: {}\n };\n\n private _isPaused = true;\n private _playController: PlayerIcon;\n private _forwardController: PlayerIcon;\n private _backwardController: PlayerIcon;\n\n private _layout: LayoutType;\n private _startAttr: BaseGraphicAttributes<ISymbolGraphicAttribute>;\n private _pauseAttr: BaseGraphicAttributes<ISymbolGraphicAttribute>;\n private _forwardAttr: BaseGraphicAttributes<ISymbolGraphicAttribute>;\n private _backwardAttr: BaseGraphicAttributes<ISymbolGraphicAttribute>;\n\n constructor(attributes: ControllerAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Controller.defaultAttributes, attributes));\n this.updateAttributes();\n this._initPlay();\n this._initBackward();\n this._initForward();\n this._initEvents();\n }\n\n updateAttributes = () => {\n this._startAttr = {\n style: {\n symbolType: iconPlay,\n ...Controller.defaultControllerAttr,\n visible: this.attribute.start.visible,\n ...this.attribute.start.style\n }\n };\n this._pauseAttr = {\n style: {\n symbolType: iconPause,\n ...Controller.defaultControllerAttr,\n visible: this.attribute.pause.visible,\n ...this.attribute.pause.style\n }\n };\n this._forwardAttr = {\n style: {\n ...Controller.defaultControllerAttr,\n visible: this.attribute.forward.visible,\n ...this.attribute.forward.style\n }\n };\n this._backwardAttr = {\n style: {\n ...Controller.defaultControllerAttr,\n visible: this.attribute.backward.visible,\n ...this.attribute.backward.style\n }\n };\n this.updateLayout();\n };\n\n private updateLayout = () => {\n this._layout = this.attribute.layout;\n // 若水平布局\n if (this._layout === 'horizontal') {\n this._backwardAttr.style.symbolType = this._backwardAttr.style?.symbolType ?? iconLeft;\n this._forwardAttr.style.symbolType = this._forwardAttr.style?.symbolType ?? iconRight;\n }\n // 若垂直布局\n else if (this._layout === 'vertical') {\n this._backwardAttr.style.symbolType = this._backwardAttr.style?.symbolType ?? iconUp;\n this._forwardAttr.style.symbolType = this._forwardAttr.style?.symbolType ?? iconDown;\n }\n };\n\n private _initPlay = () => {\n if (isNil(this._playController)) {\n this._playController = new PlayerIcon({\n ...this._startAttr.style\n });\n\n this.add(this._playController);\n }\n };\n\n private _initBackward = () => {\n if (isNil(this._backwardController)) {\n this._backwardController = new PlayerIcon({\n ...this._backwardAttr.style\n });\n\n this.add(this._backwardController);\n }\n };\n\n private _initForward = () => {\n if (isNil(this._forwardController)) {\n this._forwardController = new PlayerIcon({\n ...this._forwardAttr.style\n });\n\n this.add(this._forwardController);\n }\n };\n\n /**\n * 初始化事件\n * 1. 注册\n */\n private _initEvents = () => {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n this._playController.addEventListener('pointerdown', (e: FederatedPointerEvent) => {\n e.stopPropagation();\n\n if (this._isPaused === true) {\n this.play();\n } else {\n this.pause();\n }\n });\n\n this._backwardController.addEventListener('pointerdown', (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.backward();\n });\n\n this._forwardController.addEventListener('pointerdown', (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.forward();\n });\n };\n\n private _createCustomEvent = (eventType: ControllerEventEnum) => {\n const customEvent = new CustomEvent(eventType, { eventType });\n // FIXME: 需要在 vrender 的事件系统支持\n // @ts-ignore\n customEvent.manager = this.stage?.eventSystem.manager;\n return customEvent;\n };\n\n render(): void {\n this.updateAttributes();\n this.renderPlay();\n this.renderBackward();\n this.renderForward();\n }\n\n renderPlay = () => {\n if (this._isPaused) {\n this._playController.setAttributes({\n symbolType: this._playController.getComputedAttribute('symbolType'),\n ...this._startAttr.style\n });\n } else {\n this._playController.setAttributes({\n symbolType: this._playController.getComputedAttribute('symbolType'),\n ...this._pauseAttr.style\n });\n }\n };\n\n renderBackward = () => {\n this._backwardController.setAttributes(this._backwardAttr.style);\n };\n\n renderForward = () => {\n this._forwardController.setAttributes(this._forwardAttr.style);\n };\n\n play = () => {\n const onPlayEvent = this._createCustomEvent(ControllerEventEnum.OnPlay);\n this.dispatchEvent(onPlayEvent);\n };\n\n pause = () => {\n const onPauseEvent = this._createCustomEvent(ControllerEventEnum.OnPause);\n this.dispatchEvent(onPauseEvent);\n };\n\n forward = () => {\n const onPlayEvent = this._createCustomEvent(ControllerEventEnum.OnForward);\n this.dispatchEvent(onPlayEvent);\n };\n\n backward = () => {\n const onPlayEvent = this._createCustomEvent(ControllerEventEnum.OnBackward);\n this.dispatchEvent(onPlayEvent);\n };\n\n togglePlay = () => {\n this._playController.setAttributes(this._startAttr.style);\n this._isPaused = true;\n };\n\n togglePause = () => {\n this._playController.setAttributes(this._pauseAttr.style);\n this._isPaused = false;\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/player/controller/controller.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAEhD,0CAAoD;AAGpD,qCAAsF;AACtF,iCAAoC;AACpC,yCAAgD;AAGhD,MAAa,UAAW,SAAQ,wBAAiD;IA4B/E,YAAY,UAAgC,EAAE,OAA0B;QACtE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAZzF,cAAS,GAAG,IAAI,CAAC;QAoBzB,qBAAgB,GAAG,GAAG,EAAE;YACtB,IAAI,CAAC,UAAU,GAAG;gBAChB,KAAK,8CACH,UAAU,EAAE,iBAAQ,IACjB,UAAU,CAAC,qBAAqB,KACnC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,KAClC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAC9B;aACF,CAAC;YACF,IAAI,CAAC,UAAU,GAAG;gBAChB,KAAK,8CACH,UAAU,EAAE,kBAAS,IAClB,UAAU,CAAC,qBAAqB,KACnC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,KAClC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAC9B;aACF,CAAC;YACF,IAAI,CAAC,YAAY,GAAG;gBAClB,KAAK,gDACA,UAAU,CAAC,qBAAqB,KACnC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAA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esContent":["import { isNil, merge } from '@visactor/vutils';\nimport type { FederatedPointerEvent, ISymbolGraphicAttribute } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../../core/base';\nimport type { BaseGraphicAttributes } from '../../core/type';\nimport type { ControllerAttributes, LayoutType } from './type';\nimport { iconRight, iconPause, iconPlay, iconLeft, iconUp, iconDown } from './assets';\nimport { PlayerIcon } from './icon';\nimport { ControllerTypeEnum } from './constant';\nimport type { ComponentOptions } from '../../interface';\n\nexport class Controller extends AbstractComponent<Required<ControllerAttributes>> {\n static defaultControllerAttr: ISymbolGraphicAttribute = {\n visible: true,\n x: 0,\n y: 0,\n size: 20,\n fill: '#91caff',\n pickMode: 'imprecise',\n cursor: 'pointer'\n };\n static defaultAttributes: ControllerAttributes = {\n [ControllerTypeEnum.Start]: {},\n [ControllerTypeEnum.Pause]: {},\n [ControllerTypeEnum.Backward]: {},\n [ControllerTypeEnum.Forward]: {}\n };\n\n private _isPaused = true;\n private _playController: PlayerIcon;\n private _forwardController: PlayerIcon;\n private _backwardController: PlayerIcon;\n\n private _layout: LayoutType;\n private _startAttr: BaseGraphicAttributes<ISymbolGraphicAttribute>;\n private _pauseAttr: BaseGraphicAttributes<ISymbolGraphicAttribute>;\n private _forwardAttr: BaseGraphicAttributes<ISymbolGraphicAttribute>;\n private _backwardAttr: BaseGraphicAttributes<ISymbolGraphicAttribute>;\n\n constructor(attributes: ControllerAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Controller.defaultAttributes, attributes));\n this.updateAttributes();\n this._initPlay();\n this._initBackward();\n this._initForward();\n this._initEvents();\n }\n\n updateAttributes = () => {\n this._startAttr = {\n style: {\n symbolType: iconPlay,\n ...Controller.defaultControllerAttr,\n visible: this.attribute.start.visible,\n ...this.attribute.start.style\n }\n };\n this._pauseAttr = {\n style: {\n symbolType: iconPause,\n ...Controller.defaultControllerAttr,\n visible: this.attribute.pause.visible,\n ...this.attribute.pause.style\n }\n };\n this._forwardAttr = {\n style: {\n ...Controller.defaultControllerAttr,\n visible: this.attribute.forward.visible,\n ...this.attribute.forward.style\n }\n };\n this._backwardAttr = {\n style: {\n ...Controller.defaultControllerAttr,\n visible: this.attribute.backward.visible,\n ...this.attribute.backward.style\n }\n };\n this.updateLayout();\n };\n\n private updateLayout = () => {\n this._layout = this.attribute.layout;\n // 若水平布局\n if (this._layout === 'horizontal') {\n this._backwardAttr.style.symbolType = this._backwardAttr.style?.symbolType ?? iconLeft;\n this._forwardAttr.style.symbolType = this._forwardAttr.style?.symbolType ?? iconRight;\n }\n // 若垂直布局\n else if (this._layout === 'vertical') {\n this._backwardAttr.style.symbolType = this._backwardAttr.style?.symbolType ?? iconUp;\n this._forwardAttr.style.symbolType = this._forwardAttr.style?.symbolType ?? iconDown;\n }\n };\n\n private _initPlay = () => {\n if (isNil(this._playController)) {\n this._playController = new PlayerIcon({\n ...this._startAttr.style\n });\n\n this.add(this._playController);\n }\n };\n\n private _initBackward = () => {\n if (isNil(this._backwardController)) {\n this._backwardController = new PlayerIcon({\n ...this._backwardAttr.style\n });\n\n this.add(this._backwardController);\n }\n };\n\n private _initForward = () => {\n if (isNil(this._forwardController)) {\n this._forwardController = new PlayerIcon({\n ...this._forwardAttr.style\n });\n\n this.add(this._forwardController);\n }\n };\n\n /**\n * 初始化事件\n * 1. 注册\n */\n private _initEvents = () => {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n this._playController.addEventListener('pointerdown', (e: FederatedPointerEvent) => {\n e.stopPropagation();\n\n if (this._isPaused === true) {\n this.play();\n } else {\n this.pause();\n }\n });\n\n this._backwardController.addEventListener('pointerdown', (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.backward();\n });\n\n this._forwardController.addEventListener('pointerdown', (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.forward();\n });\n };\n\n render(): void {\n this.updateAttributes();\n this.renderPlay();\n this.renderBackward();\n this.renderForward();\n }\n\n renderPlay = () => {\n if (this._isPaused) {\n this._playController.setAttributes({\n symbolType: this._playController.getComputedAttribute('symbolType'),\n ...this._startAttr.style\n });\n } else {\n this._playController.setAttributes({\n symbolType: this._playController.getComputedAttribute('symbolType'),\n ...this._pauseAttr.style\n });\n }\n };\n\n renderBackward = () => {\n this._backwardController.setAttributes(this._backwardAttr.style);\n };\n\n renderForward = () => {\n this._forwardController.setAttributes(this._forwardAttr.style);\n };\n\n play = () => {\n this._dispatchEvent('ControllerEventEnum.OnPlay');\n };\n\n pause = () => {\n this._dispatchEvent('ControllerEventEnum.OnPause');\n };\n\n forward = () => {\n this._dispatchEvent('ControllerEventEnum.OnForward');\n };\n\n backward = () => {\n this._dispatchEvent('ControllerEventEnum.OnBackward');\n };\n\n togglePlay = () => {\n this._playController.setAttributes(this._startAttr.style);\n this._isPaused = true;\n };\n\n togglePause = () => {\n this._playController.setAttributes(this._pauseAttr.style);\n this._isPaused = false;\n };\n}\n"]}
@@ -41,6 +41,5 @@ export declare class ScrollBar extends AbstractComponent<Required<ScrollBarAttri
41
41
  private _computeScrollValue;
42
42
  private _onSliderPointerMove;
43
43
  private _onSliderPointerUp;
44
- private _onChange;
45
44
  private _reset;
46
45
  }
@@ -50,7 +50,7 @@ class ScrollBar extends base_1.AbstractComponent {
50
50
  }), this.attribute.delayTime), this._onSliderPointerUp = e => {
51
51
  e.preventDefault();
52
52
  const {realTime: realTime = !0, range: preRange, limitRange: limitRange = [ 0, 1 ]} = this.attribute, preScrollRange = this.getScrollRange(), [currentPos, currentScrollValue] = this._computeScrollValue(e), range = [ preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue ];
53
- realTime || this._onChange({
53
+ realTime || this._dispatchEvent("scroll", {
54
54
  pre: preRange,
55
55
  value: (0, vutils_1.clampRange)(range, limitRange[0], limitRange[1])
56
56
  }), "browser" === vrender_core_1.vglobal.env ? (vrender_core_1.vglobal.removeEventListener("pointermove", this._onSliderPointerMove, {
@@ -69,7 +69,7 @@ class ScrollBar extends base_1.AbstractComponent {
69
69
  this._slider && ("horizontal" === direction ? this._slider.setAttribute("x", sliderPos[0], !0) : this._slider.setAttribute("y", sliderPos[0], !0),
70
70
  (null === (_a = this.stage) || void 0 === _a ? void 0 : _a.autoRender) || null === (_b = this.stage) || void 0 === _b || _b.renderNextFrame());
71
71
  }
72
- this.attribute.range = currScrollRange, realTime && this._onChange({
72
+ this.attribute.range = currScrollRange, realTime && this._dispatchEvent("scroll", {
73
73
  pre: preRange,
74
74
  value: currScrollRange
75
75
  });
@@ -151,12 +151,6 @@ class ScrollBar extends base_1.AbstractComponent {
151
151
  return "horizontal" === direction ? (0, vutils_1.clampRange)([ x1 + min * width, x1 + max * width ], x1, width - sliderSize) : (0,
152
152
  vutils_1.clampRange)([ y1 + min * height, y1 + max * height ], y1, height - sliderSize);
153
153
  }
154
- _onChange(detail) {
155
- var _a;
156
- const changeEvent = new vrender_core_1.CustomEvent("scroll", detail);
157
- changeEvent.manager = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventSystem.manager,
158
- this.dispatchEvent(changeEvent);
159
- }
160
154
  _reset() {
161
155
  this._sliderRenderBounds = null, this._sliderLimitRange = null;
162
156
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/scrollbar/scrollbar.ts"],"names":[],"mappings":";;;AAKA,yDAA8D;AAC9D,6CAAkG;AAClG,uCAAiD;AAIjD,yCAAoD;AAWpD,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,iBAAQ;IAClB,QAAQ,EAAE,iBAAQ;CACnB,CAAC;AAEF,IAAA,iCAAsB,GAAE,CAAC;AAEzB,MAAa,SAAU,SAAQ,wBAAgD;IAmC7E,YAAY,UAA+B,EAAE,OAA0B;QACrE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,SAAS,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAnChG,SAAI,GAAG,WAAW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AG;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 { CustomEvent, 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';\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 if (direction === 'horizontal') {\n this._slider.setAttribute('x', sliderPos[0], true);\n } else {\n this._slider.setAttribute('y', sliderPos[0], true);\n }\n\n if (!this.stage?.autoRender) {\n this.stage?.renderNextFrame();\n }\n }\n }\n (this.attribute as ScrollBarAttributes).range = currScrollRange;\n // 发射 change 事件\n if (realTime) {\n this._onChange({\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: width - (left + right),\n height: 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?.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 if (vglobal.env === 'browser') {\n vglobal.addEventListener('pointermove', this._onSliderPointerMove, { capture: true });\n vglobal.addEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.addEventListener('pointermove', this._onSliderPointerMove, { 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 = delayMap[this.attribute.delayType]((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 }, 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 if (!realTime) {\n this._onChange({\n pre: preRange,\n value: clampRange(range, limitRange[0], limitRange[1])\n });\n }\n if (vglobal.env === 'browser') {\n vglobal.removeEventListener('pointermove', this._onSliderPointerMove, { capture: true });\n vglobal.removeEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.removeEventListener('pointermove', this._onSliderPointerMove, { capture: true });\n this.stage.removeEventListener('pointerup', this._onSliderPointerUp);\n this.stage.removeEventListener('pointerupoutside', this._onSliderPointerUp);\n }\n };\n\n private _onChange(detail: any) {\n const changeEvent = new CustomEvent('scroll', detail);\n // FIXME: 需要在 vrender 的事件系统支持\n // @ts-ignore\n changeEvent.manager = this.stage?.eventSystem.manager;\n this.dispatchEvent(changeEvent);\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,yDAAiD;AACjD,6CAAkG;AAClG,uCAAiD;AAIjD,yCAAoD;AAWpD,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,iBAAQ;IAClB,QAAQ,EAAE,iBAAQ;CACnB,CAAC;AAEF,IAAA,iCAAsB,GAAE,CAAC;AAEzB,MAAa,SAAU,SAAQ,wBAAgD;IAmC7E,YAAY,UAA+B,EAAE,OAA0B;QACrE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,SAAS,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAnChG,SAAI,GAAG,WAAW,CAAC;QAuOX,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,IAAI,CAAC,WAAW,CAAC;YACpC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1C,IAAI,kBAAkB,CAAC;YACvB,IAAI,SAAS,KAAK,UAAU,EAAE;gBAC5B,MAAM,SAAS,GAAG,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;gBAC/C,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,SAA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;YAC/B,CAAC,CAAC,IAAA,mBAAU,EAAC,CAAC,EAAE,GAAG,GAAG,GAAG,KAAK,EAAE,EAAE,GAAG,GAAG,GAAG,KAAK,CAAC,EAAE,EAAE,EAAE,KAAK,GAAG,UAAU,CAAC;YAC1E,CAAC,CAAC,IAAA,mBAAU,EAAC,CAAC,EAAE,GAAG,GAAG,GAAG,MAAM,EAAE,EAAE,GAAG,GAAG,GAAG,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;IAClF,CAAC;IAgGO,MAAM;QACZ,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAChC,CAAC;;AAzUH,8BA0UC;AAvUQ,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';\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 if (direction === 'horizontal') {\n this._slider.setAttribute('x', sliderPos[0], true);\n } else {\n this._slider.setAttribute('y', sliderPos[0], true);\n }\n\n if (!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('scroll', {\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: width - (left + right),\n height: 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?.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 if (vglobal.env === 'browser') {\n vglobal.addEventListener('pointermove', this._onSliderPointerMove, { capture: true });\n vglobal.addEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.addEventListener('pointermove', this._onSliderPointerMove, { 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 = delayMap[this.attribute.delayType]((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 }, 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 if (!realTime) {\n this._dispatchEvent('scroll', {\n pre: preRange,\n value: clampRange(range, limitRange[0], limitRange[1])\n });\n }\n if (vglobal.env === 'browser') {\n vglobal.removeEventListener('pointermove', this._onSliderPointerMove, { capture: true });\n vglobal.removeEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.removeEventListener('pointermove', this._onSliderPointerMove, { 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"]}
@@ -350,13 +350,11 @@ class Slider extends base_1.AbstractComponent {
350
350
  this._currentValue.endPos = position);
351
351
  }
352
352
  _dispatchChangeEvent() {
353
- var _a;
354
- const isRange = !!this.attribute.range, currentValue = this._currentValue, changeEvent = new vrender_core_1.CustomEvent("change", {
353
+ const isRange = !!this.attribute.range, currentValue = this._currentValue;
354
+ this._dispatchEvent("change", {
355
355
  value: isRange ? [ Math.min(currentValue.endValue, currentValue.startValue), Math.max(currentValue.endValue, currentValue.startValue) ] : currentValue.startValue,
356
356
  position: isRange ? [ Math.min(currentValue.endPos, currentValue.startPos), Math.max(currentValue.endPos, currentValue.startPos) ] : currentValue.startPos
357
357
  });
358
- changeEvent.manager = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventSystem.manager,
359
- this.dispatchEvent(changeEvent);
360
358
  }
361
359
  _getHandlers() {
362
360
  let temp, startHandler = this._startHandler, endHandler = this._endHandler;