@visactor/vrender-components 1.0.37 → 1.1.0-alpha.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 (40) hide show
  1. package/cjs/index.d.ts +1 -1
  2. package/cjs/index.js +1 -1
  3. package/cjs/index.js.map +1 -1
  4. package/cjs/poptip/contribution.js +3 -10
  5. package/cjs/poptip/contribution.js.map +1 -1
  6. package/cjs/poptip/module.d.ts +0 -2
  7. package/cjs/poptip/module.js +7 -10
  8. package/cjs/poptip/module.js.map +1 -1
  9. package/cjs/poptip/poptip-plugin.js +5 -12
  10. package/cjs/poptip/poptip-plugin.js.map +1 -1
  11. package/cjs/poptip/register.js +1 -1
  12. package/cjs/poptip/register.js.map +1 -1
  13. package/cjs/scrollbar/module.d.ts +0 -2
  14. package/cjs/scrollbar/module.js +5 -6
  15. package/cjs/scrollbar/module.js.map +1 -1
  16. package/cjs/scrollbar/scrollbar-plugin.js +5 -12
  17. package/cjs/scrollbar/scrollbar-plugin.js.map +1 -1
  18. package/cjs/slider/slider.js.map +1 -1
  19. package/cjs/table-series-number/event-manager.js.map +1 -1
  20. package/dist/index.es.js +7966 -7760
  21. package/es/index.d.ts +1 -1
  22. package/es/index.js +1 -1
  23. package/es/index.js.map +1 -1
  24. package/es/poptip/contribution.js +2 -14
  25. package/es/poptip/contribution.js.map +1 -1
  26. package/es/poptip/module.d.ts +0 -2
  27. package/es/poptip/module.js +4 -8
  28. package/es/poptip/module.js.map +1 -1
  29. package/es/poptip/poptip-plugin.js +5 -19
  30. package/es/poptip/poptip-plugin.js.map +1 -1
  31. package/es/poptip/register.js +2 -0
  32. package/es/poptip/register.js.map +1 -1
  33. package/es/scrollbar/module.d.ts +0 -2
  34. package/es/scrollbar/module.js +3 -5
  35. package/es/scrollbar/module.js.map +1 -1
  36. package/es/scrollbar/scrollbar-plugin.js +5 -13
  37. package/es/scrollbar/scrollbar-plugin.js.map +1 -1
  38. package/es/slider/slider.js.map +1 -1
  39. package/es/table-series-number/event-manager.js.map +1 -1
  40. package/package.json +6 -6
package/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "1.0.37";
1
+ export declare const version = "1.1.0-alpha.0";
2
2
  export * from './core/base';
3
3
  export * from './core/type';
4
4
  export * from './scrollbar';
package/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = "1.0.37";
1
+ export const version = "1.1.0-alpha.0";
2
2
 
3
3
  export * from "./core/base";
4
4
 
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"1.0.37\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './weather';\nexport * from './util';\nexport * from './switch';\nexport * from './label-item';\nexport * from './table-series-number';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC;AAEvC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"1.1.0-alpha.0\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './weather';\nexport * from './util';\nexport * from './switch';\nexport * from './label-item';\nexport * from './table-series-number';\n"]}
@@ -1,11 +1,3 @@
1
- var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
2
- var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
3
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
4
- return c > 3 && r && Object.defineProperty(target, key, r), r;
5
- };
6
-
7
- import { injectable } from "@visactor/vrender-core";
8
-
9
1
  import { PopTip } from "./poptip";
10
2
 
11
3
  import { merge } from "@visactor/vutils";
@@ -16,7 +8,7 @@ function wrapPoptip(target, source) {
16
8
  return merge(target, theme.poptip, source), target;
17
9
  }
18
10
 
19
- let PopTipRenderContribution = class {
11
+ export class PopTipRenderContribution {
20
12
  render(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
21
13
  var _a, _b;
22
14
  if (1 === graphic._showPoptip) {
@@ -48,9 +40,5 @@ let PopTipRenderContribution = class {
48
40
  }), null === (_b = this.poptipComponent.parent) || void 0 === _b || _b.removeChild(this.poptipComponent),
49
41
  this.poptipComponent = null));
50
42
  }
51
- };
52
-
53
- PopTipRenderContribution = __decorate([ injectable() ], PopTipRenderContribution);
54
-
55
- export { PopTipRenderContribution };
43
+ }
56
44
  //# sourceMappingURL=contribution.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/poptip/contribution.ts"],"names":[],"mappings":";;;;;;AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,SAAS,UAAU,CAAC,MAA2B,EAAE,MAA2B;IAC1E,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC;AAChB,CAAC;AAGM,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAEnC,MAAM,CACJ,OAA6C,EAC7C,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,gBAA6C,EAC7C,WAAyB,EACzB,MAAiH,EACjH,QAAmH,EACnH,OAAa;;QAEb,IAAI,OAAO,CAAC,WAAW,KAAK,CAAC,EAAE;YAC7B,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAI,OAAO,CAAC,SAAiB,CAAC,MAAM,IAAI,EAAE,CAAC;YACvE,IAAI,OAAO,KAAK,KAAK,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,EAAE;gBACpE,OAAO;aACR;YACD,MAAM,SAAS,GAAG,EAAE,CAAC;YACrB,KA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AI,gBAAgB,EAAE;gBACpB,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;aAC5C;SACF;aAAM,IAAI,OAAO,CAAC,WAAW,KAAK,CAAC,EAAE;YACpC,OAAO,CAAC,WAAW,GAAG,CAAC,CAAC;YACxB,IAAI,IAAI,CAAC,eAAe,EAAE;gBACxB,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;oBACjC,UAAU,EAAE,KAAK;iBAClB,CAAC,CAAC;gBACH,MAAA,IAAI,CAAC,eAAe,CAAC,MAAM,0CAAE,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBAC/D,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;aAC7B;SACF;IACH,CAAC;CACF,CAAA;AAtEY,wBAAwB;IADpC,UAAU,EAAE;GACA,wBAAwB,CAsEpC;SAtEY,wBAAwB","file":"contribution.js","sourcesContent":["import type {\n IContext2d,\n IGraphic,\n IGraphicAttribute,\n IInteractiveSubRenderContribution,\n IThemeAttribute,\n IDrawContext\n} from '@visactor/vrender-core';\nimport { injectable } from '@visactor/vrender-core';\nimport { PopTip } from './poptip';\nimport { merge } from '@visactor/vutils';\nimport { theme } from './theme';\n\nfunction wrapPoptip(target: Record<string, any>, source: Record<string, any>) {\n merge(target, theme.poptip, source);\n return target;\n}\n\n@injectable()\nexport class PopTipRenderContribution implements IInteractiveSubRenderContribution {\n declare poptipComponent: PopTip;\n render(\n graphic: IGraphic<Partial<IGraphicAttribute>>,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ): void {\n if (graphic._showPoptip === 1) {\n const { visible, visibleCb } = (graphic.attribute as any).poptip || {};\n if (visible === false || (visibleCb && visibleCb(graphic) === false)) {\n return;\n }\n const attribute = {};\n merge(\n attribute,\n PopTip.defaultAttributes,\n (graphic.attribute as any).poptip ? (graphic.attribute as any).poptip : {}\n );\n if (!this.poptipComponent) {\n this.poptipComponent = new PopTip(attribute);\n } else {\n this.poptipComponent.initAttributes(attribute);\n }\n // 如果text图元没有配置title和content的话\n let poptip = (graphic.attribute as any).poptip || {};\n if (graphic.type === 'text' && poptip.title == null && poptip.content == null) {\n const out = {};\n wrapPoptip(out, poptip);\n poptip = out;\n poptip.content = poptip.content ?? (graphic.attribute as any).text;\n }\n const matrix = graphic.globalTransMatrix;\n this.poptipComponent.setAttributes({\n visibleAll: true,\n pickable: false,\n childrenPickable: false,\n // 默认使用bounds作为锚点\n poptipAnchor: 'bounds',\n ...poptip,\n x: matrix.e,\n y: matrix.f,\n positionBounds: graphic.globalAABBBounds\n });\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n interactiveLayer.add(this.poptipComponent);\n }\n } else if (graphic._showPoptip === 2) {\n graphic._showPoptip = 0;\n if (this.poptipComponent) {\n this.poptipComponent.setAttributes({\n visibleAll: false\n });\n this.poptipComponent.parent?.removeChild(this.poptipComponent);\n this.poptipComponent = null;\n }\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/poptip/contribution.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,SAAS,UAAU,CAAC,MAA2B,EAAE,MAA2B;IAC1E,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC;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M,CAAC,OAAO,mCAAK,OAAO,CAAC,SAAiB,CAAC,IAAI,CAAC;aACpE;YACD,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;YACzC,IAAI,CAAC,eAAe,CAAC,aAAa,+BAChC,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,KAAK,EACf,gBAAgB,EAAE,KAAK,EAEvB,YAAY,EAAE,QAAQ,IACnB,MAAM,KACT,CAAC,EAAE,MAAM,CAAC,CAAC,EACX,CAAC,EAAE,MAAM,CAAC,CAAC,EACX,cAAc,EAAE,OAAO,CAAC,gBAAgB,IACxC,CAAC;YAEH,WAAW,CAAC,KAAK,CAAC,uBAAuB,EAAE,CAAC;YAC5C,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;YAC5E,IAAI,gBAAgB,EAAE;gBACpB,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;aAC5C;SACF;aAAM,IAAI,OAAO,CAAC,WAAW,KAAK,CAAC,EAAE;YACpC,OAAO,CAAC,WAAW,GAAG,CAAC,CAAC;YACxB,IAAI,IAAI,CAAC,eAAe,EAAE;gBACxB,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;oBACjC,UAAU,EAAE,KAAK;iBAClB,CAAC,CAAC;gBACH,MAAA,IAAI,CAAC,eAAe,CAAC,MAAM,0CAAE,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBAC/D,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;aAC7B;SACF;IACH,CAAC;CACF","file":"contribution.js","sourcesContent":["import type {\n IContext2d,\n IGraphic,\n IGraphicAttribute,\n IInteractiveSubRenderContribution,\n IThemeAttribute,\n IDrawContext\n} from '@visactor/vrender-core';\nimport { PopTip } from './poptip';\nimport { merge } from '@visactor/vutils';\nimport { theme } from './theme';\n\nfunction wrapPoptip(target: Record<string, any>, source: Record<string, any>) {\n merge(target, theme.poptip, source);\n return target;\n}\n\nexport class PopTipRenderContribution implements IInteractiveSubRenderContribution {\n declare poptipComponent: PopTip;\n render(\n graphic: IGraphic<Partial<IGraphicAttribute>>,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ): void {\n if (graphic._showPoptip === 1) {\n const { visible, visibleCb } = (graphic.attribute as any).poptip || {};\n if (visible === false || (visibleCb && visibleCb(graphic) === false)) {\n return;\n }\n const attribute = {};\n merge(\n attribute,\n PopTip.defaultAttributes,\n (graphic.attribute as any).poptip ? (graphic.attribute as any).poptip : {}\n );\n if (!this.poptipComponent) {\n this.poptipComponent = new PopTip(attribute);\n } else {\n this.poptipComponent.initAttributes(attribute);\n }\n // 如果text图元没有配置title和content的话\n let poptip = (graphic.attribute as any).poptip || {};\n if (graphic.type === 'text' && poptip.title == null && poptip.content == null) {\n const out = {};\n wrapPoptip(out, poptip);\n poptip = out;\n poptip.content = poptip.content ?? (graphic.attribute as any).text;\n }\n const matrix = graphic.globalTransMatrix;\n this.poptipComponent.setAttributes({\n visibleAll: true,\n pickable: false,\n childrenPickable: false,\n // 默认使用bounds作为锚点\n poptipAnchor: 'bounds',\n ...poptip,\n x: matrix.e,\n y: matrix.f,\n positionBounds: graphic.globalAABBBounds\n });\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n interactiveLayer.add(this.poptipComponent);\n }\n } else if (graphic._showPoptip === 2) {\n graphic._showPoptip = 0;\n if (this.poptipComponent) {\n this.poptipComponent.setAttributes({\n visibleAll: false\n });\n this.poptipComponent.parent?.removeChild(this.poptipComponent);\n this.poptipComponent = null;\n }\n }\n }\n}\n"]}
@@ -1,3 +1 @@
1
- import { ContainerModule } from '@visactor/vrender-core';
2
- export declare const popTipModule: ContainerModule;
3
1
  export declare function loadPoptip(): void;
@@ -1,17 +1,13 @@
1
- import { InteractiveSubRenderContribution, AutoEnablePlugins, ContainerModule, container } from "@visactor/vrender-core";
1
+ import { InteractiveSubRenderContribution, AutoEnablePlugins, contributionRegistry } from "@visactor/vrender-core";
2
2
 
3
3
  import { PopTipRenderContribution } from "./contribution";
4
4
 
5
5
  import { PopTipPlugin, PopTipForClipedTextPlugin } from "./poptip-plugin";
6
6
 
7
- export const popTipModule = new ContainerModule(((bind, unbind, isBound, rebind) => {
8
- isBound(PopTipRenderContribution) || (bind(PopTipRenderContribution).toSelf().inSingletonScope(),
9
- bind(InteractiveSubRenderContribution).toService(PopTipRenderContribution)), isBound(PopTipPlugin) || (bind(PopTipPlugin).toSelf(),
10
- bind(AutoEnablePlugins).toService(PopTipPlugin)), isBound(PopTipForClipedTextPlugin) || (bind(PopTipForClipedTextPlugin).toSelf(),
11
- bind(AutoEnablePlugins).toService(PopTipForClipedTextPlugin));
12
- }));
7
+ let _registered = !1;
13
8
 
14
9
  export function loadPoptip() {
15
- container.load(popTipModule);
10
+ _registered || (_registered = !0, contributionRegistry.register(InteractiveSubRenderContribution, new PopTipRenderContribution),
11
+ contributionRegistry.register(AutoEnablePlugins, new PopTipPlugin), contributionRegistry.register(AutoEnablePlugins, new PopTipForClipedTextPlugin));
16
12
  }
17
13
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/poptip/module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,iBAAiB,EACjB,eAAe,EACf,SAAS,EACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,eAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IAChF,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,EAAE;QACtC,IAAI,CAAC,wBAAwB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;QAC3D,IAAI,CAAC,gCAAgC,CAAC,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;KAC5E;IACD,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;QAC1B,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;KACjD;IACD,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,EAAE;QACvC,IAAI,CAAC,yBAAyB,CAAC,CAAC,MAAM,EAAE,CAAC;QACzC,IAAI,CAAC,iBAAiB,CAAC,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;KAC9D;AACH,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,UAAU;IACxB,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AAC/B,CAAC","file":"module.js","sourcesContent":["import {\n InteractiveSubRenderContribution,\n AutoEnablePlugins,\n ContainerModule,\n container\n} from '@visactor/vrender-core';\nimport { PopTipRenderContribution } from './contribution';\nimport { PopTipPlugin, PopTipForClipedTextPlugin } from './poptip-plugin';\n\nexport const popTipModule = new ContainerModule((bind, unbind, isBound, rebind) => {\n if (!isBound(PopTipRenderContribution)) {\n bind(PopTipRenderContribution).toSelf().inSingletonScope();\n bind(InteractiveSubRenderContribution).toService(PopTipRenderContribution);\n }\n if (!isBound(PopTipPlugin)) {\n bind(PopTipPlugin).toSelf();\n bind(AutoEnablePlugins).toService(PopTipPlugin);\n }\n if (!isBound(PopTipForClipedTextPlugin)) {\n bind(PopTipForClipedTextPlugin).toSelf();\n bind(AutoEnablePlugins).toService(PopTipForClipedTextPlugin);\n }\n});\n\nexport function loadPoptip() {\n container.load(popTipModule);\n}\n"]}
1
+ {"version":3,"sources":["../src/poptip/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnH,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,MAAM,UAAU,UAAU;IACxB,IAAI,WAAW,EAAE;QACf,OAAO;KACR;IACD,WAAW,GAAG,IAAI,CAAC;IACnB,oBAAoB,CAAC,QAAQ,CAAC,gCAAgC,EAAE,IAAI,wBAAwB,EAAE,CAAC,CAAC;IAChG,oBAAoB,CAAC,QAAQ,CAAC,iBAAiB,EAAE,IAAI,YAAY,EAAE,CAAC,CAAC;IACrE,oBAAoB,CAAC,QAAQ,CAAC,iBAAiB,EAAE,IAAI,yBAAyB,EAAE,CAAC,CAAC;AACpF,CAAC","file":"module.js","sourcesContent":["import { InteractiveSubRenderContribution, AutoEnablePlugins, contributionRegistry } from '@visactor/vrender-core';\nimport { PopTipRenderContribution } from './contribution';\nimport { PopTipPlugin, PopTipForClipedTextPlugin } from './poptip-plugin';\n\nlet _registered = false;\nexport function loadPoptip() {\n if (_registered) {\n return;\n }\n _registered = true;\n contributionRegistry.register(InteractiveSubRenderContribution, new PopTipRenderContribution());\n contributionRegistry.register(AutoEnablePlugins, new PopTipPlugin());\n contributionRegistry.register(AutoEnablePlugins, new PopTipForClipedTextPlugin());\n}\n"]}
@@ -1,10 +1,4 @@
1
- var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
2
- var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
3
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
4
- return c > 3 && r && Object.defineProperty(target, key, r), r;
5
- };
6
-
7
- import { Generator, injectable } from "@visactor/vrender-core";
1
+ import { Generator } from "@visactor/vrender-core";
8
2
 
9
3
  export class PopTipPluginBase {
10
4
  constructor() {
@@ -38,17 +32,13 @@ export class PopTipPluginBase {
38
32
  }
39
33
  }
40
34
 
41
- let PopTipPlugin = class extends PopTipPluginBase {
35
+ export class PopTipPlugin extends PopTipPluginBase {
42
36
  constructor() {
43
37
  super(...arguments), this.name = "poptip", this.key = this.name + this._uid;
44
38
  }
45
- };
46
-
47
- PopTipPlugin = __decorate([ injectable() ], PopTipPlugin);
48
-
49
- export { PopTipPlugin };
39
+ }
50
40
 
51
- let PopTipForClipedTextPlugin = class extends PopTipPluginBase {
41
+ export class PopTipForClipedTextPlugin extends PopTipPluginBase {
52
42
  constructor() {
53
43
  super(...arguments), this.name = "poptipForText", this.key = this.name + this._uid,
54
44
  this.pointerlave = e => {
@@ -71,9 +61,5 @@ let PopTipForClipedTextPlugin = class extends PopTipPluginBase {
71
61
  const {stage: stage} = this.pluginService;
72
62
  super.deactivate(context), stage.removeEventListener("pointerleave", this.pointerlave);
73
63
  }
74
- };
75
-
76
- PopTipForClipedTextPlugin = __decorate([ injectable() ], PopTipForClipedTextPlugin);
77
-
78
- export { PopTipForClipedTextPlugin };
64
+ }
79
65
  //# sourceMappingURL=poptip-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/poptip/poptip-plugin.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAI/D,MAAM,OAAgB,gBAAgB;IAAtC;QACE,gBAAW,GA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C,QAAQ,CAAC,OAAuB;QAC9B,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAExB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC;QAErC,KAAK,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3D,CAAC;IAQD,QAAQ,CAAC,OAAiB;QACxB,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,MAAM;YACvB,CAAC,OAAO,CAAC,MAAM;YACf,OAAO,CAAC,WAAW;YACnB,CAAC,OAAO,CAAC,SAAS;YACjB,OAAe,CAAC,SAAS,CAAC,uBAAuB,CACnD,CAAC;IACJ,CAAC;IACD,QAAQ,CAAC,OAAiB;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,UAAU,CAAC,OAAuB;QAChC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC;QACrC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC1B,KAAK,CAAC,mBAAmB,CAAC,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9D,CAAC;CACF,CAAA;AApCY,yBAAyB;IADrC,UAAU,EAAE;GACA,yBAAyB,CAoCrC;SApCY,yBAAyB","file":"poptip-plugin.js","sourcesContent":["import type { FederatedPointerEvent, IGraphic, IPlugin, IPluginService } from '@visactor/vrender-core';\nimport { Generator, injectable } from '@visactor/vrender-core';\n\n// _showPoptip: 0-没有,1-添加,2-删除\n\nexport abstract class PopTipPluginBase {\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n activeGraphic: IGraphic;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n const { stage } = this.pluginService;\n\n stage.addEventListener('pointerover', this.poptip);\n }\n\n needHide(graphic: IGraphic) {\n return graphic.isContainer || !graphic.attribute;\n }\n\n needShow(graphic: IGraphic) {\n return !!(graphic.attribute as any).poptip;\n }\n\n poptip = (e: FederatedPointerEvent) => {\n const graphic = e.target as any;\n if (this.needHide(graphic)) {\n this.unpoptip(e);\n return;\n }\n // 触发graphic重绘\n if (graphic === this.activeGraphic) {\n return;\n }\n if (this.needShow(graphic)) {\n graphic.setAttributes({});\n graphic._showPoptip = 1;\n }\n\n if (this.activeGraphic) {\n this.activeGraphic.setAttributes({});\n this.activeGraphic._showPoptip = 2;\n }\n // console.log(graphic)\n this.setActiveGraphic(graphic, true);\n };\n\n unpoptip = (e: FederatedPointerEvent) => {\n if (!this.activeGraphic) {\n return;\n }\n this.activeGraphic.setAttributes({});\n this.activeGraphic._showPoptip = 2;\n this.setActiveGraphic(null, true);\n };\n\n setActiveGraphic(graphic: any | null, rerender?: boolean) {\n this.activeGraphic = graphic;\n // 触发重绘\n this.pluginService.stage.renderNextFrame();\n }\n\n deactivate(context: IPluginService): void {\n const { stage } = this.pluginService;\n stage.removeEventListener('pointerover', this.poptip);\n }\n}\n\n@injectable()\nexport class PopTipPlugin extends PopTipPluginBase implements IPlugin {\n name: 'poptip' = 'poptip';\n key: string = this.name + this._uid;\n}\n\n@injectable()\nexport class PopTipForClipedTextPlugin extends PopTipPluginBase implements IPlugin {\n name: 'poptipForText' = 'poptipForText';\n key: string = this.name + this._uid;\n\n activate(context: IPluginService): void {\n super.activate(context);\n\n const { stage } = this.pluginService;\n\n stage.addEventListener('pointerleave', this.pointerlave);\n }\n pointerlave = (e: any) => {\n const { stage } = this.pluginService;\n if (e.target === stage) {\n this.unpoptip(e);\n }\n };\n\n needHide(graphic: IGraphic) {\n return (\n graphic.type !== 'text' ||\n !graphic.cliped ||\n graphic.isContainer ||\n !graphic.attribute ||\n (graphic as any).attribute.disableAutoClipedPoptip\n );\n }\n needShow(graphic: IGraphic): boolean {\n return true;\n }\n\n deactivate(context: IPluginService): void {\n const { stage } = this.pluginService;\n super.deactivate(context);\n stage.removeEventListener('pointerleave', this.pointerlave);\n }\n}\n"]}
1
+ {"version":3,"sources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aAClB;QACH,CAAC,CAAC;IAoBJ,CAAC;IAhCC,QAAQ,CAAC,OAAuB;QAC9B,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAExB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC;QAErC,KAAK,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3D,CAAC;IAQD,QAAQ,CAAC,OAAiB;QACxB,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,MAAM;YACvB,CAAC,OAAO,CAAC,MAAM;YACf,OAAO,CAAC,WAAW;YACnB,CAAC,OAAO,CAAC,SAAS;YACjB,OAAe,CAAC,SAAS,CAAC,uBAAuB,CACnD,CAAC;IACJ,CAAC;IACD,QAAQ,CAAC,OAAiB;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,UAAU,CAAC,OAAuB;QAChC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC;QACrC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC1B,KAAK,CAAC,mBAAmB,CAAC,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9D,CAAC;CACF","file":"poptip-plugin.js","sourcesContent":["import type { FederatedPointerEvent, IGraphic, IPlugin, IPluginService } from '@visactor/vrender-core';\nimport { Generator } from '@visactor/vrender-core';\n\n// _showPoptip: 0-没有,1-添加,2-删除\n\nexport abstract class PopTipPluginBase {\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n activeGraphic: IGraphic;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n const { stage } = this.pluginService;\n\n stage.addEventListener('pointerover', this.poptip);\n }\n\n needHide(graphic: IGraphic) {\n return graphic.isContainer || !graphic.attribute;\n }\n\n needShow(graphic: IGraphic) {\n return !!(graphic.attribute as any).poptip;\n }\n\n poptip = (e: FederatedPointerEvent) => {\n const graphic = e.target as any;\n if (this.needHide(graphic)) {\n this.unpoptip(e);\n return;\n }\n // 触发graphic重绘\n if (graphic === this.activeGraphic) {\n return;\n }\n if (this.needShow(graphic)) {\n graphic.setAttributes({});\n (graphic as any)._showPoptip = 1;\n }\n\n if (this.activeGraphic) {\n this.activeGraphic.setAttributes({});\n (this.activeGraphic as any)._showPoptip = 2;\n }\n // console.log(graphic)\n this.setActiveGraphic(graphic, true);\n };\n\n unpoptip = (e: FederatedPointerEvent) => {\n if (!this.activeGraphic) {\n return;\n }\n this.activeGraphic.setAttributes({});\n (this.activeGraphic as any)._showPoptip = 2;\n this.setActiveGraphic(null, true);\n };\n\n setActiveGraphic(graphic: any | null, rerender?: boolean) {\n this.activeGraphic = graphic;\n // 触发重绘\n this.pluginService.stage.renderNextFrame();\n }\n\n deactivate(context: IPluginService): void {\n const { stage } = this.pluginService;\n stage.removeEventListener('pointerover', this.poptip);\n }\n}\n\nexport class PopTipPlugin extends PopTipPluginBase implements IPlugin {\n name: 'poptip' = 'poptip';\n key: string = this.name + this._uid;\n}\n\nexport class PopTipForClipedTextPlugin extends PopTipPluginBase implements IPlugin {\n name: 'poptipForText' = 'poptipForText';\n key: string = this.name + this._uid;\n\n activate(context: IPluginService): void {\n super.activate(context);\n\n const { stage } = this.pluginService;\n\n stage.addEventListener('pointerleave', this.pointerlave);\n }\n pointerlave = (e: any) => {\n const { stage } = this.pluginService;\n if (e.target === stage) {\n this.unpoptip(e);\n }\n };\n\n needHide(graphic: IGraphic) {\n return (\n graphic.type !== 'text' ||\n !graphic.cliped ||\n graphic.isContainer ||\n !graphic.attribute ||\n (graphic as any).attribute.disableAutoClipedPoptip\n );\n }\n needShow(graphic: IGraphic): boolean {\n return true;\n }\n\n deactivate(context: IPluginService): void {\n const { stage } = this.pluginService;\n super.deactivate(context);\n stage.removeEventListener('pointerleave', this.pointerlave);\n }\n}\n"]}
@@ -4,6 +4,8 @@ import { DEFAULT_THEME, theme } from "./theme";
4
4
 
5
5
  import { registerGroup, registerRect, registerSymbol, registerText } from "@visactor/vrender-kits";
6
6
 
7
+ const _registered = !1;
8
+
7
9
  export function loadPoptipComponent() {
8
10
  registerGroup(), registerText(), registerSymbol(), registerRect();
9
11
  }
@@ -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,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"]}
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,WAAW,GAAG,KAAK,CAAC;AAC1B,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 { InteractiveSubRenderContribution, AutoEnablePlugins } 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\nconst _registered = false;\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"]}
@@ -1,3 +1 @@
1
- import { ContainerModule } from '@visactor/vrender-core';
2
- export declare const scrollbarModule: ContainerModule;
3
1
  export declare function loadScrollbar(): void;
@@ -1,12 +1,10 @@
1
- import { AutoEnablePlugins, ContainerModule, container } from "@visactor/vrender-core";
1
+ import { AutoEnablePlugins, contributionRegistry } from "@visactor/vrender-core";
2
2
 
3
3
  import { ScrollBarPlugin } from "./scrollbar-plugin";
4
4
 
5
- export const scrollbarModule = new ContainerModule(((bind, unbind, isBound, rebind) => {
6
- isBound(ScrollBarPlugin) || (bind(ScrollBarPlugin).toSelf(), bind(AutoEnablePlugins).toService(ScrollBarPlugin));
7
- }));
5
+ let _registered = !1;
8
6
 
9
7
  export function loadScrollbar() {
10
- container.load(scrollbarModule);
8
+ _registered || (_registered = !0, contributionRegistry.register(AutoEnablePlugins, new ScrollBarPlugin));
11
9
  }
12
10
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/scrollbar/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IACnF,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;QAC7B,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,EAAE,CAAC;QAC/B,IAAI,CAAC,iBAAiB,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;KACpD;AACH,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,aAAa;IAC3B,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAClC,CAAC","file":"module.js","sourcesContent":["import { AutoEnablePlugins, ContainerModule, container } from '@visactor/vrender-core';\nimport { ScrollBarPlugin } from './scrollbar-plugin';\n\nexport const scrollbarModule = new ContainerModule((bind, unbind, isBound, rebind) => {\n if (!isBound(ScrollBarPlugin)) {\n bind(ScrollBarPlugin).toSelf();\n bind(AutoEnablePlugins).toService(ScrollBarPlugin);\n }\n});\n\nexport function loadScrollbar() {\n container.load(scrollbarModule);\n}\n"]}
1
+ {"version":3,"sources":["../src/scrollbar/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,MAAM,UAAU,aAAa;IAC3B,IAAI,WAAW,EAAE;QACf,OAAO;KACR;IACD,WAAW,GAAG,IAAI,CAAC;IACnB,oBAAoB,CAAC,QAAQ,CAAC,iBAAiB,EAAE,IAAI,eAAe,EAAE,CAAC,CAAC;AAC1E,CAAC","file":"module.js","sourcesContent":["import { AutoEnablePlugins, contributionRegistry } from '@visactor/vrender-core';\nimport { ScrollBarPlugin } from './scrollbar-plugin';\n\nlet _registered = false;\nexport function loadScrollbar() {\n if (_registered) {\n return;\n }\n _registered = true;\n contributionRegistry.register(AutoEnablePlugins, new ScrollBarPlugin());\n}\n"]}
@@ -1,10 +1,4 @@
1
- var ScrollBarPlugin_1, __decorate = this && this.__decorate || function(decorators, target, key, desc) {
2
- var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
3
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
4
- return c > 3 && r && Object.defineProperty(target, key, r), r;
5
- };
6
-
7
- import { Generator, injectable } from "@visactor/vrender-core";
1
+ import { Generator } from "@visactor/vrender-core";
8
2
 
9
3
  import { ScrollBar } from "./scrollbar";
10
4
 
@@ -12,7 +6,7 @@ import { AABBBounds, abs, Bounds } from "@visactor/vutils";
12
6
 
13
7
  import { SCROLLBAR_EVENT } from "../constant";
14
8
 
15
- let ScrollBarPlugin = ScrollBarPlugin_1 = class {
9
+ export class ScrollBarPlugin {
16
10
  constructor() {
17
11
  this.name = "scrollbar", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(),
18
12
  this.key = this.name + this._uid, this.scroll = e => {
@@ -64,7 +58,7 @@ let ScrollBarPlugin = ScrollBarPlugin_1 = class {
64
58
  this.pluginService = context;
65
59
  const {stage: stage} = this.pluginService;
66
60
  this.childrenBounds = new AABBBounds, stage.addEventListener("wheel", this.scroll),
67
- this.params = ScrollBarPlugin_1.defaultParams;
61
+ this.params = ScrollBarPlugin.defaultParams;
68
62
  }
69
63
  initEventOfScrollbar(scrollContainer, scrollbar, isHorozntal) {
70
64
  scrollContainer.addEventListener("pointerover", (() => {
@@ -165,11 +159,9 @@ let ScrollBarPlugin = ScrollBarPlugin_1 = class {
165
159
  const {stage: stage} = this.pluginService;
166
160
  stage.removeEventListener("wheel", this.scroll);
167
161
  }
168
- };
162
+ }
169
163
 
170
164
  ScrollBarPlugin.defaultParams = {
171
165
  timeout: 500
172
- }, ScrollBarPlugin = ScrollBarPlugin_1 = __decorate([ injectable() ], ScrollBarPlugin);
173
-
174
- export { ScrollBarPlugin };
166
+ };
175
167
  //# sourceMappingURL=scrollbar-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/scrollbar/scrollbar-plugin.ts"],"names":[],"mappings":";;;;;;;AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAYvC,IAAM,eAAe,uBAArB,MAAM,eAAe;IAArB;QACL,SAAI,GAAgB,WAAW,CAAC;QAChC,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAmBpC,WAAM,GAAG,CAAC,CAAuD,EAAE,EAAE;;YAEnE,MAAM,OAAO,GAAG,CAAC,CAAC,MAAa,CAAC;YAGhC,MAAM,IAAI,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;YAE9C,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;gBAClC,OAAO;aACR;YAED,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,eAAe,EAAE;gBACjC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAA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AC;IACd,CAAC;IAED,UAAU,CAAC,OAAuB;QAChC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC;QACrC,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAa,CAAC,CAAC;IACzD,CAAC;;AA5TM,6BAAa,GAAY;IAC9B,OAAO,EAAE,GAAG;CACb,CAAC;AAZS,eAAe;IAD3B,UAAU,EAAE;GACA,eAAe,CAuU3B;SAvUY,eAAe","file":"scrollbar-plugin.js","sourcesContent":["import type { IGraphic, IGroup, IPlugin, IPluginService } from '@visactor/vrender-core';\nimport { Generator, injectable } from '@visactor/vrender-core';\nimport { ScrollBar } from './scrollbar';\nimport type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds, abs, Bounds } from '@visactor/vutils';\nimport { SCROLLBAR_EVENT } from '../constant';\nimport type { ScrollBarAttributes } from './type';\n\n// _showPoptip: 0-没有,1-添加,2-删除\n\ntype IParams = {\n timeout?: number; // 消失的timeout\n bufferV?: number; // 判定是否出现滚动条的buffer\n bufferH?: number; // 判定是否出现滚动条的buffer\n};\n\n@injectable()\nexport class ScrollBarPlugin implements IPlugin {\n name: 'scrollbar' = 'scrollbar';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n scrollContainer?: { g: IGroup; showH: boolean; showV: boolean };\n scrollContainerBounds: IAABBBounds;\n childrenBounds: IAABBBounds;\n\n static defaultParams: IParams = {\n timeout: 500\n };\n\n params: IParams;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n const { stage } = this.pluginService;\n\n this.childrenBounds = new AABBBounds();\n stage.addEventListener('wheel', this.scroll as any);\n this.params = ScrollBarPlugin.defaultParams;\n }\n scroll = (e: { deltaX: number; deltaY: number; target: IGraphic }) => {\n // 计算子元素的bounds\n const graphic = e.target as any;\n // childrenBounds.set(0, 0, scrollContainer.AABBBounds.width(), scrollContainer.AABBBounds.height());\n\n const data = this.getScrollContainer(graphic);\n\n if (!data && !this.scrollContainer) {\n return;\n }\n\n if (!data && this.scrollContainer) {\n if (!this.scrollContainer.g.stage || this.scrollContainer.g.stage !== graphic.stage) {\n return;\n }\n const newScrollContainer = this.formatScrollContainer(this.scrollContainer.g);\n\n if (!newScrollContainer) {\n this.clearScrollbar(this.scrollContainer.g, 'all');\n // 删除老的scrollbar\n return;\n }\n if (this.scrollContainer.showH && !newScrollContainer.showH) {\n this.clearScrollbar(this.scrollContainer.g, 'horizontal');\n }\n\n if (this.scrollContainer.showV && !newScrollContainer.showV) {\n this.clearScrollbar(this.scrollContainer.g, 'vertical');\n }\n\n this.scrollContainer = newScrollContainer;\n } else if (data && this.scrollContainer && data.g !== this.scrollContainer.g) {\n this.clearScrollbar(this.scrollContainer.g, 'all');\n }\n\n this.scrollContainer = data ?? this.scrollContainer;\n if (!data) {\n return;\n }\n const scrollContainer = data.g;\n if (!scrollContainer) {\n return;\n }\n const { width, height, scrollX = 0, scrollY = 0 } = scrollContainer.attribute;\n let newScrollX = scrollX;\n let newScrollY = scrollY;\n let { showH, showV } = data;\n this.scrollContainerBounds = new Bounds().set(\n 0,\n 0,\n scrollContainer.attribute.width,\n scrollContainer.attribute.height\n );\n if (showH && showH) {\n if (abs(e.deltaX) > abs(e.deltaY)) {\n showH = showH && true;\n showV = showV && false;\n } else {\n showH = showH && false;\n showV = showV && true;\n }\n }\n\n const scrollWidth = this.childrenBounds.width();\n const scrollHeight = this.childrenBounds.height();\n\n if (showH) {\n newScrollX = scrollX - (e.deltaX ?? 0);\n if (newScrollX > 0) {\n newScrollX = 0;\n } else if (newScrollX < width - scrollWidth) {\n newScrollX = width - scrollWidth;\n }\n }\n\n if (showV) {\n newScrollY = scrollY - (e.deltaY ?? 0);\n if (newScrollY > 0) {\n newScrollY = 0;\n } else if (newScrollY < height - scrollHeight) {\n newScrollY = height - scrollHeight;\n }\n }\n\n scrollContainer.setAttributes({\n scrollX: newScrollX,\n scrollY: newScrollY\n });\n this.addOrUpdateScroll(showH, showV, scrollContainer.parent, scrollContainer);\n };\n\n handleScrollBarChange = (params: any) => {\n if (\n !this.scrollContainer ||\n !this.scrollContainerBounds ||\n !this.childrenBounds ||\n !params ||\n !params.target ||\n !params.detail ||\n !params.detail.value\n ) {\n return;\n }\n const scrollbar = params.target;\n const newRange = params.detail.value;\n\n if (scrollbar.attribute.direction === 'horizontal') {\n const scrollWidth = this.childrenBounds.width();\n\n this.scrollContainer.g.setAttributes({ scrollX: -newRange[0] * scrollWidth });\n } else {\n const scrollHeight = this.childrenBounds.height();\n\n this.scrollContainer.g.setAttributes({ scrollY: -newRange[0] * scrollHeight });\n }\n };\n\n initEventOfScrollbar(scrollContainer: IGroup, scrollbar: IGroup, isHorozntal?: boolean) {\n scrollContainer.addEventListener('pointerover', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n scrollContainer.addEventListener('pointermove', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n scrollContainer.addEventListener('pointerout', () => {\n scrollbar.setAttribute('visibleAll', false);\n });\n scrollbar.addEventListener('pointerover', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n scrollbar.addEventListener('pointerout', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n\n scrollbar.addEventListener('scrollUp', this.handleScrollBarChange);\n scrollbar.addEventListener(SCROLLBAR_EVENT, this.handleScrollBarChange);\n }\n\n addOrUpdateScroll(showH: boolean, showV: boolean, container: IGroup, scrollContainer: IGroup) {\n if (showH) {\n const { scrollBar: hScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, true);\n\n if (!isUpdate) {\n this.initEventOfScrollbar(scrollContainer, hScrollbar, true);\n }\n } else {\n this.clearScrollbar(scrollContainer, 'horizontal');\n }\n if (showV) {\n const { scrollBar: vScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, false);\n\n if (!isUpdate) {\n this.initEventOfScrollbar(scrollContainer, vScrollbar, false);\n }\n } else {\n this.clearScrollbar(scrollContainer, 'vertical');\n }\n }\n\n getDirection(isHorozntal?: boolean) {\n return isHorozntal ? 'horizontal' : 'vertical';\n }\n\n addOrUpdateHScroll(scrollContainer: IGroup, container: IGroup, isHorozntal?: boolean) {\n const direction = this.getDirection(isHorozntal);\n const name = `${scrollContainer.name ?? scrollContainer._uid}_${this.getDirection(isHorozntal)}_${this.name}`;\n const scrollbars = container.children.filter((g: ScrollBar) => g.name === name);\n let isUpdate = true;\n let scrollBar = scrollbars[0] as ScrollBar;\n\n const { y = 0, dy = 0, x = 0, dx = 0, height, width, zIndex = 0 } = this.scrollContainer.g.attribute;\n const attrs: Partial<ScrollBarAttributes> = {\n x: 0,\n y: 0,\n direction,\n zIndex: zIndex + 1,\n visibleAll: true,\n padding: [2, 0],\n railStyle: {\n fill: 'rgba(0, 0, 0, .1)'\n },\n range: [0, 0.05]\n };\n\n if (isHorozntal) {\n attrs.width = this.scrollContainerBounds.width();\n attrs.height = 12;\n } else {\n attrs.height = this.scrollContainerBounds.height();\n attrs.width = 12;\n }\n\n if (!scrollBar) {\n isUpdate = false;\n\n scrollBar = new ScrollBar(attrs as ScrollBarAttributes);\n scrollBar.name = name;\n container.add(scrollBar);\n (scrollBar as any).isScrollBar = true;\n } else if (scrollbars.length > 1) {\n scrollbars.forEach((child: IGraphic, index: number) => {\n if (index) {\n child.parent?.removeChild(child);\n }\n });\n }\n const childrenBounds = this.childrenBounds;\n\n const { scrollX, scrollY } = scrollContainer.attribute;\n if (isHorozntal) {\n const ratio = Math.min(this.scrollContainerBounds.width() / childrenBounds.width(), 1);\n const start = Math.max(Math.min(scrollX / this.childrenBounds.width(), 0), ratio - 1);\n attrs.x = x + dx;\n attrs.y = y + dy + height - (attrs.height ?? 0);\n attrs.range = [-start, -start + ratio];\n } else {\n const ratio = Math.min(this.scrollContainerBounds.height() / childrenBounds.height(), 1);\n const start = Math.max(Math.min(scrollY / this.childrenBounds.height(), 0), ratio - 1);\n attrs.x = x + dx + width - this.scrollContainerBounds.width();\n attrs.y = y + dy;\n attrs.range = [-start, -start + ratio];\n }\n\n scrollBar.setAttributes(attrs);\n return {\n scrollBar,\n isUpdate\n };\n }\n\n clearScrollbar(scrollContainer: IGroup, type: 'horizontal' | 'vertical' | 'all') {\n if (!scrollContainer.parent) {\n return;\n }\n const scrollbarBars = scrollContainer.parent.children.filter((child: IGroup) => {\n return (child as any).isScrollBar && (type === 'all' || (child.attribute as any).direction === type);\n });\n\n scrollbarBars.forEach((child: IGraphic) => {\n child.parent.removeChild(child);\n });\n }\n\n formatScrollContainer(g: IGraphic) {\n if (!g || g.type !== 'group' || !g.attribute) {\n return null;\n }\n\n const { overflow, width, height } = (g as IGroup).attribute;\n\n if (!overflow || overflow === 'hidden') {\n return null;\n }\n\n let showH = false;\n let showV = false;\n\n if (overflow === 'scroll') {\n showH = true;\n showV = true;\n } else {\n showH = overflow === 'scroll-x';\n showV = !showH;\n }\n\n const childrenBounds = this.childrenBounds;\n\n childrenBounds.clear();\n g.forEachChildren((g: IGraphic) => {\n childrenBounds.union(g.AABBBounds);\n });\n\n if (!g.AABBBounds.empty()) {\n if (showH) {\n showH = width < childrenBounds.width();\n }\n\n if (showV) {\n showV = height < childrenBounds.height();\n }\n }\n\n return showH || showV ? { g: g as IGroup, showH, showV } : null;\n }\n\n // 获取响应滚动的元素\n getScrollContainer(graphic: IGraphic): { g: IGroup; showH: boolean; showV: boolean } | null {\n let g = graphic;\n while (g) {\n const res = this.formatScrollContainer(g);\n\n if (res) {\n return res;\n }\n g = g.parent;\n }\n return null;\n }\n\n deactivate(context: IPluginService): void {\n const { stage } = this.pluginService;\n stage.removeEventListener('wheel', this.scroll as any);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/scrollbar/scrollbar-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,GA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AI,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE;YACzB,IAAI,KAAK,EAAE;gBACT,KAAK,GAAG,KAAK,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC;aACxC;YAED,IAAI,KAAK,EAAE;gBACT,KAAK,GAAG,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;aAC1C;SACF;QAED,OAAO,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAW,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAClE,CAAC;IAGD,kBAAkB,CAAC,OAAiB;QAClC,IAAI,CAAC,GAAG,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE;YACR,MAAM,GAAG,GAAG,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;YAE1C,IAAI,GAAG,EAAE;gBACP,OAAO,GAAG,CAAC;aACZ;YACD,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,UAAU,CAAC,OAAuB;QAChC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC;QACrC,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAa,CAAC,CAAC;IACzD,CAAC;;AA5TM,6BAAa,GAAY;IAC9B,OAAO,EAAE,GAAG;CACb,CAAC","file":"scrollbar-plugin.js","sourcesContent":["import type { IGraphic, IGroup, IPlugin, IPluginService } from '@visactor/vrender-core';\nimport { Generator } from '@visactor/vrender-core';\nimport { ScrollBar } from './scrollbar';\nimport type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds, abs, Bounds } from '@visactor/vutils';\nimport { SCROLLBAR_EVENT } from '../constant';\nimport type { ScrollBarAttributes } from './type';\n\n// _showPoptip: 0-没有,1-添加,2-删除\n\ntype IParams = {\n timeout?: number; // 消失的timeout\n bufferV?: number; // 判定是否出现滚动条的buffer\n bufferH?: number; // 判定是否出现滚动条的buffer\n};\n\nexport class ScrollBarPlugin implements IPlugin {\n name: 'scrollbar' = 'scrollbar';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n scrollContainer?: { g: IGroup; showH: boolean; showV: boolean };\n scrollContainerBounds: IAABBBounds;\n childrenBounds: IAABBBounds;\n\n static defaultParams: IParams = {\n timeout: 500\n };\n\n params: IParams;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n const { stage } = this.pluginService;\n\n this.childrenBounds = new AABBBounds();\n stage.addEventListener('wheel', this.scroll as any);\n this.params = ScrollBarPlugin.defaultParams;\n }\n scroll = (e: { deltaX: number; deltaY: number; target: IGraphic }) => {\n // 计算子元素的bounds\n const graphic = e.target as any;\n // childrenBounds.set(0, 0, scrollContainer.AABBBounds.width(), scrollContainer.AABBBounds.height());\n\n const data = this.getScrollContainer(graphic);\n\n if (!data && !this.scrollContainer) {\n return;\n }\n\n if (!data && this.scrollContainer) {\n if (!this.scrollContainer.g.stage || this.scrollContainer.g.stage !== graphic.stage) {\n return;\n }\n const newScrollContainer = this.formatScrollContainer(this.scrollContainer.g);\n\n if (!newScrollContainer) {\n this.clearScrollbar(this.scrollContainer.g, 'all');\n // 删除老的scrollbar\n return;\n }\n if (this.scrollContainer.showH && !newScrollContainer.showH) {\n this.clearScrollbar(this.scrollContainer.g, 'horizontal');\n }\n\n if (this.scrollContainer.showV && !newScrollContainer.showV) {\n this.clearScrollbar(this.scrollContainer.g, 'vertical');\n }\n\n this.scrollContainer = newScrollContainer;\n } else if (data && this.scrollContainer && data.g !== this.scrollContainer.g) {\n this.clearScrollbar(this.scrollContainer.g, 'all');\n }\n\n this.scrollContainer = data ?? this.scrollContainer;\n if (!data) {\n return;\n }\n const scrollContainer = data.g;\n if (!scrollContainer) {\n return;\n }\n const { width, height, scrollX = 0, scrollY = 0 } = scrollContainer.attribute;\n let newScrollX = scrollX;\n let newScrollY = scrollY;\n let { showH, showV } = data;\n this.scrollContainerBounds = new Bounds().set(\n 0,\n 0,\n scrollContainer.attribute.width,\n scrollContainer.attribute.height\n );\n if (showH && showH) {\n if (abs(e.deltaX) > abs(e.deltaY)) {\n showH = showH && true;\n showV = showV && false;\n } else {\n showH = showH && false;\n showV = showV && true;\n }\n }\n\n const scrollWidth = this.childrenBounds.width();\n const scrollHeight = this.childrenBounds.height();\n\n if (showH) {\n newScrollX = scrollX - (e.deltaX ?? 0);\n if (newScrollX > 0) {\n newScrollX = 0;\n } else if (newScrollX < width - scrollWidth) {\n newScrollX = width - scrollWidth;\n }\n }\n\n if (showV) {\n newScrollY = scrollY - (e.deltaY ?? 0);\n if (newScrollY > 0) {\n newScrollY = 0;\n } else if (newScrollY < height - scrollHeight) {\n newScrollY = height - scrollHeight;\n }\n }\n\n scrollContainer.setAttributes({\n scrollX: newScrollX,\n scrollY: newScrollY\n });\n this.addOrUpdateScroll(showH, showV, scrollContainer.parent, scrollContainer);\n };\n\n handleScrollBarChange = (params: any) => {\n if (\n !this.scrollContainer ||\n !this.scrollContainerBounds ||\n !this.childrenBounds ||\n !params ||\n !params.target ||\n !params.detail ||\n !params.detail.value\n ) {\n return;\n }\n const scrollbar = params.target;\n const newRange = params.detail.value;\n\n if (scrollbar.attribute.direction === 'horizontal') {\n const scrollWidth = this.childrenBounds.width();\n\n this.scrollContainer.g.setAttributes({ scrollX: -newRange[0] * scrollWidth });\n } else {\n const scrollHeight = this.childrenBounds.height();\n\n this.scrollContainer.g.setAttributes({ scrollY: -newRange[0] * scrollHeight });\n }\n };\n\n initEventOfScrollbar(scrollContainer: IGroup, scrollbar: IGroup, isHorozntal?: boolean) {\n scrollContainer.addEventListener('pointerover', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n scrollContainer.addEventListener('pointermove', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n scrollContainer.addEventListener('pointerout', () => {\n scrollbar.setAttribute('visibleAll', false);\n });\n scrollbar.addEventListener('pointerover', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n scrollbar.addEventListener('pointerout', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n\n scrollbar.addEventListener('scrollUp', this.handleScrollBarChange);\n scrollbar.addEventListener(SCROLLBAR_EVENT, this.handleScrollBarChange);\n }\n\n addOrUpdateScroll(showH: boolean, showV: boolean, container: IGroup, scrollContainer: IGroup) {\n if (showH) {\n const { scrollBar: hScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, true);\n\n if (!isUpdate) {\n this.initEventOfScrollbar(scrollContainer, hScrollbar, true);\n }\n } else {\n this.clearScrollbar(scrollContainer, 'horizontal');\n }\n if (showV) {\n const { scrollBar: vScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, false);\n\n if (!isUpdate) {\n this.initEventOfScrollbar(scrollContainer, vScrollbar, false);\n }\n } else {\n this.clearScrollbar(scrollContainer, 'vertical');\n }\n }\n\n getDirection(isHorozntal?: boolean) {\n return isHorozntal ? 'horizontal' : 'vertical';\n }\n\n addOrUpdateHScroll(scrollContainer: IGroup, container: IGroup, isHorozntal?: boolean) {\n const direction = this.getDirection(isHorozntal);\n const name = `${scrollContainer.name ?? scrollContainer._uid}_${this.getDirection(isHorozntal)}_${this.name}`;\n const scrollbars = container.children.filter((g: ScrollBar) => g.name === name);\n let isUpdate = true;\n let scrollBar = scrollbars[0] as ScrollBar;\n\n const { y = 0, dy = 0, x = 0, dx = 0, height, width, zIndex = 0 } = this.scrollContainer.g.attribute;\n const attrs: Partial<ScrollBarAttributes> = {\n x: 0,\n y: 0,\n direction,\n zIndex: zIndex + 1,\n visibleAll: true,\n padding: [2, 0],\n railStyle: {\n fill: 'rgba(0, 0, 0, .1)'\n },\n range: [0, 0.05]\n };\n\n if (isHorozntal) {\n attrs.width = this.scrollContainerBounds.width();\n attrs.height = 12;\n } else {\n attrs.height = this.scrollContainerBounds.height();\n attrs.width = 12;\n }\n\n if (!scrollBar) {\n isUpdate = false;\n\n scrollBar = new ScrollBar(attrs as ScrollBarAttributes);\n scrollBar.name = name;\n container.add(scrollBar);\n (scrollBar as any).isScrollBar = true;\n } else if (scrollbars.length > 1) {\n scrollbars.forEach((child: IGraphic, index: number) => {\n if (index) {\n child.parent?.removeChild(child);\n }\n });\n }\n const childrenBounds = this.childrenBounds;\n\n const { scrollX, scrollY } = scrollContainer.attribute;\n if (isHorozntal) {\n const ratio = Math.min(this.scrollContainerBounds.width() / childrenBounds.width(), 1);\n const start = Math.max(Math.min(scrollX / this.childrenBounds.width(), 0), ratio - 1);\n attrs.x = x + dx;\n attrs.y = y + dy + height - (attrs.height ?? 0);\n attrs.range = [-start, -start + ratio];\n } else {\n const ratio = Math.min(this.scrollContainerBounds.height() / childrenBounds.height(), 1);\n const start = Math.max(Math.min(scrollY / this.childrenBounds.height(), 0), ratio - 1);\n attrs.x = x + dx + width - this.scrollContainerBounds.width();\n attrs.y = y + dy;\n attrs.range = [-start, -start + ratio];\n }\n\n scrollBar.setAttributes(attrs);\n return {\n scrollBar,\n isUpdate\n };\n }\n\n clearScrollbar(scrollContainer: IGroup, type: 'horizontal' | 'vertical' | 'all') {\n if (!scrollContainer.parent) {\n return;\n }\n const scrollbarBars = scrollContainer.parent.children.filter((child: IGroup) => {\n return (child as any).isScrollBar && (type === 'all' || (child.attribute as any).direction === type);\n });\n\n scrollbarBars.forEach((child: IGraphic) => {\n child.parent.removeChild(child);\n });\n }\n\n formatScrollContainer(g: IGraphic) {\n if (!g || g.type !== 'group' || !g.attribute) {\n return null;\n }\n\n const { overflow, width, height } = (g as IGroup).attribute;\n\n if (!overflow || overflow === 'hidden') {\n return null;\n }\n\n let showH = false;\n let showV = false;\n\n if (overflow === 'scroll') {\n showH = true;\n showV = true;\n } else {\n showH = overflow === 'scroll-x';\n showV = !showH;\n }\n\n const childrenBounds = this.childrenBounds;\n\n childrenBounds.clear();\n g.forEachChildren((g: IGraphic) => {\n childrenBounds.union(g.AABBBounds);\n });\n\n if (!g.AABBBounds.empty()) {\n if (showH) {\n showH = width < childrenBounds.width();\n }\n\n if (showV) {\n showV = height < childrenBounds.height();\n }\n }\n\n return showH || showV ? { g: g as IGroup, showH, showV } : null;\n }\n\n // 获取响应滚动的元素\n getScrollContainer(graphic: IGraphic): { g: IGroup; showH: boolean; showV: boolean } | null {\n let g = graphic;\n while (g) {\n const res = this.formatScrollContainer(g);\n\n if (res) {\n return res;\n }\n g = g.parent;\n }\n return null;\n }\n\n deactivate(context: IPluginService): void {\n const { stage } = this.pluginService;\n stage.removeEventListener('wheel', this.scroll as any);\n }\n}\n"]}