@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.
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/poptip/contribution.js +3 -10
- package/cjs/poptip/contribution.js.map +1 -1
- package/cjs/poptip/module.d.ts +0 -2
- package/cjs/poptip/module.js +7 -10
- package/cjs/poptip/module.js.map +1 -1
- package/cjs/poptip/poptip-plugin.js +5 -12
- package/cjs/poptip/poptip-plugin.js.map +1 -1
- package/cjs/poptip/register.js +1 -1
- package/cjs/poptip/register.js.map +1 -1
- package/cjs/scrollbar/module.d.ts +0 -2
- package/cjs/scrollbar/module.js +5 -6
- package/cjs/scrollbar/module.js.map +1 -1
- package/cjs/scrollbar/scrollbar-plugin.js +5 -12
- package/cjs/scrollbar/scrollbar-plugin.js.map +1 -1
- package/cjs/slider/slider.js.map +1 -1
- package/cjs/table-series-number/event-manager.js.map +1 -1
- package/dist/index.es.js +7966 -7760
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/poptip/contribution.js +2 -14
- package/es/poptip/contribution.js.map +1 -1
- package/es/poptip/module.d.ts +0 -2
- package/es/poptip/module.js +4 -8
- package/es/poptip/module.js.map +1 -1
- package/es/poptip/poptip-plugin.js +5 -19
- package/es/poptip/poptip-plugin.js.map +1 -1
- package/es/poptip/register.js +2 -0
- package/es/poptip/register.js.map +1 -1
- package/es/scrollbar/module.d.ts +0 -2
- package/es/scrollbar/module.js +3 -5
- package/es/scrollbar/module.js.map +1 -1
- package/es/scrollbar/scrollbar-plugin.js +5 -13
- package/es/scrollbar/scrollbar-plugin.js.map +1 -1
- package/es/slider/slider.js.map +1 -1
- package/es/table-series-number/event-manager.js.map +1 -1
- package/package.json +6 -6
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
17
17
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
|
-
}), exports.version = void 0, exports.version = "1.0.
|
|
20
|
+
}), exports.version = void 0, exports.version = "1.1.0-alpha.0", __exportStar(require("./core/base"), exports),
|
|
21
21
|
__exportStar(require("./core/type"), exports), __exportStar(require("./scrollbar"), exports),
|
|
22
22
|
__exportStar(require("./tag"), exports), __exportStar(require("./poptip"), exports),
|
|
23
23
|
__exportStar(require("./crosshair"), exports), __exportStar(require("./label"), exports),
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,eAAe,CAAC;AAEvC,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B;AAC5B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,6CAA2B;AAC3B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,0CAAwB;AACxB,8CAA4B;AAC5B,4CAA0B;AAC1B,yCAAuB;AACvB,2CAAyB;AACzB,+CAA6B;AAC7B,wDAAsC","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,22 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
4
|
-
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5
|
-
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);
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
3
|
Object.defineProperty(exports, "__esModule", {
|
|
10
4
|
value: !0
|
|
11
5
|
}), exports.PopTipRenderContribution = void 0;
|
|
12
6
|
|
|
13
|
-
const
|
|
7
|
+
const poptip_1 = require("./poptip"), vutils_1 = require("@visactor/vutils"), theme_1 = require("./theme");
|
|
14
8
|
|
|
15
9
|
function wrapPoptip(target, source) {
|
|
16
10
|
return (0, vutils_1.merge)(target, theme_1.theme.poptip, source), target;
|
|
17
11
|
}
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
class PopTipRenderContribution {
|
|
20
14
|
render(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
|
|
21
15
|
var _a, _b;
|
|
22
16
|
if (1 === graphic._showPoptip) {
|
|
@@ -48,8 +42,7 @@ let PopTipRenderContribution = class {
|
|
|
48
42
|
}), null === (_b = this.poptipComponent.parent) || void 0 === _b || _b.removeChild(this.poptipComponent),
|
|
49
43
|
this.poptipComponent = null));
|
|
50
44
|
}
|
|
51
|
-
}
|
|
45
|
+
}
|
|
52
46
|
|
|
53
|
-
PopTipRenderContribution = __decorate([ (0, vrender_core_1.injectable)() ], PopTipRenderContribution),
|
|
54
47
|
exports.PopTipRenderContribution = PopTipRenderContribution;
|
|
55
48
|
//# sourceMappingURL=contribution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/poptip/contribution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/poptip/contribution.ts"],"names":[],"mappings":";;;AAQA,qCAAkC;AAClC,6CAAyC;AACzC,mCAAgC;AAEhC,SAAS,UAAU,CAAC,MAA2B,EAAE,MAA2B;IAC1E,IAAA,cAAK,EAAC,MAAM,EAAE,aAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAa,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,IAAA,cAAK,EAC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AAgB,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;AAtED,4DAsEC","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"]}
|
package/cjs/poptip/module.d.ts
CHANGED
package/cjs/poptip/module.js
CHANGED
|
@@ -2,20 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.loadPoptip =
|
|
5
|
+
}), exports.loadPoptip = void 0;
|
|
6
6
|
|
|
7
7
|
const vrender_core_1 = require("@visactor/vrender-core"), contribution_1 = require("./contribution"), poptip_plugin_1 = require("./poptip-plugin");
|
|
8
8
|
|
|
9
|
+
let _registered = !1;
|
|
10
|
+
|
|
9
11
|
function loadPoptip() {
|
|
10
|
-
vrender_core_1.
|
|
12
|
+
_registered || (_registered = !0, vrender_core_1.contributionRegistry.register(vrender_core_1.InteractiveSubRenderContribution, new contribution_1.PopTipRenderContribution),
|
|
13
|
+
vrender_core_1.contributionRegistry.register(vrender_core_1.AutoEnablePlugins, new poptip_plugin_1.PopTipPlugin),
|
|
14
|
+
vrender_core_1.contributionRegistry.register(vrender_core_1.AutoEnablePlugins, new poptip_plugin_1.PopTipForClipedTextPlugin));
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
exports.
|
|
14
|
-
isBound(contribution_1.PopTipRenderContribution) || (bind(contribution_1.PopTipRenderContribution).toSelf().inSingletonScope(),
|
|
15
|
-
bind(vrender_core_1.InteractiveSubRenderContribution).toService(contribution_1.PopTipRenderContribution)),
|
|
16
|
-
isBound(poptip_plugin_1.PopTipPlugin) || (bind(poptip_plugin_1.PopTipPlugin).toSelf(),
|
|
17
|
-
bind(vrender_core_1.AutoEnablePlugins).toService(poptip_plugin_1.PopTipPlugin)),
|
|
18
|
-
isBound(poptip_plugin_1.PopTipForClipedTextPlugin) || (bind(poptip_plugin_1.PopTipForClipedTextPlugin).toSelf(),
|
|
19
|
-
bind(vrender_core_1.AutoEnablePlugins).toService(poptip_plugin_1.PopTipForClipedTextPlugin));
|
|
20
|
-
})), exports.loadPoptip = loadPoptip;
|
|
17
|
+
exports.loadPoptip = loadPoptip;
|
|
21
18
|
//# sourceMappingURL=module.js.map
|
package/cjs/poptip/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/poptip/module.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/poptip/module.ts"],"names":[],"mappings":";;;AAAA,yDAAmH;AACnH,iDAA0D;AAC1D,mDAA0E;AAE1E,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,SAAgB,UAAU;IACxB,IAAI,WAAW,EAAE;QACf,OAAO;KACR;IACD,WAAW,GAAG,IAAI,CAAC;IACnB,mCAAoB,CAAC,QAAQ,CAAC,+CAAgC,EAAE,IAAI,uCAAwB,EAAE,CAAC,CAAC;IAChG,mCAAoB,CAAC,QAAQ,CAAC,gCAAiB,EAAE,IAAI,4BAAY,EAAE,CAAC,CAAC;IACrE,mCAAoB,CAAC,QAAQ,CAAC,gCAAiB,EAAE,IAAI,yCAAyB,EAAE,CAAC,CAAC;AACpF,CAAC;AARD,gCAQC","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,11 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
4
|
-
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5
|
-
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);
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
3
|
Object.defineProperty(exports, "__esModule", {
|
|
10
4
|
value: !0
|
|
11
5
|
}), exports.PopTipForClipedTextPlugin = exports.PopTipPlugin = exports.PopTipPluginBase = void 0;
|
|
@@ -47,15 +41,15 @@ class PopTipPluginBase {
|
|
|
47
41
|
|
|
48
42
|
exports.PopTipPluginBase = PopTipPluginBase;
|
|
49
43
|
|
|
50
|
-
|
|
44
|
+
class PopTipPlugin extends PopTipPluginBase {
|
|
51
45
|
constructor() {
|
|
52
46
|
super(...arguments), this.name = "poptip", this.key = this.name + this._uid;
|
|
53
47
|
}
|
|
54
|
-
}
|
|
48
|
+
}
|
|
55
49
|
|
|
56
|
-
|
|
50
|
+
exports.PopTipPlugin = PopTipPlugin;
|
|
57
51
|
|
|
58
|
-
|
|
52
|
+
class PopTipForClipedTextPlugin extends PopTipPluginBase {
|
|
59
53
|
constructor() {
|
|
60
54
|
super(...arguments), this.name = "poptipForText", this.key = this.name + this._uid,
|
|
61
55
|
this.pointerlave = e => {
|
|
@@ -78,8 +72,7 @@ let PopTipForClipedTextPlugin = class extends PopTipPluginBase {
|
|
|
78
72
|
const {stage: stage} = this.pluginService;
|
|
79
73
|
super.deactivate(context), stage.removeEventListener("pointerleave", this.pointerlave);
|
|
80
74
|
}
|
|
81
|
-
}
|
|
75
|
+
}
|
|
82
76
|
|
|
83
|
-
PopTipForClipedTextPlugin = __decorate([ (0, vrender_core_1.injectable)() ], PopTipForClipedTextPlugin),
|
|
84
77
|
exports.PopTipForClipedTextPlugin = PopTipForClipedTextPlugin;
|
|
85
78
|
//# sourceMappingURL=poptip-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/poptip/poptip-plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/poptip/poptip-plugin.ts"],"names":[],"mappings":";;;AACA,yDAAmD;AAInD,MAAsB,gBAAgB;IAAtC;QACE,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,wBAAS,CAAC,kBAAkB,EAAE,CAAC;QAkB9C,WAAM,GAAG,CAAC,CAAwB,EAAE,EAAE;YACpC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAa,CAAC;YAChC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBAC1B,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBACjB,OAAO;aACR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,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;AApCD,8DAoCC","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"]}
|
package/cjs/poptip/register.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.setPoptipTheme = exports.loadPoptipComponent = void 0;
|
|
6
6
|
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), theme_1 = require("./theme"), vrender_kits_1 = require("@visactor/vrender-kits");
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), theme_1 = require("./theme"), vrender_kits_1 = require("@visactor/vrender-kits"), _registered = !1;
|
|
8
8
|
|
|
9
9
|
function loadPoptipComponent() {
|
|
10
10
|
(0, vrender_kits_1.registerGroup)(), (0, vrender_kits_1.registerText)(), (0, vrender_kits_1.registerSymbol)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/poptip/register.ts"],"names":[],"mappings":";;;AACA,6CAAyC;AAEzC,mCAA+C;AAC/C,yDAAmG;AAEnG,SAAgB,mBAAmB;IACjC,IAAA,4BAAa,GAAE,CAAC;IAChB,IAAA,2BAAY,GAAE,CAAC;IACf,IAAA,6BAAc,GAAE,CAAC;IACjB,IAAA,2BAAY,GAAE,CAAC;AACjB,CAAC;AALD,kDAKC;AAED,SAAgB,cAAc,CAAC,kBAAoC;IACjE,IAAA,cAAK,EAAC,aAAK,CAAC,MAAM,EAAE,qBAAa,EAAE,kBAAkB,CAAC,CAAC;AACzD,CAAC;AAFD,wCAEC","file":"register.js","sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../src/poptip/register.ts"],"names":[],"mappings":";;;AACA,6CAAyC;AAEzC,mCAA+C;AAC/C,yDAAmG;AAEnG,MAAM,WAAW,GAAG,KAAK,CAAC;AAC1B,SAAgB,mBAAmB;IACjC,IAAA,4BAAa,GAAE,CAAC;IAChB,IAAA,2BAAY,GAAE,CAAC;IACf,IAAA,6BAAc,GAAE,CAAC;IACjB,IAAA,2BAAY,GAAE,CAAC;AACjB,CAAC;AALD,kDAKC;AAED,SAAgB,cAAc,CAAC,kBAAoC;IACjE,IAAA,cAAK,EAAC,aAAK,CAAC,MAAM,EAAE,qBAAa,EAAE,kBAAkB,CAAC,CAAC;AACzD,CAAC;AAFD,wCAEC","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"]}
|
package/cjs/scrollbar/module.js
CHANGED
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.loadScrollbar =
|
|
5
|
+
}), exports.loadScrollbar = void 0;
|
|
6
6
|
|
|
7
7
|
const vrender_core_1 = require("@visactor/vrender-core"), scrollbar_plugin_1 = require("./scrollbar-plugin");
|
|
8
8
|
|
|
9
|
+
let _registered = !1;
|
|
10
|
+
|
|
9
11
|
function loadScrollbar() {
|
|
10
|
-
vrender_core_1.
|
|
12
|
+
_registered || (_registered = !0, vrender_core_1.contributionRegistry.register(vrender_core_1.AutoEnablePlugins, new scrollbar_plugin_1.ScrollBarPlugin));
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
exports.
|
|
14
|
-
isBound(scrollbar_plugin_1.ScrollBarPlugin) || (bind(scrollbar_plugin_1.ScrollBarPlugin).toSelf(),
|
|
15
|
-
bind(vrender_core_1.AutoEnablePlugins).toService(scrollbar_plugin_1.ScrollBarPlugin));
|
|
16
|
-
})), exports.loadScrollbar = loadScrollbar;
|
|
15
|
+
exports.loadScrollbar = loadScrollbar;
|
|
17
16
|
//# sourceMappingURL=module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/scrollbar/module.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/scrollbar/module.ts"],"names":[],"mappings":";;;AAAA,yDAAiF;AACjF,yDAAqD;AAErD,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,SAAgB,aAAa;IAC3B,IAAI,WAAW,EAAE;QACf,OAAO;KACR;IACD,WAAW,GAAG,IAAI,CAAC;IACnB,mCAAoB,CAAC,QAAQ,CAAC,gCAAiB,EAAE,IAAI,kCAAe,EAAE,CAAC,CAAC;AAC1E,CAAC;AAND,sCAMC","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,18 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var ScrollBarPlugin_1, __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
4
|
-
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5
|
-
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);
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
3
|
Object.defineProperty(exports, "__esModule", {
|
|
10
4
|
value: !0
|
|
11
5
|
}), exports.ScrollBarPlugin = void 0;
|
|
12
6
|
|
|
13
7
|
const vrender_core_1 = require("@visactor/vrender-core"), scrollbar_1 = require("./scrollbar"), vutils_1 = require("@visactor/vutils"), constant_1 = require("../constant");
|
|
14
8
|
|
|
15
|
-
|
|
9
|
+
class ScrollBarPlugin {
|
|
16
10
|
constructor() {
|
|
17
11
|
this.name = "scrollbar", this.activeEvent = "onRegister", this._uid = vrender_core_1.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 vutils_1.AABBBounds, stage.addEventListener("wheel", this.scroll),
|
|
67
|
-
this.params =
|
|
61
|
+
this.params = ScrollBarPlugin.defaultParams;
|
|
68
62
|
}
|
|
69
63
|
initEventOfScrollbar(scrollContainer, scrollbar, isHorozntal) {
|
|
70
64
|
scrollContainer.addEventListener("pointerover", (() => {
|
|
@@ -165,10 +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
|
-
ScrollBarPlugin.defaultParams = {
|
|
164
|
+
exports.ScrollBarPlugin = ScrollBarPlugin, ScrollBarPlugin.defaultParams = {
|
|
171
165
|
timeout: 500
|
|
172
|
-
}
|
|
173
|
-
exports.ScrollBarPlugin = ScrollBarPlugin;
|
|
166
|
+
};
|
|
174
167
|
//# sourceMappingURL=scrollbar-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/scrollbar/scrollbar-plugin.ts"],"names":[],"mappings":";;;;;;;;;;AACA,yDAA+D;AAC/D,2CAAwC;AAExC,6CAA2D;AAC3D,0CAA8C;AAYvC,IAAM,eAAe,uBAArB,MAAM,eAAe;IAArB;QACL,SAAI,GAAgB,WAAW,CAAC;QAChC,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,wBAAS,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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AAC;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;AAZS,eAAe;IAD3B,IAAA,yBAAU,GAAE;GACA,eAAe,CAuU3B;AAvUY,0CAAe","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,yDAAmD;AACnD,2CAAwC;AAExC,6C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AAI,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;;AAtUH,0CAuUC;AA7TQ,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"]}
|