@visactor/vrender-components 0.12.1 → 0.12.3-alpha.6
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/axis/base.d.ts +5 -5
- package/cjs/axis/base.js +1 -2
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/circle.d.ts +5 -5
- package/cjs/axis/circle.js +2 -2
- package/cjs/axis/circle.js.map +1 -1
- package/cjs/axis/line.d.ts +5 -6
- package/cjs/axis/line.js +3 -2
- package/cjs/axis/line.js.map +1 -1
- package/cjs/brush/brush.d.ts +5 -3
- package/cjs/brush/brush.js +21 -15
- package/cjs/brush/brush.js.map +1 -1
- package/cjs/brush/type.d.ts +10 -1
- package/cjs/brush/type.js +7 -1
- package/cjs/brush/type.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/legend/discrete/discrete.d.ts +1 -1
- package/cjs/legend/discrete/discrete.js +54 -41
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/pager/pager.d.ts +2 -2
- package/cjs/pager/pager.js +4 -2
- package/cjs/pager/pager.js.map +1 -1
- package/cjs/util/matrix.d.ts +5 -2
- package/cjs/util/matrix.js +24 -11
- package/cjs/util/matrix.js.map +1 -1
- package/dist/index.js +90 -162
- package/dist/index.min.js +1 -1
- package/es/axis/base.d.ts +5 -5
- package/es/axis/base.js +1 -2
- package/es/axis/base.js.map +1 -1
- package/es/axis/circle.d.ts +5 -5
- package/es/axis/circle.js +2 -3
- package/es/axis/circle.js.map +1 -1
- package/es/axis/line.d.ts +5 -6
- package/es/axis/line.js +3 -3
- package/es/axis/line.js.map +1 -1
- package/es/brush/brush.d.ts +5 -3
- package/es/brush/brush.js +20 -12
- package/es/brush/brush.js.map +1 -1
- package/es/brush/type.d.ts +10 -1
- package/es/brush/type.js +7 -1
- package/es/brush/type.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/legend/discrete/discrete.d.ts +1 -1
- package/es/legend/discrete/discrete.js +54 -41
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/pager/pager.d.ts +2 -2
- package/es/pager/pager.js +4 -2
- package/es/pager/pager.js.map +1 -1
- package/es/util/matrix.d.ts +5 -2
- package/es/util/matrix.js +19 -3
- package/es/util/matrix.js.map +1 -1
- package/package.json +3 -4
package/cjs/pager/pager.js
CHANGED
|
@@ -73,7 +73,8 @@ class Pager extends base_1.AbstractComponent {
|
|
|
73
73
|
let {preShape: preShape, nextShape: nextShape} = handler;
|
|
74
74
|
preShape || (preShape = isHorizontal ? "triangleLeft" : "triangleUp"), nextShape || (nextShape = isHorizontal ? "triangleRight" : "triangleDown");
|
|
75
75
|
const preHandler = (0, vrender_1.createSymbol)(Object.assign(Object.assign({
|
|
76
|
-
strokeBoundsBuffer: 0
|
|
76
|
+
strokeBoundsBuffer: 0,
|
|
77
|
+
pickMode: "imprecise"
|
|
77
78
|
}, handlerStyle), {
|
|
78
79
|
x: 0,
|
|
79
80
|
y: 0,
|
|
@@ -96,7 +97,8 @@ class Pager extends base_1.AbstractComponent {
|
|
|
96
97
|
}, textStyle));
|
|
97
98
|
this.text = text, container.add(text);
|
|
98
99
|
const nextHandler = (0, vrender_1.createSymbol)(Object.assign(Object.assign({
|
|
99
|
-
strokeBoundsBuffer: 0
|
|
100
|
+
strokeBoundsBuffer: 0,
|
|
101
|
+
pickMode: "imprecise"
|
|
100
102
|
}, handlerStyle), {
|
|
101
103
|
x: isHorizontal ? handlerSizeX + 2 * handlerSpace + maxTextWidth : 0,
|
|
102
104
|
y: isHorizontal ? 0 : handlerSizeY + 2 * handlerSpace + maxTextHeight,
|
package/cjs/pager/pager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["pager/pager.ts"],"names":[],"mappings":";;;AAGA,+CAQ2B;AAC3B,6CAA0E;AAC1E,uCAAiD;AACjD,kCA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,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,KAAe,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACxD,CAAC;;AAxNH,sBAyNC;AA5MQ,uBAAiB,GAA6B;IACnD,OAAO,EAAE,qBAAqB;IAC9B,SAAS,EAAE;QACT,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,EAAE;KACb;CACF,CAAC","file":"pager.js","sourcesContent":["/**\n * @description 翻页器\n */\nimport {\n createGroup,\n createSymbol,\n createText,\n ISymbol,\n IText,\n FederatedPointerEvent,\n CustomEvent\n} from '@visactor/vrender';\nimport { merge, normalizePadding, get, isNumber } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { measureTextSize } from '../util';\nimport { PagerAttributes } from './type';\n\nconst DEFAULT_HANDLER_STYLE: PagerAttributes['handler'] = {\n space: 8,\n style: {\n fill: 'rgb(47, 69, 84)',\n cursor: 'pointer',\n size: 15\n },\n state: {\n disable: {\n fill: 'rgb(170, 170, 170)',\n cursor: 'not-allowed'\n },\n hover: {}\n }\n};\n\nexport class Pager extends AbstractComponent<Required<PagerAttributes>> {\n name = 'pager';\n\n private _current = 1;\n getCurrent() {\n return this._current;\n }\n\n private _total!: number;\n preHandler!: ISymbol | null;\n nextHandler!: ISymbol | null;\n text!: IText | null;\n\n static defaultAttributes: Partial<PagerAttributes> = {\n handler: DEFAULT_HANDLER_STYLE,\n textStyle: {\n fill: 'rgb(51, 51, 51)',\n fontSize: 12\n }\n };\n\n constructor(attributes: PagerAttributes) {\n super(merge({}, Pager.defaultAttributes, attributes));\n }\n\n protected render() {\n this._reset();\n const {\n layout = 'horizontal',\n handler = DEFAULT_HANDLER_STYLE,\n total,\n defaultCurrent = 1,\n textStyle,\n padding = 0\n } = this.attribute;\n\n this._current = defaultCurrent;\n const parsedPadding = normalizePadding(padding);\n const isHorizontal = layout === 'horizontal';\n\n const container = createGroup({\n x: 0,\n y: 0\n });\n\n const handlerStyle = handler.style || {};\n const handlerSize = handlerStyle.size || 15;\n const handlerSpace = handler.space ?? 8;\n const handlerState = handler.state || {};\n\n let { preShape, nextShape } = handler;\n if (!preShape) {\n preShape = isHorizontal ? 'triangleLeft' : 'triangleUp';\n }\n if (!nextShape) {\n nextShape = isHorizontal ? 'triangleRight' : 'triangleDown';\n }\n\n const preHandler = createSymbol({\n strokeBoundsBuffer: 0,\n ...handlerStyle,\n x: 0,\n y: 0,\n symbolType: preShape,\n size: handlerSize\n });\n preHandler.states = handlerState;\n preHandler.name = 'preHandler';\n this.preHandler = preHandler;\n container.add(preHandler);\n\n // 获取文本的最大长度,如果不固定的话随着文本的变化整体会发生抖动\n const { width: maxTextWidth, height: maxTextHeight } = measureTextSize(`${total}/${total}`, {\n textAlign: 'center',\n textBaseline: 'middle',\n ...textStyle\n });\n\n const handlerSizeX = isNumber(handlerSize) ? handlerSize : handlerSize[0];\n const handlerSizeY = isNumber(handlerSize) ? handlerSize : handlerSize[1];\n\n const text = createText({\n x: isHorizontal ? handlerSizeX / 2 + handlerSpace + maxTextWidth / 2 : 0,\n y: isHorizontal ? 0 : handlerSizeY / 2 + handlerSpace + maxTextHeight / 2,\n text: `${defaultCurrent}/${total}`,\n textAlign: 'center',\n textBaseline: 'middle',\n lineHeight: textStyle?.fontSize,\n ...textStyle\n });\n this.text = text;\n container.add(text);\n\n const nextHandler = createSymbol({\n strokeBoundsBuffer: 0,\n ...handlerStyle,\n x: isHorizontal ? handlerSizeX + handlerSpace * 2 + maxTextWidth : 0,\n y: isHorizontal ? 0 : handlerSizeY + handlerSpace * 2 + maxTextHeight,\n symbolType: nextShape,\n size: handlerSize\n });\n nextHandler.name = 'nextHandler';\n nextHandler.states = handlerState;\n this.nextHandler = nextHandler;\n\n container.add(nextHandler);\n\n if (this._total === 1) {\n preHandler.addState('disable');\n nextHandler.addState('disable');\n } else if (this._current === 1) {\n preHandler.addState('disable');\n } else if (this._current === total) {\n nextHandler.addState('disable');\n }\n\n const containerBounds = container.AABBBounds;\n const width = containerBounds.width();\n const height = containerBounds.height();\n\n container.translateTo(0 - containerBounds.x1 + parsedPadding[3], 0 - containerBounds.y1 + parsedPadding[0]);\n this.add(container);\n\n this.attribute.width = width + parsedPadding[1] + parsedPadding[3];\n this.attribute.height = height + parsedPadding[0] + parsedPadding[2];\n\n this._bindEvents();\n }\n\n private _bindEvents(): void {\n if (this.preHandler) {\n this.preHandler.addEventListener('pointerenter', this._onHover as EventListenerOrEventListenerObject);\n this.preHandler.addEventListener('pointerleave', this._onUnHover as EventListenerOrEventListenerObject);\n this.preHandler.addEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n\n if (this.nextHandler) {\n this.nextHandler.addEventListener('pointerenter', this._onHover as EventListenerOrEventListenerObject);\n this.nextHandler.addEventListener('pointerleave', this._onUnHover as EventListenerOrEventListenerObject);\n this.nextHandler.addEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n }\n\n private _onHover = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as ISymbol;\n if (!target.hasState('disable')) {\n target.addState('hover');\n }\n };\n\n private _onUnHover = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as ISymbol;\n target.removeState('hover');\n };\n\n private _onClick = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as ISymbol;\n if (target.name === 'preHandler') {\n if (this._current === 1) {\n return;\n }\n this._current -= 1;\n if (this._current === 1) {\n target.addState('disable');\n } else {\n target.removeState('disable');\n }\n const changeEvent = new CustomEvent('toPrev', {\n current: this._current,\n total: this._total,\n direction: 'pre'\n });\n // FIXME: 需要在 vrender 的事件系统支持\n // @ts-ignore\n changeEvent.manager = this.stage?.eventSystem.manager;\n this.dispatchEvent(changeEvent);\n }\n\n if (target.name === 'nextHandler') {\n if (this._current === this._total) {\n return;\n }\n this._current += 1;\n\n if (this._current === this._total) {\n target.addState('disable');\n } else {\n target.removeState('disable');\n }\n\n const changeEvent = new CustomEvent('toNext', {\n current: this._current,\n total: this._total,\n direction: 'next'\n });\n // FIXME: 需要在 vrender 的事件系统支持\n // @ts-ignore\n changeEvent.manager = this.stage?.eventSystem.manager;\n this.dispatchEvent(changeEvent);\n }\n\n if (this._current > 1) {\n (this.preHandler as ISymbol).removeState('disable');\n }\n if (this._current < this._total) {\n (this.nextHandler as ISymbol).removeState('disable');\n }\n\n (this.text as IText).setAttribute('text', `${this._current}/${this._total}`);\n };\n\n private _reset() {\n this.removeAllChild();\n this._current = 1;\n this._total = this.attribute.total as number;\n this.preHandler = this.nextHandler = this.text = null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["pager/pager.ts"],"names":[],"mappings":";;;AAKA,+CAAuF;AACvF,6CAAqE;AACrE,uCAAiD;AACjD,kCAA0C;AAG1C,MAAM,qBAAqB,GAA+B;IACxD,KAAK,EAAE,CAAC;IACR,KAAK,EAAE;QACL,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,EAAE;KACT;IACD,KAAK,EAAE;QACL,OAAO,EAAE;YACP,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,aAAa;SACtB;QACD,KAAK,EAAE,EAAE;KACV;CACF,CAAC;AAEF,MAAa,KAAM,SAAQ,wBAA4C;IAIrE,UAAU;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAeD,YAAY,UAA2B;QACrC,KAAK,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,KAAK,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QArBxD,SAAI,GAAG,OAAO,CAAC;QAEP,aAAQ,GAAG,CAAC,CAAC;QA8Ib,aAAQ,GAAG,CAAC,CAAwB,EAAE,EAAE;YAC9C,MAAM,MAAM,GAAG,CAAC,CAAC,MAA4B,CAAC;YAC9C,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EAAE;YACnB,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,CAAC,QAA8C,CAAC,CAAC;YACtG,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,CAAC,UAAgD,CAAC,CAAC;YACxG,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,QAA8C,CAAC,CAAC;SACtG;QAED,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,CAAC,QAA8C,CAAC,CAAC;YACvG,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,CAAC,UAAgD,CAAC,CAAC;YACzG,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,QAA8C,CAAC,CAAC;SACvG;IACH,CAAC;IAsEO,MAAM;QACZ,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,KAAe,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACxD,CAAC;;AA1NH,sBA2NC;AA9MQ,uBAAiB,GAA6B;IACnD,OAAO,EAAE,qBAAqB;IAC9B,SAAS,EAAE;QACT,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,EAAE;KACb;CACF,CAAC","file":"pager.js","sourcesContent":["/**\n * @description 翻页器\n */\nimport type { ISymbol, IText, FederatedPointerEvent } from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { createGroup, createSymbol, createText, CustomEvent } from '@visactor/vrender';\nimport { merge, normalizePadding, isNumber } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { measureTextSize } from '../util';\nimport type { PagerAttributes } from './type';\n\nconst DEFAULT_HANDLER_STYLE: PagerAttributes['handler'] = {\n space: 8,\n style: {\n fill: 'rgb(47, 69, 84)',\n cursor: 'pointer',\n size: 15\n },\n state: {\n disable: {\n fill: 'rgb(170, 170, 170)',\n cursor: 'not-allowed'\n },\n hover: {}\n }\n};\n\nexport class Pager extends AbstractComponent<Required<PagerAttributes>> {\n name = 'pager';\n\n private _current = 1;\n getCurrent() {\n return this._current;\n }\n\n private _total!: number;\n preHandler!: ISymbol | null;\n nextHandler!: ISymbol | null;\n text!: IText | null;\n\n static defaultAttributes: Partial<PagerAttributes> = {\n handler: DEFAULT_HANDLER_STYLE,\n textStyle: {\n fill: 'rgb(51, 51, 51)',\n fontSize: 12\n }\n };\n\n constructor(attributes: PagerAttributes) {\n super(merge({}, Pager.defaultAttributes, attributes));\n }\n\n protected render() {\n this._reset();\n const {\n layout = 'horizontal',\n handler = DEFAULT_HANDLER_STYLE,\n total,\n defaultCurrent = 1,\n textStyle,\n padding = 0\n } = this.attribute;\n\n this._current = defaultCurrent;\n const parsedPadding = normalizePadding(padding);\n const isHorizontal = layout === 'horizontal';\n\n const container = createGroup({\n x: 0,\n y: 0\n });\n\n const handlerStyle = handler.style || {};\n const handlerSize = handlerStyle.size || 15;\n const handlerSpace = handler.space ?? 8;\n const handlerState = handler.state || {};\n\n let { preShape, nextShape } = handler;\n if (!preShape) {\n preShape = isHorizontal ? 'triangleLeft' : 'triangleUp';\n }\n if (!nextShape) {\n nextShape = isHorizontal ? 'triangleRight' : 'triangleDown';\n }\n\n const preHandler = createSymbol({\n strokeBoundsBuffer: 0,\n pickMode: 'imprecise',\n ...handlerStyle,\n x: 0,\n y: 0,\n symbolType: preShape,\n size: handlerSize\n });\n preHandler.states = handlerState;\n preHandler.name = 'preHandler';\n this.preHandler = preHandler;\n container.add(preHandler);\n\n // 获取文本的最大长度,如果不固定的话随着文本的变化整体会发生抖动\n const { width: maxTextWidth, height: maxTextHeight } = measureTextSize(`${total}/${total}`, {\n textAlign: 'center',\n textBaseline: 'middle',\n ...textStyle\n });\n\n const handlerSizeX = isNumber(handlerSize) ? handlerSize : handlerSize[0];\n const handlerSizeY = isNumber(handlerSize) ? handlerSize : handlerSize[1];\n\n const text = createText({\n x: isHorizontal ? handlerSizeX / 2 + handlerSpace + maxTextWidth / 2 : 0,\n y: isHorizontal ? 0 : handlerSizeY / 2 + handlerSpace + maxTextHeight / 2,\n text: `${defaultCurrent}/${total}`,\n textAlign: 'center',\n textBaseline: 'middle',\n lineHeight: textStyle?.fontSize,\n ...textStyle\n });\n this.text = text;\n container.add(text);\n\n const nextHandler = createSymbol({\n strokeBoundsBuffer: 0,\n pickMode: 'imprecise',\n ...handlerStyle,\n x: isHorizontal ? handlerSizeX + handlerSpace * 2 + maxTextWidth : 0,\n y: isHorizontal ? 0 : handlerSizeY + handlerSpace * 2 + maxTextHeight,\n symbolType: nextShape,\n size: handlerSize\n });\n nextHandler.name = 'nextHandler';\n nextHandler.states = handlerState;\n this.nextHandler = nextHandler;\n\n container.add(nextHandler);\n\n if (this._total === 1) {\n preHandler.addState('disable');\n nextHandler.addState('disable');\n } else if (this._current === 1) {\n preHandler.addState('disable');\n } else if (this._current === total) {\n nextHandler.addState('disable');\n }\n\n const containerBounds = container.AABBBounds;\n const width = containerBounds.width();\n const height = containerBounds.height();\n\n container.translateTo(0 - containerBounds.x1 + parsedPadding[3], 0 - containerBounds.y1 + parsedPadding[0]);\n this.add(container);\n\n this.attribute.width = width + parsedPadding[1] + parsedPadding[3];\n this.attribute.height = height + parsedPadding[0] + parsedPadding[2];\n\n this._bindEvents();\n }\n\n private _bindEvents(): void {\n if (this.preHandler) {\n this.preHandler.addEventListener('pointerenter', this._onHover as EventListenerOrEventListenerObject);\n this.preHandler.addEventListener('pointerleave', this._onUnHover as EventListenerOrEventListenerObject);\n this.preHandler.addEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n\n if (this.nextHandler) {\n this.nextHandler.addEventListener('pointerenter', this._onHover as EventListenerOrEventListenerObject);\n this.nextHandler.addEventListener('pointerleave', this._onUnHover as EventListenerOrEventListenerObject);\n this.nextHandler.addEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n }\n\n private _onHover = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as ISymbol;\n if (!target.hasState('disable')) {\n target.addState('hover');\n }\n };\n\n private _onUnHover = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as ISymbol;\n target.removeState('hover');\n };\n\n private _onClick = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as ISymbol;\n if (target.name === 'preHandler') {\n if (this._current === 1) {\n return;\n }\n this._current -= 1;\n if (this._current === 1) {\n target.addState('disable');\n } else {\n target.removeState('disable');\n }\n const changeEvent = new CustomEvent('toPrev', {\n current: this._current,\n total: this._total,\n direction: 'pre'\n });\n // FIXME: 需要在 vrender 的事件系统支持\n // @ts-ignore\n changeEvent.manager = this.stage?.eventSystem.manager;\n this.dispatchEvent(changeEvent);\n }\n\n if (target.name === 'nextHandler') {\n if (this._current === this._total) {\n return;\n }\n this._current += 1;\n\n if (this._current === this._total) {\n target.addState('disable');\n } else {\n target.removeState('disable');\n }\n\n const changeEvent = new CustomEvent('toNext', {\n current: this._current,\n total: this._total,\n direction: 'next'\n });\n // FIXME: 需要在 vrender 的事件系统支持\n // @ts-ignore\n changeEvent.manager = this.stage?.eventSystem.manager;\n this.dispatchEvent(changeEvent);\n }\n\n if (this._current > 1) {\n (this.preHandler as ISymbol).removeState('disable');\n }\n if (this._current < this._total) {\n (this.nextHandler as ISymbol).removeState('disable');\n }\n\n (this.text as IText).setAttribute('text', `${this._current}/${this._total}`);\n };\n\n private _reset() {\n this.removeAllChild();\n this._current = 1;\n this._total = this.attribute.total as number;\n this.preHandler = this.nextHandler = this.text = null;\n }\n}\n"]}
|
package/cjs/util/matrix.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
export type Vector2 = [number, number];
|
|
2
|
+
export declare function scale(vector: Vector2, scale: number): number[];
|
|
3
|
+
export declare function length(vector: Vector2): number;
|
|
4
|
+
export declare function normalize(vector: Vector2): number[];
|
|
5
|
+
export declare function angle(vector1: Vector2, vector2: Vector2): number;
|
|
3
6
|
export declare function direction(v1: number[], v2: number[]): number;
|
|
4
7
|
export declare function angleTo(v1: [number, number], v2: [number, number], direct: boolean): number;
|
package/cjs/util/matrix.js
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
3
|
+
function scale(vector, scale) {
|
|
4
|
+
return [ vector[0] * scale, vector[1] * scale ];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function length(vector) {
|
|
8
|
+
const [x, y] = vector;
|
|
9
|
+
return Math.sqrt(x * x + y * y);
|
|
10
|
+
}
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
function normalize(vector) {
|
|
13
|
+
const [x, y] = vector;
|
|
14
|
+
let len = x * x + y * y;
|
|
15
|
+
return len > 0 && (len = 1 / Math.sqrt(len)), [ vector[0] * len, vector[1] * len ];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function angle(vector1, vector2) {
|
|
19
|
+
const [x1, y1] = vector1, [x2, y2] = vector2, mag = Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2)), cosine = mag && (x1 * x2 + y1 * y2) / mag;
|
|
20
|
+
return Math.acos(Math.min(Math.max(cosine, -1), 1));
|
|
21
|
+
}
|
|
8
22
|
|
|
9
23
|
function direction(v1, v2) {
|
|
10
24
|
return v1[0] * v2[1] - v2[0] * v1[1];
|
|
11
25
|
}
|
|
12
26
|
|
|
13
27
|
function angleTo(v1, v2, direct) {
|
|
14
|
-
const ang =
|
|
28
|
+
const ang = angle(v1, v2), angleLargeThanPI = direction(v1, v2) >= 0;
|
|
15
29
|
return direct ? angleLargeThanPI ? 2 * Math.PI - ang : ang : angleLargeThanPI ? ang : 2 * Math.PI - ang;
|
|
16
30
|
}
|
|
17
31
|
|
|
18
|
-
Object.defineProperty(exports, "
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}), exports.direction = direction, exports.angleTo = angleTo;
|
|
32
|
+
Object.defineProperty(exports, "__esModule", {
|
|
33
|
+
value: !0
|
|
34
|
+
}), exports.angleTo = exports.direction = exports.angle = exports.normalize = exports.length = exports.scale = void 0,
|
|
35
|
+
exports.scale = scale, exports.length = length, exports.normalize = normalize, exports.angle = angle,
|
|
36
|
+
exports.direction = direction, exports.angleTo = angleTo;
|
|
24
37
|
//# sourceMappingURL=matrix.js.map
|
package/cjs/util/matrix.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["util/matrix.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["util/matrix.ts"],"names":[],"mappings":";;;AAKA,SAAgB,KAAK,CAAC,MAAe,EAAE,KAAa;IAClD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;AAChD,CAAC;AAFD,sBAEC;AAKD,SAAgB,MAAM,CAAC,MAAe;IACpC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC;IACtB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAClC,CAAC;AAHD,wBAGC;AAKD,SAAgB,SAAS,CAAC,MAAe;IACvC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC;IACtB,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,GAAG,GAAG,CAAC,EAAE;QACX,GAAG,GAAG,CAAC,GAAG,IAAI,CAA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gBAAgB,EAAE;YACpB,OAAO,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;SAC1B;QACD,OAAO,GAAG,CAAC;KACZ;IAED,IAAI,gBAAgB,EAAE;QACpB,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;AAC3B,CAAC;AAdD,0BAcC","file":"matrix.js","sourcesContent":["export type Vector2 = [number, number];\n\n/**\n * Scales a vec2 by a scalar number\n */\nexport function scale(vector: Vector2, scale: number) {\n return [vector[0] * scale, vector[1] * scale];\n}\n\n/**\n * Calculates the length of a vec2\n */\nexport function length(vector: Vector2) {\n const [x, y] = vector;\n return Math.sqrt(x * x + y * y);\n}\n\n/**\n * Normalize a vec2\n */\nexport function normalize(vector: Vector2) {\n const [x, y] = vector;\n let len = x * x + y * y;\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n }\n return [vector[0] * len, vector[1] * len];\n}\n\n/**\n * Get the angle between two 2D vectors\n */\nexport function angle(vector1: Vector2, vector2: Vector2) {\n const [x1, y1] = vector1;\n const [x2, y2] = vector2;\n const mag = Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2));\n const cosine = mag && (x1 * x2 + y1 * y2) / mag;\n return Math.acos(Math.min(Math.max(cosine, -1), 1));\n}\n\n/**\n * 向量 v1 到 向量 v2 夹角的方向\n * @param {Array} v1 向量\n * @param {Array} v2 向量\n * @return {Boolean} >= 0 顺时针 < 0 逆时针\n */\nexport function direction(v1: number[], v2: number[]): number {\n return v1[0] * v2[1] - v2[0] * v1[1];\n}\n\n/**\n * 二维向量 v1 到 v2 的夹角\n * @param v1\n * @param v2\n * @param direct\n */\nexport function angleTo(v1: [number, number], v2: [number, number], direct: boolean): number {\n const ang = angle(v1, v2);\n const angleLargeThanPI = direction(v1, v2) >= 0;\n if (direct) {\n if (angleLargeThanPI) {\n return Math.PI * 2 - ang;\n }\n return ang;\n }\n\n if (angleLargeThanPI) {\n return ang;\n }\n return Math.PI * 2 - ang;\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -436,143 +436,28 @@
|
|
|
436
436
|
return '#' + vutils.ColorUtil.rgbToHex(r, g, b);
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
* @module glMatrix
|
|
442
|
-
*/
|
|
443
|
-
var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
|
|
444
|
-
if (!Math.hypot) Math.hypot = function () {
|
|
445
|
-
var y = 0,
|
|
446
|
-
i = arguments.length;
|
|
447
|
-
while (i--) {
|
|
448
|
-
y += arguments[i] * arguments[i];
|
|
449
|
-
}
|
|
450
|
-
return Math.sqrt(y);
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* 2 Dimensional Vector
|
|
455
|
-
* @module vec2
|
|
456
|
-
*/
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Creates a new, empty vec2
|
|
460
|
-
*
|
|
461
|
-
* @returns {vec2} a new 2D vector
|
|
462
|
-
*/
|
|
463
|
-
|
|
464
|
-
function create() {
|
|
465
|
-
var out = new ARRAY_TYPE(2);
|
|
466
|
-
if (ARRAY_TYPE != Float32Array) {
|
|
467
|
-
out[0] = 0;
|
|
468
|
-
out[1] = 0;
|
|
469
|
-
}
|
|
470
|
-
return out;
|
|
439
|
+
function scale(vector, scale) {
|
|
440
|
+
return [vector[0] * scale, vector[1] * scale];
|
|
471
441
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
* @param {vec2} out the receiving vector
|
|
476
|
-
* @param {ReadonlyVec2} a the vector to scale
|
|
477
|
-
* @param {Number} b amount to scale the vector by
|
|
478
|
-
* @returns {vec2} out
|
|
479
|
-
*/
|
|
480
|
-
|
|
481
|
-
function scale(out, a, b) {
|
|
482
|
-
out[0] = a[0] * b;
|
|
483
|
-
out[1] = a[1] * b;
|
|
484
|
-
return out;
|
|
442
|
+
function length(vector) {
|
|
443
|
+
const [x, y] = vector;
|
|
444
|
+
return Math.sqrt(x * x + y * y);
|
|
485
445
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
function length(a) {
|
|
494
|
-
var x = a[0],
|
|
495
|
-
y = a[1];
|
|
496
|
-
return Math.hypot(x, y);
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Normalize a vec2
|
|
500
|
-
*
|
|
501
|
-
* @param {vec2} out the receiving vector
|
|
502
|
-
* @param {ReadonlyVec2} a vector to normalize
|
|
503
|
-
* @returns {vec2} out
|
|
504
|
-
*/
|
|
505
|
-
|
|
506
|
-
function normalize(out, a) {
|
|
507
|
-
var x = a[0],
|
|
508
|
-
y = a[1];
|
|
509
|
-
var len = x * x + y * y;
|
|
510
|
-
if (len > 0) {
|
|
511
|
-
//TODO: evaluate use of glm_invsqrt here?
|
|
512
|
-
len = 1 / Math.sqrt(len);
|
|
513
|
-
}
|
|
514
|
-
out[0] = a[0] * len;
|
|
515
|
-
out[1] = a[1] * len;
|
|
516
|
-
return out;
|
|
446
|
+
function normalize(vector) {
|
|
447
|
+
const [x, y] = vector;
|
|
448
|
+
let len = x * x + y * y;
|
|
449
|
+
if (len > 0) {
|
|
450
|
+
len = 1 / Math.sqrt(len);
|
|
451
|
+
}
|
|
452
|
+
return [vector[0] * len, vector[1] * len];
|
|
517
453
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
function angle(a, b) {
|
|
526
|
-
var x1 = a[0],
|
|
527
|
-
y1 = a[1],
|
|
528
|
-
x2 = b[0],
|
|
529
|
-
y2 = b[1],
|
|
530
|
-
// mag is the product of the magnitudes of a and b
|
|
531
|
-
mag = Math.sqrt(x1 * x1 + y1 * y1) * Math.sqrt(x2 * x2 + y2 * y2),
|
|
532
|
-
// mag &&.. short circuits if mag == 0
|
|
533
|
-
cosine = mag && (x1 * x2 + y1 * y2) / mag; // Math.min(Math.max(cosine, -1), 1) clamps the cosine between -1 and 1
|
|
534
|
-
|
|
535
|
-
return Math.acos(Math.min(Math.max(cosine, -1), 1));
|
|
454
|
+
function angle(vector1, vector2) {
|
|
455
|
+
const [x1, y1] = vector1;
|
|
456
|
+
const [x2, y2] = vector2;
|
|
457
|
+
const mag = Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2));
|
|
458
|
+
const cosine = mag && (x1 * x2 + y1 * y2) / mag;
|
|
459
|
+
return Math.acos(Math.min(Math.max(cosine, -1), 1));
|
|
536
460
|
}
|
|
537
|
-
/**
|
|
538
|
-
* Perform some operation over an array of vec2s.
|
|
539
|
-
*
|
|
540
|
-
* @param {Array} a the array of vectors to iterate over
|
|
541
|
-
* @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
|
|
542
|
-
* @param {Number} offset Number of elements to skip at the beginning of the array
|
|
543
|
-
* @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
|
|
544
|
-
* @param {Function} fn Function to call for each vector in the array
|
|
545
|
-
* @param {Object} [arg] additional argument to pass to fn
|
|
546
|
-
* @returns {Array} a
|
|
547
|
-
* @function
|
|
548
|
-
*/
|
|
549
|
-
|
|
550
|
-
(function () {
|
|
551
|
-
var vec = create();
|
|
552
|
-
return function (a, stride, offset, count, fn, arg) {
|
|
553
|
-
var i, l;
|
|
554
|
-
if (!stride) {
|
|
555
|
-
stride = 2;
|
|
556
|
-
}
|
|
557
|
-
if (!offset) {
|
|
558
|
-
offset = 0;
|
|
559
|
-
}
|
|
560
|
-
if (count) {
|
|
561
|
-
l = Math.min(count * stride + offset, a.length);
|
|
562
|
-
} else {
|
|
563
|
-
l = a.length;
|
|
564
|
-
}
|
|
565
|
-
for (i = offset; i < l; i += stride) {
|
|
566
|
-
vec[0] = a[i];
|
|
567
|
-
vec[1] = a[i + 1];
|
|
568
|
-
fn(vec, vec, arg);
|
|
569
|
-
a[i] = vec[0];
|
|
570
|
-
a[i + 1] = vec[1];
|
|
571
|
-
}
|
|
572
|
-
return a;
|
|
573
|
-
};
|
|
574
|
-
})();
|
|
575
|
-
|
|
576
461
|
function direction(v1, v2) {
|
|
577
462
|
return v1[0] * v2[1] - v2[0] * v1[1];
|
|
578
463
|
}
|
|
@@ -2525,11 +2410,11 @@
|
|
|
2525
2410
|
container.add(axisTitle);
|
|
2526
2411
|
}
|
|
2527
2412
|
renderGrid(container) {
|
|
2528
|
-
this._renderGridByType('grid', container);
|
|
2529
2413
|
const { visible } = this.attribute.subGrid || {};
|
|
2530
2414
|
if (visible) {
|
|
2531
2415
|
this._renderGridByType('subGrid', container);
|
|
2532
2416
|
}
|
|
2417
|
+
this._renderGridByType('grid', container);
|
|
2533
2418
|
}
|
|
2534
2419
|
getVerticalCoord(point, offset, inside) {
|
|
2535
2420
|
const vector = this.getVerticalVector(offset, inside, point);
|
|
@@ -2773,9 +2658,9 @@
|
|
|
2773
2658
|
getVerticalVector(offset, inside = false) {
|
|
2774
2659
|
const { verticalFactor = 1 } = this.attribute;
|
|
2775
2660
|
const axisVector = this.getRelativeVector();
|
|
2776
|
-
const
|
|
2777
|
-
const verticalVector = [
|
|
2778
|
-
return scale(
|
|
2661
|
+
const normalizedAxisVector = normalize(axisVector);
|
|
2662
|
+
const verticalVector = [normalizedAxisVector[1], normalizedAxisVector[0] * -1];
|
|
2663
|
+
return scale(verticalVector, offset * (inside ? 1 : -1) * verticalFactor);
|
|
2779
2664
|
}
|
|
2780
2665
|
getTitleAttribute() {
|
|
2781
2666
|
const { position = 'middle', space = 4, textStyle = {}, autoRotate = true, shape, background, state, ...restAttrs } = this.attribute.title;
|
|
@@ -3072,8 +2957,7 @@
|
|
|
3072
2957
|
const { inside: axisInside = false } = this.attribute;
|
|
3073
2958
|
const { center } = this.attribute;
|
|
3074
2959
|
const vector = [point.x - center.x, point.y - center.y];
|
|
3075
|
-
scale(vector,
|
|
3076
|
-
return vector;
|
|
2960
|
+
return scale(vector, ((inside ? -1 : 1) * (axisInside ? -1 : 1) * offset) / length(vector));
|
|
3077
2961
|
}
|
|
3078
2962
|
getRelativeVector(point) {
|
|
3079
2963
|
const { center } = this.attribute;
|
|
@@ -4930,6 +4814,7 @@
|
|
|
4930
4814
|
}
|
|
4931
4815
|
const preHandler = vrender.createSymbol({
|
|
4932
4816
|
strokeBoundsBuffer: 0,
|
|
4817
|
+
pickMode: 'imprecise',
|
|
4933
4818
|
...handlerStyle,
|
|
4934
4819
|
x: 0,
|
|
4935
4820
|
y: 0,
|
|
@@ -4960,6 +4845,7 @@
|
|
|
4960
4845
|
container.add(text);
|
|
4961
4846
|
const nextHandler = vrender.createSymbol({
|
|
4962
4847
|
strokeBoundsBuffer: 0,
|
|
4848
|
+
pickMode: 'imprecise',
|
|
4963
4849
|
...handlerStyle,
|
|
4964
4850
|
x: isHorizontal ? handlerSizeX + handlerSpace * 2 + maxTextWidth : 0,
|
|
4965
4851
|
y: isHorizontal ? 0 : handlerSizeY + handlerSpace * 2 + maxTextHeight,
|
|
@@ -5343,11 +5229,21 @@
|
|
|
5343
5229
|
this._itemMaxWidth = Math.max(itemWidth, this._itemMaxWidth);
|
|
5344
5230
|
if (isHorizontal) {
|
|
5345
5231
|
maxPages = maxRow;
|
|
5346
|
-
if (vutils.isValid(maxWidth)
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5232
|
+
if (vutils.isValid(maxWidth)) {
|
|
5233
|
+
if (itemWidth >= maxWidth) {
|
|
5234
|
+
doWrap = true;
|
|
5235
|
+
if (index > 0) {
|
|
5236
|
+
startX = 0;
|
|
5237
|
+
startY += itemHeight + spaceRow;
|
|
5238
|
+
pages += 1;
|
|
5239
|
+
}
|
|
5240
|
+
}
|
|
5241
|
+
else if (maxWidth < startX + itemWidth) {
|
|
5242
|
+
doWrap = true;
|
|
5243
|
+
startX = 0;
|
|
5244
|
+
startY += itemHeight + spaceRow;
|
|
5245
|
+
pages += 1;
|
|
5246
|
+
}
|
|
5351
5247
|
}
|
|
5352
5248
|
if (index > 0) {
|
|
5353
5249
|
itemGroup.setAttributes({
|
|
@@ -5376,10 +5272,11 @@
|
|
|
5376
5272
|
}
|
|
5377
5273
|
itemsContainer.add(itemGroup);
|
|
5378
5274
|
});
|
|
5275
|
+
let pagerRendered = false;
|
|
5379
5276
|
if (doWrap && autoPage && pages > maxPages) {
|
|
5380
|
-
this._renderPager(isHorizontal);
|
|
5277
|
+
pagerRendered = this._renderPager(isHorizontal);
|
|
5381
5278
|
}
|
|
5382
|
-
|
|
5279
|
+
if (!pagerRendered) {
|
|
5383
5280
|
itemsContainer.setAttribute('y', this._title ? this._title.AABBBounds.height() + vutils.get(this.attribute, 'title.space', 8) : 0);
|
|
5384
5281
|
this._innerView.add(itemsContainer);
|
|
5385
5282
|
}
|
|
@@ -5555,6 +5452,10 @@
|
|
|
5555
5452
|
this._innerView.add(pagerComp);
|
|
5556
5453
|
pageHeight = (maxRow - 1) * spaceRow + this._itemHeight * maxRow;
|
|
5557
5454
|
pageWidth = maxWidth - pagerComp.AABBBounds.width() - pagerSpace;
|
|
5455
|
+
if (pageWidth <= 0) {
|
|
5456
|
+
this._innerView.removeChild(pagerComp);
|
|
5457
|
+
return false;
|
|
5458
|
+
}
|
|
5558
5459
|
itemsContainer.getChildren().forEach((item, index) => {
|
|
5559
5460
|
const { width, height } = item.attribute;
|
|
5560
5461
|
if (pageWidth < startX + width) {
|
|
@@ -5586,6 +5487,10 @@
|
|
|
5586
5487
|
this._innerView.add(pagerComp);
|
|
5587
5488
|
pageWidth = this._itemMaxWidth * maxCol + (maxCol - 1) * spaceCol;
|
|
5588
5489
|
pageHeight = maxHeight - pagerComp.AABBBounds.height() - pagerSpace - renderStartY;
|
|
5490
|
+
if (pageHeight <= 0) {
|
|
5491
|
+
this._innerView.removeChild(pagerComp);
|
|
5492
|
+
return false;
|
|
5493
|
+
}
|
|
5589
5494
|
itemsContainer.getChildren().forEach((item, index) => {
|
|
5590
5495
|
const { height } = item.attribute;
|
|
5591
5496
|
if (pageHeight < startY + height) {
|
|
@@ -5645,6 +5550,7 @@
|
|
|
5645
5550
|
};
|
|
5646
5551
|
this._pager.addEventListener('toPrev', onPaging);
|
|
5647
5552
|
this._pager.addEventListener('toNext', onPaging);
|
|
5553
|
+
return true;
|
|
5648
5554
|
}
|
|
5649
5555
|
_onHover = (e) => {
|
|
5650
5556
|
const target = e.target;
|
|
@@ -8060,6 +7966,17 @@
|
|
|
8060
7966
|
}
|
|
8061
7967
|
}
|
|
8062
7968
|
|
|
7969
|
+
exports.IOperateType = void 0;
|
|
7970
|
+
(function (IOperateType) {
|
|
7971
|
+
IOperateType["drawStart"] = "drawStart";
|
|
7972
|
+
IOperateType["drawEnd"] = "drawEnd";
|
|
7973
|
+
IOperateType["drawing"] = "drawing";
|
|
7974
|
+
IOperateType["moving"] = "moving";
|
|
7975
|
+
IOperateType["moveStart"] = "moveStart";
|
|
7976
|
+
IOperateType["moveEnd"] = "moveEnd";
|
|
7977
|
+
IOperateType["brushClear"] = "brushClear";
|
|
7978
|
+
})(exports.IOperateType || (exports.IOperateType = {}));
|
|
7979
|
+
|
|
8063
7980
|
const DEFAULT_BRUSH_ATTRIBUTES = {
|
|
8064
7981
|
brushMode: 'single',
|
|
8065
7982
|
brushType: 'rect',
|
|
@@ -8091,6 +8008,8 @@
|
|
|
8091
8008
|
_container;
|
|
8092
8009
|
_activeDrawState = false;
|
|
8093
8010
|
_cacheDrawPoints = [];
|
|
8011
|
+
_cacheStartTime;
|
|
8012
|
+
_activeClearState = false;
|
|
8094
8013
|
_activeMoveState = false;
|
|
8095
8014
|
_operatingMaskMoveDx = 0;
|
|
8096
8015
|
_operatingMaskMoveDy = 0;
|
|
@@ -8146,12 +8065,12 @@
|
|
|
8146
8065
|
this._activeMoveState && this._moving(e);
|
|
8147
8066
|
};
|
|
8148
8067
|
_onBrushEnd = (e) => {
|
|
8149
|
-
if (this.
|
|
8068
|
+
if (this._activeClearState) {
|
|
8150
8069
|
return;
|
|
8151
8070
|
}
|
|
8152
8071
|
this._updateDragMaskCallback &&
|
|
8153
8072
|
this._updateDragMaskCallback({
|
|
8154
|
-
operateType: this._activeDrawState ?
|
|
8073
|
+
operateType: this._activeDrawState ? exports.IOperateType.drawEnd : exports.IOperateType.moveEnd,
|
|
8155
8074
|
operateMask: this._operatingMask,
|
|
8156
8075
|
operatedMaskAABBBounds: this._brushMaskAABBBoundsDict
|
|
8157
8076
|
});
|
|
@@ -8160,25 +8079,34 @@
|
|
|
8160
8079
|
this._operatingMask.setAttribute('pickable', false);
|
|
8161
8080
|
};
|
|
8162
8081
|
_initDraw(e) {
|
|
8163
|
-
const {
|
|
8082
|
+
const { removeOnClick } = this.attribute;
|
|
8164
8083
|
const pos = this.eventPosToStagePos(e);
|
|
8165
8084
|
this._cacheDrawPoints = [pos];
|
|
8085
|
+
const nowTime = Date.now();
|
|
8166
8086
|
if (!this._operatingMask) {
|
|
8167
8087
|
this._addBrushMask();
|
|
8168
8088
|
}
|
|
8169
|
-
if (
|
|
8089
|
+
if (nowTime - this._cacheStartTime < 200 && removeOnClick) {
|
|
8090
|
+
this._activeClearState = true;
|
|
8170
8091
|
this._container.incrementalClearChild();
|
|
8171
|
-
this.
|
|
8092
|
+
this._updateDragMaskCallback &&
|
|
8093
|
+
this._updateDragMaskCallback({
|
|
8094
|
+
operateType: exports.IOperateType.brushClear,
|
|
8095
|
+
operateMask: this._operatingMask,
|
|
8096
|
+
operatedMaskAABBBounds: this._brushMaskAABBBoundsDict
|
|
8097
|
+
});
|
|
8172
8098
|
}
|
|
8173
|
-
else
|
|
8099
|
+
else {
|
|
8100
|
+
this._activeClearState = false;
|
|
8174
8101
|
this._addBrushMask();
|
|
8102
|
+
this._updateDragMaskCallback &&
|
|
8103
|
+
this._updateDragMaskCallback({
|
|
8104
|
+
operateType: exports.IOperateType.drawStart,
|
|
8105
|
+
operateMask: this._operatingMask,
|
|
8106
|
+
operatedMaskAABBBounds: this._brushMaskAABBBoundsDict
|
|
8107
|
+
});
|
|
8175
8108
|
}
|
|
8176
|
-
this.
|
|
8177
|
-
this._updateDragMaskCallback({
|
|
8178
|
-
operateType: 'brushStart',
|
|
8179
|
-
operateMask: this._operatingMask,
|
|
8180
|
-
operatedMaskAABBBounds: this._brushMaskAABBBoundsDict
|
|
8181
|
-
});
|
|
8109
|
+
this._cacheStartTime = nowTime;
|
|
8182
8110
|
}
|
|
8183
8111
|
_initMove(e) {
|
|
8184
8112
|
this._cacheMovePoint = this.eventPosToStagePos(e);
|
|
@@ -8196,7 +8124,7 @@
|
|
|
8196
8124
|
this._operatingMask.setAttribute('pickable', true);
|
|
8197
8125
|
this._updateDragMaskCallback &&
|
|
8198
8126
|
this._updateDragMaskCallback({
|
|
8199
|
-
operateType:
|
|
8127
|
+
operateType: exports.IOperateType.moveStart,
|
|
8200
8128
|
operateMask: this._operatingMask,
|
|
8201
8129
|
operatedMaskAABBBounds: this._brushMaskAABBBoundsDict
|
|
8202
8130
|
});
|
|
@@ -8215,7 +8143,7 @@
|
|
|
8215
8143
|
this._brushMaskAABBBoundsDict[this._operatingMask.name] = this._operatingMask.AABBBounds;
|
|
8216
8144
|
this._updateDragMaskCallback &&
|
|
8217
8145
|
this._updateDragMaskCallback({
|
|
8218
|
-
operateType:
|
|
8146
|
+
operateType: exports.IOperateType.drawing,
|
|
8219
8147
|
operateMask: this._operatingMask,
|
|
8220
8148
|
operatedMaskAABBBounds: this._brushMaskAABBBoundsDict
|
|
8221
8149
|
});
|
|
@@ -8239,7 +8167,7 @@
|
|
|
8239
8167
|
this._brushMaskAABBBoundsDict[this._operatingMask.name] = this._operatingMask.AABBBounds;
|
|
8240
8168
|
this._updateDragMaskCallback &&
|
|
8241
8169
|
this._updateDragMaskCallback({
|
|
8242
|
-
operateType:
|
|
8170
|
+
operateType: exports.IOperateType.moving,
|
|
8243
8171
|
operateMask: this._operatingMask,
|
|
8244
8172
|
operatedMaskAABBBounds: this._brushMaskAABBBoundsDict
|
|
8245
8173
|
});
|
|
@@ -8718,7 +8646,7 @@
|
|
|
8718
8646
|
}
|
|
8719
8647
|
}
|
|
8720
8648
|
|
|
8721
|
-
const version = "0.12.
|
|
8649
|
+
const version = "0.12.3-alpha.6";
|
|
8722
8650
|
|
|
8723
8651
|
exports.AbstractComponent = AbstractComponent;
|
|
8724
8652
|
exports.BasePlayer = BasePlayer;
|