@visactor/vrender-components 0.22.7-alpha.2 → 0.22.7-alpha.3
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/marker/animate/animate.d.ts +3 -3
- package/cjs/marker/animate/animate.js.map +1 -1
- package/cjs/marker/animate/clip-in.d.ts +1 -1
- package/cjs/marker/animate/clip-in.js +3 -6
- package/cjs/marker/animate/clip-in.js.map +1 -1
- package/cjs/marker/animate/fade-in.d.ts +3 -3
- package/cjs/marker/animate/fade-in.js +4 -10
- package/cjs/marker/animate/fade-in.js.map +1 -1
- package/cjs/marker/animate/fade-out.d.ts +3 -3
- package/cjs/marker/animate/fade-out.js +4 -10
- package/cjs/marker/animate/fade-out.js.map +1 -1
- package/cjs/marker/arc-area.d.ts +5 -8
- package/cjs/marker/arc-area.js +39 -18
- package/cjs/marker/arc-area.js.map +1 -1
- package/cjs/marker/arc-line.d.ts +4 -6
- package/cjs/marker/arc-line.js +9 -12
- package/cjs/marker/arc-line.js.map +1 -1
- package/cjs/marker/area.d.ts +4 -6
- package/cjs/marker/area.js +32 -14
- package/cjs/marker/area.js.map +1 -1
- package/cjs/marker/base.d.ts +3 -2
- package/cjs/marker/base.js.map +1 -1
- package/cjs/marker/common-line.d.ts +7 -11
- package/cjs/marker/common-line.js +31 -11
- package/cjs/marker/common-line.js.map +1 -1
- package/cjs/marker/config.d.ts +0 -2
- package/cjs/marker/config.js +0 -2
- package/cjs/marker/config.js.map +1 -1
- package/cjs/marker/line.d.ts +4 -6
- package/cjs/marker/line.js +4 -10
- package/cjs/marker/line.js.map +1 -1
- package/cjs/marker/type.d.ts +16 -19
- package/cjs/marker/type.js.map +1 -1
- package/cjs/scrollbar/scrollbar.d.ts +1 -0
- package/cjs/scrollbar/scrollbar.js +17 -10
- package/cjs/scrollbar/scrollbar.js.map +1 -1
- package/cjs/slider/slider.d.ts +1 -0
- package/cjs/slider/slider.js +30 -22
- package/cjs/slider/slider.js.map +1 -1
- package/cjs/util/event.d.ts +1 -0
- package/cjs/util/event.js +14 -0
- package/cjs/util/event.js.map +1 -0
- package/dist/index.es.js +160 -195
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/marker/animate/animate.d.ts +3 -3
- package/es/marker/animate/animate.js.map +1 -1
- package/es/marker/animate/clip-in.d.ts +1 -1
- package/es/marker/animate/clip-in.js +2 -6
- package/es/marker/animate/clip-in.js.map +1 -1
- package/es/marker/animate/fade-in.d.ts +3 -3
- package/es/marker/animate/fade-in.js +3 -11
- package/es/marker/animate/fade-in.js.map +1 -1
- package/es/marker/animate/fade-out.d.ts +3 -3
- package/es/marker/animate/fade-out.js +3 -11
- package/es/marker/animate/fade-out.js.map +1 -1
- package/es/marker/arc-area.d.ts +5 -8
- package/es/marker/arc-area.js +41 -19
- package/es/marker/arc-area.js.map +1 -1
- package/es/marker/arc-line.d.ts +4 -6
- package/es/marker/arc-line.js +9 -12
- package/es/marker/arc-line.js.map +1 -1
- package/es/marker/area.d.ts +4 -6
- package/es/marker/area.js +34 -15
- package/es/marker/area.js.map +1 -1
- package/es/marker/base.d.ts +3 -2
- package/es/marker/base.js.map +1 -1
- package/es/marker/common-line.d.ts +7 -11
- package/es/marker/common-line.js +34 -14
- package/es/marker/common-line.js.map +1 -1
- package/es/marker/config.d.ts +0 -2
- package/es/marker/config.js +0 -2
- package/es/marker/config.js.map +1 -1
- package/es/marker/line.d.ts +4 -6
- package/es/marker/line.js +4 -10
- package/es/marker/line.js.map +1 -1
- package/es/marker/type.d.ts +16 -19
- package/es/marker/type.js.map +1 -1
- package/es/scrollbar/scrollbar.d.ts +1 -0
- package/es/scrollbar/scrollbar.js +18 -9
- package/es/scrollbar/scrollbar.js.map +1 -1
- package/es/slider/slider.d.ts +1 -0
- package/es/slider/slider.js +31 -21
- package/es/slider/slider.js.map +1 -1
- package/es/util/event.d.ts +1 -0
- package/es/util/event.js +6 -0
- package/es/util/event.js.map +1 -0
- package/package.json +4 -4
- package/cjs/marker/mixin/label.d.ts +0 -16
- package/cjs/marker/mixin/label.js +0 -57
- package/cjs/marker/mixin/label.js.map +0 -1
- package/es/marker/mixin/label.d.ts +0 -16
- package/es/marker/mixin/label.js +0 -45
- package/es/marker/mixin/label.js.map +0 -1
package/cjs/marker/line.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/marker/line.ts"],"names":[],"mappings":";;;AAAA,6CAAwD;AAKxD,yCAAmD;AAEnD,+CAA+C;AAG/C,wCAAqC;AACrC,0CAA6C;AAC7C,qCAAkH;AAElH,+CAA0D;AAC1D,kCAA0F;AAG1F,IAAA,gCAAqB,GAAE,CAAC;AAExB,SAAgB,uBAAuB;IACrC,QAAQ,CAAC,QAAQ,GAAG,+BAAqB,CAAC;AAC5C,CAAC;AAFD,0DAEC;AAED,MAAa,QAAS,SAAQ,4BAA6D;IAO/E,aAAa,CAAC,KAA2B;QACjD,IAAI,QAAQ,CAAC,QAAQ,IAAI,IAAI,CAAC,gBAAgB,EAAE;YAC9C,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;SAC1E;IACH,CAAC;IAED,YAAY,UAAyB,EAAE,OAA0B;QAC/D,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAb/F,SAAI,GAAG,UAAU,CAAC;IAclB,CAAC;IAES,sBAAsB,CAC9B,QAAgC,EAChC,UAAwD;;QAExD,MAAM,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAA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iBAAiB,CAAC,KAAsB,CAAC,CAAC;IAC5E,CAAC;;AA9IH,4BA+IC;AA5IQ,0BAAiB,GAA2B,gCAAmD,CAAC","file":"line.js","sourcesContent":["import { isValidNumber, merge } from '@visactor/vutils';\nimport type { IMarkLineLabelPosition, MarkerLineLabelAttrs } from './type';\n// eslint-disable-next-line no-duplicate-imports\nimport type { MarkLineAttrs, MarkerAnimationState } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { loadMarkLineComponent } from './register';\nimport type { Point } from '../core/type';\nimport { MarkCommonLine } from './common-line';\nimport type { ArcSegment } from '../segment';\n// eslint-disable-next-line no-duplicate-imports\nimport { Segment } from '../segment';\nimport { DEFAULT_STATES } from '../constant';\nimport { DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP, DEFAULT_MARK_LINE_THEME, FUZZY_EQUAL_DELTA } from './config';\nimport type { IGroup, ILineGraphicAttribute } from '@visactor/vrender-core';\nimport { markCommonLineAnimate } from './animate/animate';\nimport { fuzzyEqualNumber, getTextAlignAttrOfVerticalDir, isPostiveXAxis } from '../util';\nimport type { TagAttributes } from '../tag';\n\nloadMarkLineComponent();\n\nexport function registerMarkLineAnimate() {\n MarkLine._animate = markCommonLineAnimate;\n}\n\nexport class MarkLine extends MarkCommonLine<ILineGraphicAttribute, IMarkLineLabelPosition> {\n name = 'markLine';\n // eslint-disable-next-line max-len\n static defaultAttributes: Partial<MarkLineAttrs> = DEFAULT_MARK_LINE_THEME as unknown as MarkLineAttrs;\n protected _line!: Segment | ArcSegment;\n\n /** animate */\n protected markerAnimate(state: MarkerAnimationState) {\n if (MarkLine._animate && this._animationConfig) {\n MarkLine._animate(this._line, this._label, this._animationConfig, state);\n }\n }\n\n constructor(attributes: MarkLineAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkLine.defaultAttributes, attributes));\n }\n\n protected getPointAttrByPosition(\n position: IMarkLineLabelPosition,\n labelAttrs: MarkerLineLabelAttrs<IMarkLineLabelPosition>\n ) {\n const { refX = 0, refY = 0 } = labelAttrs;\n const points = this._line.getMainSegmentPoints();\n const lineEndAngle = this._line.getEndAngle() ?? 0;\n const labelAngle = isPostiveXAxis(lineEndAngle) ? lineEndAngle : lineEndAngle;\n\n const labelOffsetX = refX * Math.cos(labelAngle) + refY * Math.cos(labelAngle - Math.PI / 2);\n const labelOffsetY = refX * Math.sin(labelAngle) + refY * Math.sin(labelAngle - Math.PI / 2);\n\n if (position.includes('start') || position.includes('Start')) {\n return {\n position: {\n x: points[0].x + labelOffsetX,\n y: points[0].y + labelOffsetY\n },\n angle: labelAngle\n };\n } else if (position.includes('middle') || position.includes('Middle')) {\n return {\n position: {\n x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,\n y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY\n },\n angle: labelAngle\n };\n }\n return {\n position: {\n x: points[points.length - 1].x + labelOffsetX,\n y: points[points.length - 1].y + labelOffsetY\n },\n angle: labelAngle\n };\n }\n\n protected getRotateByAngle(angle: number, labelAttrs: MarkerLineLabelAttrs<IMarkLineLabelPosition>): number {\n const itemAngle = isPostiveXAxis(angle) ? angle : angle - Math.PI;\n return itemAngle + (labelAttrs.refAngle ?? 0);\n }\n\n protected getTextStyle(position: IMarkLineLabelPosition, labelAngle: number, autoRotate: boolean) {\n // 垂直方向例外\n if (\n fuzzyEqualNumber(Math.abs(labelAngle), Math.PI / 2, FUZZY_EQUAL_DELTA) ||\n fuzzyEqualNumber(Math.abs(labelAngle), (Math.PI * 3) / 2, FUZZY_EQUAL_DELTA)\n ) {\n return getTextAlignAttrOfVerticalDir(autoRotate, labelAngle, position);\n }\n\n if (isPostiveXAxis(labelAngle)) {\n return DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP.postiveXAxis[position];\n }\n return DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP.negativeXAxis[position];\n }\n\n protected createSegment() {\n const { points, startSymbol, endSymbol, lineStyle, mainSegmentIndex, multiSegment, state } = this\n .attribute as MarkLineAttrs;\n return new Segment({\n points,\n startSymbol,\n endSymbol,\n lineStyle,\n mainSegmentIndex,\n multiSegment,\n pickable: false, // 组件容器本身不参与拾取\n state: {\n line: merge({}, DEFAULT_STATES, state?.line),\n startSymbol: merge({}, DEFAULT_STATES, state?.lineStartSymbol),\n endSymbol: merge({}, DEFAULT_STATES, state?.lineEndSymbol)\n }\n });\n }\n\n protected setLineAttributes() {\n const { points, startSymbol, endSymbol, lineStyle, mainSegmentIndex, multiSegment, state } = this\n .attribute as MarkLineAttrs;\n if (this._line) {\n this._line.setAttributes({\n points,\n startSymbol,\n endSymbol,\n lineStyle,\n mainSegmentIndex,\n multiSegment,\n state: {\n line: merge({}, DEFAULT_STATES, state?.line),\n startSymbol: merge({}, DEFAULT_STATES, state?.lineStartSymbol),\n endSymbol: merge({}, DEFAULT_STATES, state?.lineEndSymbol)\n }\n });\n }\n }\n\n protected isValidPoints() {\n const { points } = this.attribute as MarkLineAttrs;\n if (!points || points.length < 2) {\n return false;\n }\n let validFlag = true;\n points.forEach((point: Point | Point[]) => {\n if ((point as any).length) {\n (point as Point[]).forEach((p: Point) => {\n if (!isValidNumber((p as Point).x) || !isValidNumber((p as Point).y)) {\n validFlag = false;\n return;\n }\n });\n } else if (!isValidNumber((point as Point).x) || !isValidNumber((point as Point).y)) {\n validFlag = false;\n return;\n }\n });\n return validFlag;\n }\n\n protected addMarkLineLabels(container: IGroup) {\n this._addMarkLabels(container, 'mark-common-line-label', MarkLine.defaultAttributes.label as TagAttributes);\n }\n\n protected updateMarkLineLabels() {\n this._updateMarkLabels(MarkLine.defaultAttributes.label as TagAttributes);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/marker/line.ts"],"names":[],"mappings":";;;AAAA,6CAAwD;AAKxD,yCAAmD;AAEnD,+CAA+C;AAG/C,wCAAqC;AACrC,0CAA6C;AAC7C,qCAAkH;AAElH,+CAA0D;AAC1D,kCAA0F;AAE1F,IAAA,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,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAsB,EAAE,EAAE;YACxC,IAAK,KAAa,CAAC,MAAM,EAAE;gBACxB,KAAiB,CAAC,OAAO,CAAC,CAAC,CAAQ,EAAE,EAAE;oBACtC,IAAI,CAAC,IAAA,sBAAa,EAAE,CAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAA,sBAAa,EAAE,CAAW,CAAC,CAAC,CAAC,EAAE;wBACpE,SAAS,GAAG,KAAK,CAAC;wBAClB,OAAO;qBACR;gBACH,CAAC,CAAC,CAAC;aACJ;iBAAM,IAAI,CAAC,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,EAAE;gBACnF,SAAS,GAAG,KAAK,CAAC;gBAClB,OAAO;aACR;QACH,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;;AApIH,4BAqIC;AAlIQ,0BAAiB,GAA2B,gCAAmD,CAAC","file":"line.js","sourcesContent":["import { isValidNumber, merge } from '@visactor/vutils';\nimport type { IMarkLineLabelPosition } from './type';\n// eslint-disable-next-line no-duplicate-imports\nimport type { MarkLineAttrs, MarkerAnimationState } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { loadMarkLineComponent } from './register';\nimport type { Point } from '../core/type';\nimport { MarkCommonLine } from './common-line';\nimport type { ArcSegment } from '../segment';\n// eslint-disable-next-line no-duplicate-imports\nimport { Segment } from '../segment';\nimport { DEFAULT_STATES } from '../constant';\nimport { DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP, DEFAULT_MARK_LINE_THEME, FUZZY_EQUAL_DELTA } from './config';\nimport type { ILineGraphicAttribute } from '@visactor/vrender-core';\nimport { markCommonLineAnimate } from './animate/animate';\nimport { fuzzyEqualNumber, getTextAlignAttrOfVerticalDir, isPostiveXAxis } from '../util';\n\nloadMarkLineComponent();\n\nexport function registerMarkLineAnimate() {\n MarkLine._animate = markCommonLineAnimate;\n}\n\nexport class MarkLine extends MarkCommonLine<ILineGraphicAttribute, IMarkLineLabelPosition> {\n name = 'markLine';\n // eslint-disable-next-line max-len\n static defaultAttributes: Partial<MarkLineAttrs> = DEFAULT_MARK_LINE_THEME as unknown as MarkLineAttrs;\n protected _line!: Segment | ArcSegment;\n\n /** animate */\n protected markerAnimate(state: MarkerAnimationState) {\n if (MarkLine._animate && this._animationConfig) {\n MarkLine._animate(this._line, this._label, this._animationConfig, state);\n }\n }\n\n constructor(attributes: MarkLineAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkLine.defaultAttributes, attributes));\n }\n\n protected getPointAttrByPosition(position: IMarkLineLabelPosition) {\n const { label = {} } = this.attribute;\n const { refX = 0, refY = 0 } = label;\n const points = this._line.getMainSegmentPoints();\n const lineEndAngle = this._line.getEndAngle() ?? 0;\n const labelAngle = isPostiveXAxis(lineEndAngle) ? lineEndAngle : lineEndAngle;\n\n const labelOffsetX = refX * Math.cos(labelAngle) + refY * Math.cos(labelAngle - Math.PI / 2);\n const labelOffsetY = refX * Math.sin(labelAngle) + refY * Math.sin(labelAngle - Math.PI / 2);\n\n if (position.includes('start') || position.includes('Start')) {\n return {\n position: {\n x: points[0].x + labelOffsetX,\n y: points[0].y + labelOffsetY\n },\n angle: labelAngle\n };\n } else if (position.includes('middle') || position.includes('Middle')) {\n return {\n position: {\n x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,\n y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY\n },\n angle: labelAngle\n };\n }\n return {\n position: {\n x: points[points.length - 1].x + labelOffsetX,\n y: points[points.length - 1].y + labelOffsetY\n },\n angle: labelAngle\n };\n }\n\n protected getRotateByAngle(angle: number): number {\n const itemAngle = isPostiveXAxis(angle) ? angle : angle - Math.PI;\n return itemAngle + (this.attribute.label.refAngle ?? 0);\n }\n\n protected getTextStyle(position: IMarkLineLabelPosition, labelAngle: number, autoRotate: boolean) {\n // 垂直方向例外\n if (\n fuzzyEqualNumber(Math.abs(labelAngle), Math.PI / 2, FUZZY_EQUAL_DELTA) ||\n fuzzyEqualNumber(Math.abs(labelAngle), (Math.PI * 3) / 2, FUZZY_EQUAL_DELTA)\n ) {\n return getTextAlignAttrOfVerticalDir(autoRotate, labelAngle, position);\n }\n\n if (isPostiveXAxis(labelAngle)) {\n return DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP.postiveXAxis[position];\n }\n return DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP.negativeXAxis[position];\n }\n\n protected createSegment() {\n const { points, startSymbol, endSymbol, lineStyle, mainSegmentIndex, multiSegment, state } = this\n .attribute as MarkLineAttrs;\n return new Segment({\n points,\n startSymbol,\n endSymbol,\n lineStyle,\n mainSegmentIndex,\n multiSegment,\n pickable: false, // 组件容器本身不参与拾取\n state: {\n line: merge({}, DEFAULT_STATES, state?.line),\n startSymbol: merge({}, DEFAULT_STATES, state?.lineStartSymbol),\n endSymbol: merge({}, DEFAULT_STATES, state?.lineEndSymbol)\n }\n });\n }\n\n protected setLineAttributes() {\n const { points, startSymbol, endSymbol, lineStyle, mainSegmentIndex, multiSegment, state } = this\n .attribute as MarkLineAttrs;\n if (this._line) {\n this._line.setAttributes({\n points,\n startSymbol,\n endSymbol,\n lineStyle,\n mainSegmentIndex,\n multiSegment,\n state: {\n line: merge({}, DEFAULT_STATES, state?.line),\n startSymbol: merge({}, DEFAULT_STATES, state?.lineStartSymbol),\n endSymbol: merge({}, DEFAULT_STATES, state?.lineEndSymbol)\n }\n });\n }\n }\n\n protected isValidPoints() {\n const { points } = this.attribute as MarkLineAttrs;\n if (!points || points.length < 2) {\n return false;\n }\n let validFlag = true;\n points.forEach((point: Point | Point[]) => {\n if ((point as any).length) {\n (point as Point[]).forEach((p: Point) => {\n if (!isValidNumber((p as Point).x) || !isValidNumber((p as Point).y)) {\n validFlag = false;\n return;\n }\n });\n } else if (!isValidNumber((point as Point).x) || !isValidNumber((point as Point).y)) {\n validFlag = false;\n return;\n }\n });\n return validFlag;\n }\n}\n"]}
|
package/cjs/marker/type.d.ts
CHANGED
|
@@ -107,13 +107,13 @@ export type MarkCommonLineState<LineAttr> = {
|
|
|
107
107
|
line?: State<LineAttr>;
|
|
108
108
|
lineStartSymbol?: State<Partial<ISymbolGraphicAttribute>>;
|
|
109
109
|
lineEndSymbol?: State<Partial<ISymbolGraphicAttribute>>;
|
|
110
|
-
label?: State<Partial<ITextGraphicAttribute
|
|
111
|
-
labelBackground?: State<Partial<IRectGraphicAttribute
|
|
110
|
+
label?: State<Partial<ITextGraphicAttribute>>;
|
|
111
|
+
labelBackground?: State<Partial<IRectGraphicAttribute>>;
|
|
112
112
|
};
|
|
113
113
|
export type CommonMarkAreaState<AreaAttr> = {
|
|
114
114
|
area?: State<Partial<AreaAttr>>;
|
|
115
|
-
label?: State<Partial<ITextGraphicAttribute
|
|
116
|
-
labelBackground?: State<Partial<IRectGraphicAttribute
|
|
115
|
+
label?: State<Partial<ITextGraphicAttribute>>;
|
|
116
|
+
labelBackground?: State<Partial<IRectGraphicAttribute>>;
|
|
117
117
|
};
|
|
118
118
|
export type MarkPointState = {
|
|
119
119
|
line?: State<ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[]>;
|
|
@@ -127,12 +127,11 @@ export type MarkPointState = {
|
|
|
127
127
|
customMark?: State<Partial<IGroupGraphicAttribute>>;
|
|
128
128
|
targetItem?: State<Partial<ISymbolGraphicAttribute>>;
|
|
129
129
|
};
|
|
130
|
-
export type MarkerLineLabelAttrs<LineLabelPosition> = {
|
|
131
|
-
position?: LineLabelPosition;
|
|
132
|
-
confine?: boolean;
|
|
133
|
-
} & IMarkRef & IMarkLabel;
|
|
134
130
|
export type MarkCommonLineAttrs<LineAttr, LineLabelPosition, MarkCommonLineAnimationType> = MarkerAttrs<MarkCommonLineAnimationType> & Omit<CommonSegmentAttributes, 'state' | 'lineStyle'> & {
|
|
135
|
-
label?:
|
|
131
|
+
label?: {
|
|
132
|
+
position?: LineLabelPosition;
|
|
133
|
+
confine?: boolean;
|
|
134
|
+
} & IMarkRef & IMarkLabel;
|
|
136
135
|
state?: MarkCommonLineState<LineAttr>;
|
|
137
136
|
};
|
|
138
137
|
export type MarkLineAttrs = MarkCommonLineAttrs<ILineGraphicWithCornerRadius | ILineGraphicAttribute[], keyof typeof IMarkLineLabelPosition, MarkCommonLineAnimationType> & {
|
|
@@ -153,21 +152,16 @@ export type MarkArcLineAttrs = MarkCommonLineAttrs<IArcGraphicAttribute, keyof t
|
|
|
153
152
|
endAngle: number;
|
|
154
153
|
lineStyle?: IArcGraphicAttribute;
|
|
155
154
|
};
|
|
156
|
-
export type MarkerAreaLabelAttrs = {
|
|
157
|
-
position?: keyof typeof IMarkAreaLabelPosition;
|
|
158
|
-
confine?: boolean;
|
|
159
|
-
} & IMarkLabel;
|
|
160
155
|
export type MarkAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {
|
|
161
156
|
type?: 'area';
|
|
162
157
|
points: Point[];
|
|
163
|
-
label?:
|
|
158
|
+
label?: {
|
|
159
|
+
position?: keyof typeof IMarkAreaLabelPosition;
|
|
160
|
+
confine?: boolean;
|
|
161
|
+
} & IMarkLabel;
|
|
164
162
|
areaStyle?: IPolygonAttribute;
|
|
165
163
|
state?: CommonMarkAreaState<IPolygonGraphicAttribute>;
|
|
166
164
|
};
|
|
167
|
-
export type MarkerArcAreaLabelAttrs = {
|
|
168
|
-
position?: keyof typeof IMarkCommonArcLabelPosition;
|
|
169
|
-
confine?: boolean;
|
|
170
|
-
} & IMarkRef & IMarkLabel;
|
|
171
165
|
export type MarkArcAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {
|
|
172
166
|
type?: 'arc-area';
|
|
173
167
|
center: {
|
|
@@ -178,7 +172,10 @@ export type MarkArcAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {
|
|
|
178
172
|
outerRadius: number;
|
|
179
173
|
startAngle: number;
|
|
180
174
|
endAngle: number;
|
|
181
|
-
label?:
|
|
175
|
+
label?: {
|
|
176
|
+
position?: keyof typeof IMarkCommonArcLabelPosition;
|
|
177
|
+
confine?: boolean;
|
|
178
|
+
} & IMarkRef & IMarkLabel;
|
|
182
179
|
areaStyle?: IArcGraphicAttribute;
|
|
183
180
|
state?: CommonMarkAreaState<IArcGraphicAttribute>;
|
|
184
181
|
};
|
package/cjs/marker/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":";;;AAmBA,IAAY,sBAkBX;AAlBD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,+CAAqB,CAAA;IACrB,qDAA2B,CAAA;IAC3B,qDAA2B,CAAA;IAC3B,2DAAiC,CAAA;IACjC,iEAAuC,CAAA;IAEvC,2CAAiB,CAAA;IACjB,6DAAmC,CAAA;IACnC,mEAAyC,CAAA;IAEzC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,iDAAuB,CAAA;IACvB,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,6DAAmC,CAAA;AACrC,CAAC,EAlBW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAkBjC;AAED,IAAY,sBAoBX;AApBD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,6CAAmB,CAAA;IACnB,+CAAqB,CAAA;IACrB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAE3B,2CAAiB,CAAA;IAEjB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAC3B,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,yDAA+B,CAAA;IAC/B,2DAAiC,CAAA;IACjC,+DAAqC,CAAA;IACrC,iEAAuC,CAAA;AACzC,CAAC,EApBW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAoBjC;AAED,IAAY,2BAQX;AARD,WAAY,2BAA2B;IACrC,8DAA+B,CAAA;IAC/B,0DAA2B,CAAA;IAC3B,gEAAiC,CAAA;IACjC,8DAA+B,CAAA;IAC/B,0DAA2B,CAAA;IAC3B,gEAAiC,CAAA;IACjC,gDAAiB,CAAA;AACnB,CAAC,EARW,2BAA2B,GAA3B,mCAA2B,KAA3B,mCAA2B,QAQtC;AAED,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,uDAA6B,CAAA;AAC/B,CAAC,EAPW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAOjC","file":"type.js","sourcesContent":["import type {\n EasingType,\n IArcGraphicAttribute,\n IGroup,\n IGroupGraphicAttribute,\n IImageGraphicAttribute,\n ILineGraphicAttribute,\n IPolygonAttribute,\n IPolygonGraphicAttribute,\n IRectGraphicAttribute,\n IRichTextGraphicAttribute,\n ISymbol,\n ISymbolGraphicAttribute,\n ITextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { CommonSegmentAttributes, ILineGraphicWithCornerRadius, SegmentAttributes } from '../segment/type';\nimport type { TagAttributes } from '../tag/type';\nimport type { Point, State } from '../core/type';\n\nexport enum IMarkLineLabelPosition {\n start = 'start',\n startTop = 'startTop',\n startBottom = 'startBottom',\n insideStart = 'insideStart',\n insideStartTop = 'insideStartTop',\n insideStartBottom = 'insideStartBottom',\n\n middle = 'middle',\n insideMiddleTop = 'insideMiddleTop',\n insideMiddleBottom = 'insideMiddleBottom',\n\n end = 'end',\n endTop = 'endTop',\n endBottom = 'endBottom',\n insideEnd = 'insideEnd',\n insideEndTop = 'insideEndTop',\n insideEndBottom = 'insideEndBottom'\n}\n\nexport enum IMarkAreaLabelPosition {\n left = 'left',\n right = 'right',\n top = 'top',\n bottom = 'bottom',\n topLeft = 'topLeft',\n topRight = 'topRight',\n bottomLeft = 'bottomLeft',\n bottomRight = 'bottomRight',\n\n middle = 'middle',\n\n insideLeft = 'insideLeft',\n insideRight = 'insideRight',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom',\n insideTopLeft = 'insideTopLeft',\n insideTopRight = 'insideTopRight',\n insideBottomLeft = 'insideBottomLeft',\n insideBottomRight = 'insideBottomRight'\n}\n\nexport enum IMarkCommonArcLabelPosition {\n arcInnerStart = 'arcInnerStart',\n arcInnerEnd = 'arcInnerEnd',\n arcInnerMiddle = 'arcInnerMiddle',\n arcOuterStart = 'arcOuterStart',\n arcOuterEnd = 'arcOuterEnd',\n arcOuterMiddle = 'arcOuterMiddle',\n center = 'center'\n}\n\nexport enum IMarkPointItemPosition {\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom',\n insideMiddle = 'insideMiddle'\n}\n\nexport type IMarkBackgroundAttributes = {\n /**\n * 是否绘制背景层\n */\n visible: boolean;\n /**\n * TODO: 根据文字宽度进行背景 panel size自适应\n */\n autoHeight?: boolean;\n /**\n * TODO: 根据文高度度进行背景 panel size自适应\n */\n autoWidth?: boolean;\n} & Partial<IRectGraphicAttribute>;\n\nexport type IMarkLabel = Omit<TagAttributes, 'x' | 'y' | 'panel'> & {\n /**\n * 标签的背景面板配置\n */\n panel?: IMarkBackgroundAttributes;\n};\n\nexport type IMarkRef = {\n /**\n * 自动旋转,沿着线的方向\n * @default\n * mark-line/mark-area/mark-point: false - 旧逻辑里autoRotate是false, 保持不变\n * mark-arc-line/mark-arc-area: true - 新增逻辑, 如果不开启的话, 效果不太好, 所以默认true\n * mark-point - 旧逻辑里autoRotate是true, 保持不变\n */\n autoRotate?: boolean;\n /**\n * label 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * label 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * label 相对默认角度的偏移 (label跟随line的角度做自动旋转时,默认按照line的平行向量作为初始角度)\n */\n refAngle?: number;\n};\n\nexport type MarkerAttrs<AnimationType> = IGroupGraphicAttribute & {\n /**\n * 设置标注的类型\n */\n type?: 'line' | 'arc-line' | 'area' | 'arc-area' | 'point';\n /**\n * 是否支持交互\n * @default true\n */\n interactive?: boolean;\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 是否显示marker组件\n * @default true\n */\n visible?: boolean;\n /**\n * 是否将组件在绘制区域内进行剪切\n * @default true\n */\n clipInRange?: boolean;\n /**\n * 组件绘制范围配置\n */\n limitRect?: {\n /**\n * 绘制范围的起点x坐标\n */\n x: number;\n /**\n * 绘制范围的起点y坐标\n */\n y: number;\n /**\n * 绘制范围的宽度\n */\n width: number;\n /**\n * 绘制范围的高度\n */\n height: number;\n };\n} & BaseMarkerAnimation<AnimationType>;\n\n/** animation type */\nexport type BaseMarkerAnimation<T> = {\n /**\n * 动画公共配置\n */\n animation?: MarkerAnimation<T> | boolean;\n /**\n * 入场动画配置\n */\n animationEnter?: MarkerUpdateAnimation<T>;\n /**\n * 更新动画配置\n */\n animationUpdate?: MarkerUpdateAnimation<T>;\n /**\n * 离场动画配置\n */\n animationExit?: MarkerExitAnimation;\n};\nexport type MarkerAnimation<T> = MarkerUpdateAnimation<T> | MarkerUpdateAnimation<T>;\n\nexport type MarkerUpdateAnimation<T> = {\n /**\n * 设置动画的类型\n */\n type: T;\n} & MarkerExitAnimation;\n\nexport type MarkCommonLineAnimationType = 'clipIn' | 'fadeIn';\n\nexport type CommonMarkAreaAnimationType = 'fadeIn';\n\nexport type MarkPointAnimationType = 'callIn' | 'fadeIn';\n\nexport type MarkerExitAnimation = {\n /**\n * 设置离场动画的类型为fadeOut,即淡出\n */\n type: 'fadeOut';\n /**\n * 动画的时长\n */\n duration?: number;\n /**\n * 动画延迟的时长\n */\n delay?: number;\n /**\n * 动画的缓动函数\n */\n easing?: EasingType;\n};\n\nexport type MarkerAnimationState = 'enter' | 'update' | 'exit';\n\n/** state type */\nexport type MarkCommonLineState<LineAttr> = {\n /**\n * 设置线图形的在特定状态下的样式\n */\n line?: State<LineAttr>;\n /**\n * 设置线的起点在特定状态下的样式\n */\n lineStartSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置线的终点在特定状态下的样式\n */\n lineEndSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置标签在特定状态下的样式\n * 自 0.22.7 版本开始,支持多标签配置\n */\n label?: State<Partial<ITextGraphicAttribute>> | State<Partial<ITextGraphicAttribute>>[];\n /**\n * 设置标签背景区块在特定状态下的样式\n */\n labelBackground?: State<Partial<IRectGraphicAttribute>> | State<Partial<IRectGraphicAttribute>>[];\n};\n\nexport type CommonMarkAreaState<AreaAttr> = {\n /**\n * 设置标注区域在特定状态下的样式\n */\n area?: State<Partial<AreaAttr>>;\n /**\n * 设置标注区域标签在特定状态下的样式\n * 自 0.22.7 版本开始,支持多标签配置\n */\n label?: State<Partial<ITextGraphicAttribute>> | State<Partial<ITextGraphicAttribute>>[];\n /**\n * 设置标签背景区块在特定状态下的样式\n */\n labelBackground?: State<Partial<IRectGraphicAttribute>> | State<Partial<IRectGraphicAttribute>>[];\n};\n\nexport type MarkPointState = {\n /**\n * 设置标注点连线在特定状态下的样式\n */\n line?: State<ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[]>;\n /**\n * 设置线起点图形在特定状态下的样式\n */\n lineStartSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置线终点图形在特定状态下的样式\n */\n lineEndSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置标注图形在特定状态下的样式\n */\n symbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置标注图形在特定状态下的样式\n */\n image?: State<Partial<IImageGraphicAttribute>>;\n /**\n * 设置标签在特定状态下的样式\n */\n text?: State<Partial<ITextGraphicAttribute>>;\n /**\n * 设置标签背景区块在特定状态下的样式\n */\n textBackground?: State<Partial<IRectGraphicAttribute>>;\n /**\n * 设置富文本在特定状态下的样式\n */\n richText?: State<Partial<IRichTextGraphicAttribute>>;\n /**\n * 设置自定义标注图形在特定状态下的样式\n */\n customMark?: State<Partial<IGroupGraphicAttribute>>;\n /**\n * 设置目标元素在特定状态下的样式\n */\n targetItem?: State<Partial<ISymbolGraphicAttribute>>;\n};\n\nexport type MarkerLineLabelAttrs<LineLabelPosition> = {\n /**\n * label 相对line的位置\n */\n position?: LineLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n} & IMarkRef &\n IMarkLabel;\n\nexport type MarkCommonLineAttrs<LineAttr, LineLabelPosition, MarkCommonLineAnimationType> =\n MarkerAttrs<MarkCommonLineAnimationType> &\n Omit<CommonSegmentAttributes, 'state' | 'lineStyle'> & {\n /**\n * 标签\n * 自 0.22.7 版本开始,支持多标签配置\n */\n label?: MarkerLineLabelAttrs<LineLabelPosition> | MarkerLineLabelAttrs<LineLabelPosition>[];\n /**\n * 辅助线各种状态下的样式\n */\n state?: MarkCommonLineState<LineAttr>;\n };\n\nexport type MarkLineAttrs = MarkCommonLineAttrs<\n ILineGraphicWithCornerRadius | ILineGraphicAttribute[],\n keyof typeof IMarkLineLabelPosition,\n MarkCommonLineAnimationType\n> & {\n /**\n * 将辅助线的类型设置为 'line'\n */\n type?: 'line';\n /**\n * 是否对 points 进行多段处理,默认为 false,即直接将所有的点连接成线。\n * 如果需要进行多段处理,需要将 points 属性配置为 Point[][] 类型\n * @default false\n */\n multiSegment?: boolean;\n /**\n * 在 `multiSegment` 属性开启的前提下,用于声明那一段线段用来作为主线段,如果不声明,默认全段为主线段\n */\n mainSegmentIndex?: number;\n /**\n * 构成line的点: 如果是两个点,则为直线;多个点则为折线\n */\n points: Point[] | Point[][];\n /**\n * 线的样式设置\n */\n lineStyle?: ILineGraphicAttribute;\n};\n\nexport type MarkArcLineAttrs = MarkCommonLineAttrs<\n IArcGraphicAttribute,\n keyof typeof IMarkCommonArcLabelPosition,\n MarkCommonLineAnimationType\n> & {\n /**\n * 将辅助线的类型设置为 'arc-line',即弧线\n */\n type?: 'arc-line';\n /**\n * 弧线中心位置\n */\n center: {\n x: number;\n y: number;\n };\n /**\n * 弧线半径\n */\n radius: number;\n /**\n * 弧线起始角度(弧度)\n */\n startAngle: number;\n /**\n * 弧线终点角度(弧度)\n */\n endAngle: number;\n /**\n * 设置弧线的样式\n */\n lineStyle?: IArcGraphicAttribute;\n};\n\nexport type MarkerAreaLabelAttrs = {\n /**\n * 设置标签的位置\n */\n position?: keyof typeof IMarkAreaLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n} & IMarkLabel;\n\nexport type MarkAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {\n type?: 'area';\n /**\n * 构成area的点\n */\n points: Point[];\n /**\n * 标签\n * 自 0.22.7 版本开始,支持多标签配置\n */\n label?: MarkerAreaLabelAttrs | MarkerAreaLabelAttrs[];\n /**\n * area的样式\n */\n areaStyle?: IPolygonAttribute;\n /**\n * 设置标注区域在各种状态下的样式\n */\n state?: CommonMarkAreaState<IPolygonGraphicAttribute>;\n};\n\nexport type MarkerArcAreaLabelAttrs = {\n /**\n * 标签的位置\n */\n position?: keyof typeof IMarkCommonArcLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n} & IMarkRef &\n IMarkLabel;\n\nexport type MarkArcAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {\n type?: 'arc-area';\n /**\n * 扇区中心位置\n */\n center: {\n x: number;\n y: number;\n };\n /**\n * 扇区内半径\n */\n innerRadius: number;\n /**\n * 扇区外半径\n */\n outerRadius: number;\n /**\n * 扇区起始角度(弧度)\n */\n startAngle: number;\n /**\n * 扇区终点角度(弧度)\n */\n endAngle: number;\n /**\n * 标签\n * 自 0.22.7 版本开始,支持多标签配置\n */\n label?: MarkerArcAreaLabelAttrs | MarkerArcAreaLabelAttrs[];\n /**\n * area的样式\n */\n areaStyle?: IArcGraphicAttribute;\n /**\n * 辅助区域这种状态下各个图元的样式设置\n */\n state?: CommonMarkAreaState<IArcGraphicAttribute>;\n};\n\nexport type IItemContent = IMarkRef & {\n /**\n * 标注类型\n * Tips: 保留'richText'与之前的定义做兼容\n */\n type?: 'symbol' | 'text' | 'image' | 'richText' | 'custom';\n /**\n * 设置标注的位置\n */\n position?: keyof typeof IMarkPointItemPosition;\n /**\n * x 方向偏移量\n */\n offsetX?: number;\n /**\n * y 方向偏移量\n */\n offsetY?: number;\n /**\n * type为symbol时, symbol的样式\n */\n symbolStyle?: ISymbolGraphicAttribute;\n /**\n * type为image时, image的样式\n */\n imageStyle?: IImageGraphicAttribute;\n /**\n * type为text时, text的配置\n * 'text'类型的ItemContent新增三种子类型:'text','rich','html'。配置在textStyle.type上,继承自TagAttributes。\n */\n textStyle?: IMarkLabel;\n /**\n * type为rich text时, rich text的样式\n */\n richTextStyle?: IRichTextGraphicAttribute;\n /**\n * type为custom时,允许以callback的方式传入需要render的item\n */\n renderCustomCallback?: () => IGroup;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n};\n\nexport type IItemLine = {\n /** TODO:'type-opo' */\n type?: 'type-s' | 'type-do' | 'type-po' | 'type-op' | 'type-arc';\n /**\n * 是否展示该标注\n */\n visible?: boolean;\n /**\n * 当type为type-arc时生效, 数值决定曲率, 符号决定法向, 不能等于0\n * @default 0.8\n */\n arcRatio?: number;\n /**\n * 垂直于引导线的装饰线,参考案例: https://observablehq.com/@mikelotis/edmonton-population-history-line-chart\n */\n decorativeLine?: {\n /**\n * 是否显示引导线的装饰线\n */\n visible?: boolean;\n /**\n * 装饰线的长度\n */\n length?: number;\n };\n} & Omit<SegmentAttributes, 'points'>;\n\nexport type MarkPointAttrs = Omit<MarkerAttrs<MarkPointAnimationType>, 'labelStyle'> & {\n /**\n * markPoint的位置(也是path的起点)\n */\n position: Point;\n /**\n * 标注引导线\n */\n itemLine?: IItemLine;\n\n /**\n * 标注内容\n */\n itemContent?: IItemContent;\n\n /**\n * 被标注的内容\n */\n targetSymbol?: {\n /**\n * 被标注内容与标记线间的间隙\n * @default 0\n */\n offset?: number;\n /**\n * 是否显示\n * @default false\n */\n visible?: boolean;\n /**\n * 大小\n * @default 20\n */\n size?: number;\n /**\n * 被标注内容的样式设置\n */\n style?: ISymbol;\n };\n /**\n * 标注点各个状态下的样式\n */\n state?: MarkPointState;\n} & BaseMarkerAnimation<MarkPointAnimationType>;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":";;;AAmBA,IAAY,sBAkBX;AAlBD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,+CAAqB,CAAA;IACrB,qDAA2B,CAAA;IAC3B,qDAA2B,CAAA;IAC3B,2DAAiC,CAAA;IACjC,iEAAuC,CAAA;IAEvC,2CAAiB,CAAA;IACjB,6DAAmC,CAAA;IACnC,mEAAyC,CAAA;IAEzC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,iDAAuB,CAAA;IACvB,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,6DAAmC,CAAA;AACrC,CAAC,EAlBW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAkBjC;AAED,IAAY,sBAoBX;AApBD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,6CAAmB,CAAA;IACnB,+CAAqB,CAAA;IACrB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAE3B,2CAAiB,CAAA;IAEjB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAC3B,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,yDAA+B,CAAA;IAC/B,2DAAiC,CAAA;IACjC,+DAAqC,CAAA;IACrC,iEAAuC,CAAA;AACzC,CAAC,EApBW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAoBjC;AAED,IAAY,2BAQX;AARD,WAAY,2BAA2B;IACrC,8DAA+B,CAAA;IAC/B,0DAA2B,CAAA;IAC3B,gEAAiC,CAAA;IACjC,8DAA+B,CAAA;IAC/B,0DAA2B,CAAA;IAC3B,gEAAiC,CAAA;IACjC,gDAAiB,CAAA;AACnB,CAAC,EARW,2BAA2B,GAA3B,mCAA2B,KAA3B,mCAA2B,QAQtC;AAED,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,uDAA6B,CAAA;AAC/B,CAAC,EAPW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAOjC","file":"type.js","sourcesContent":["import type {\n EasingType,\n IArcGraphicAttribute,\n IGroup,\n IGroupGraphicAttribute,\n IImageGraphicAttribute,\n ILineGraphicAttribute,\n IPolygonAttribute,\n IPolygonGraphicAttribute,\n IRectGraphicAttribute,\n IRichTextGraphicAttribute,\n ISymbol,\n ISymbolGraphicAttribute,\n ITextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { CommonSegmentAttributes, ILineGraphicWithCornerRadius, SegmentAttributes } from '../segment/type';\nimport type { TagAttributes } from '../tag/type';\nimport type { Point, State } from '../core/type';\n\nexport enum IMarkLineLabelPosition {\n start = 'start',\n startTop = 'startTop',\n startBottom = 'startBottom',\n insideStart = 'insideStart',\n insideStartTop = 'insideStartTop',\n insideStartBottom = 'insideStartBottom',\n\n middle = 'middle',\n insideMiddleTop = 'insideMiddleTop',\n insideMiddleBottom = 'insideMiddleBottom',\n\n end = 'end',\n endTop = 'endTop',\n endBottom = 'endBottom',\n insideEnd = 'insideEnd',\n insideEndTop = 'insideEndTop',\n insideEndBottom = 'insideEndBottom'\n}\n\nexport enum IMarkAreaLabelPosition {\n left = 'left',\n right = 'right',\n top = 'top',\n bottom = 'bottom',\n topLeft = 'topLeft',\n topRight = 'topRight',\n bottomLeft = 'bottomLeft',\n bottomRight = 'bottomRight',\n\n middle = 'middle',\n\n insideLeft = 'insideLeft',\n insideRight = 'insideRight',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom',\n insideTopLeft = 'insideTopLeft',\n insideTopRight = 'insideTopRight',\n insideBottomLeft = 'insideBottomLeft',\n insideBottomRight = 'insideBottomRight'\n}\n\nexport enum IMarkCommonArcLabelPosition {\n arcInnerStart = 'arcInnerStart',\n arcInnerEnd = 'arcInnerEnd',\n arcInnerMiddle = 'arcInnerMiddle',\n arcOuterStart = 'arcOuterStart',\n arcOuterEnd = 'arcOuterEnd',\n arcOuterMiddle = 'arcOuterMiddle',\n center = 'center'\n}\n\nexport enum IMarkPointItemPosition {\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom',\n insideMiddle = 'insideMiddle'\n}\n\nexport type IMarkBackgroundAttributes = {\n /**\n * 是否绘制背景层\n */\n visible: boolean;\n /**\n * TODO: 根据文字宽度进行背景 panel size自适应\n */\n autoHeight?: boolean;\n /**\n * TODO: 根据文高度度进行背景 panel size自适应\n */\n autoWidth?: boolean;\n} & Partial<IRectGraphicAttribute>;\n\nexport type IMarkLabel = Omit<TagAttributes, 'x' | 'y' | 'panel'> & {\n /**\n * 标签的背景面板配置\n */\n panel?: IMarkBackgroundAttributes;\n};\n\nexport type IMarkRef = {\n /**\n * 自动旋转,沿着线的方向\n * @default\n * mark-line/mark-area/mark-point: false - 旧逻辑里autoRotate是false, 保持不变\n * mark-arc-line/mark-arc-area: true - 新增逻辑, 如果不开启的话, 效果不太好, 所以默认true\n * mark-point - 旧逻辑里autoRotate是true, 保持不变\n */\n autoRotate?: boolean;\n /**\n * label 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * label 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * label 相对默认角度的偏移 (label跟随line的角度做自动旋转时,默认按照line的平行向量作为初始角度)\n */\n refAngle?: number;\n};\n\nexport type MarkerAttrs<AnimationType> = IGroupGraphicAttribute & {\n /**\n * 设置标注的类型\n */\n type?: 'line' | 'arc-line' | 'area' | 'arc-area' | 'point';\n /**\n * 是否支持交互\n * @default true\n */\n interactive?: boolean;\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 是否显示marker组件\n * @default true\n */\n visible?: boolean;\n /**\n * 是否将组件在绘制区域内进行剪切\n * @default true\n */\n clipInRange?: boolean;\n /**\n * 组件绘制范围配置\n */\n limitRect?: {\n /**\n * 绘制范围的起点x坐标\n */\n x: number;\n /**\n * 绘制范围的起点y坐标\n */\n y: number;\n /**\n * 绘制范围的宽度\n */\n width: number;\n /**\n * 绘制范围的高度\n */\n height: number;\n };\n} & BaseMarkerAnimation<AnimationType>;\n\n/** animation type */\nexport type BaseMarkerAnimation<T> = {\n /**\n * 动画公共配置\n */\n animation?: MarkerAnimation<T> | boolean;\n /**\n * 入场动画配置\n */\n animationEnter?: MarkerUpdateAnimation<T>;\n /**\n * 更新动画配置\n */\n animationUpdate?: MarkerUpdateAnimation<T>;\n /**\n * 离场动画配置\n */\n animationExit?: MarkerExitAnimation;\n};\nexport type MarkerAnimation<T> = MarkerUpdateAnimation<T> | MarkerUpdateAnimation<T>;\n\nexport type MarkerUpdateAnimation<T> = {\n /**\n * 设置动画的类型\n */\n type: T;\n} & MarkerExitAnimation;\n\nexport type MarkCommonLineAnimationType = 'clipIn' | 'fadeIn';\n\nexport type CommonMarkAreaAnimationType = 'fadeIn';\n\nexport type MarkPointAnimationType = 'callIn' | 'fadeIn';\n\nexport type MarkerExitAnimation = {\n /**\n * 设置离场动画的类型为fadeOut,即淡出\n */\n type: 'fadeOut';\n /**\n * 动画的时长\n */\n duration?: number;\n /**\n * 动画延迟的时长\n */\n delay?: number;\n /**\n * 动画的缓动函数\n */\n easing?: EasingType;\n};\n\nexport type MarkerAnimationState = 'enter' | 'update' | 'exit';\n\n/** state type */\nexport type MarkCommonLineState<LineAttr> = {\n /**\n * 设置线图形的在特定状态下的样式\n */\n line?: State<LineAttr>;\n /**\n * 设置线的起点在特定状态下的样式\n */\n lineStartSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置线的终点在特定状态下的样式\n */\n lineEndSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置标签在特定状态下的样式\n */\n label?: State<Partial<ITextGraphicAttribute>>;\n /**\n * 设置标签背景区块在特定状态下的样式\n */\n labelBackground?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type CommonMarkAreaState<AreaAttr> = {\n /**\n * 设置标注区域在特定状态下的样式\n */\n area?: State<Partial<AreaAttr>>;\n /**\n * 设置标注区域标签在特定状态下的样式\n */\n label?: State<Partial<ITextGraphicAttribute>>;\n /**\n * 设置标签背景区块在特定状态下的样式\n */\n labelBackground?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type MarkPointState = {\n /**\n * 设置标注点连线在特定状态下的样式\n */\n line?: State<ILineGraphicWithCornerRadius | Partial<ILineGraphicAttribute>[]>;\n /**\n * 设置线起点图形在特定状态下的样式\n */\n lineStartSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置线终点图形在特定状态下的样式\n */\n lineEndSymbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置标注图形在特定状态下的样式\n */\n symbol?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * 设置标注图形在特定状态下的样式\n */\n image?: State<Partial<IImageGraphicAttribute>>;\n /**\n * 设置标签在特定状态下的样式\n */\n text?: State<Partial<ITextGraphicAttribute>>;\n /**\n * 设置标签背景区块在特定状态下的样式\n */\n textBackground?: State<Partial<IRectGraphicAttribute>>;\n /**\n * 设置富文本在特定状态下的样式\n */\n richText?: State<Partial<IRichTextGraphicAttribute>>;\n /**\n * 设置自定义标注图形在特定状态下的样式\n */\n customMark?: State<Partial<IGroupGraphicAttribute>>;\n /**\n * 设置目标元素在特定状态下的样式\n */\n targetItem?: State<Partial<ISymbolGraphicAttribute>>;\n};\n\nexport type MarkCommonLineAttrs<LineAttr, LineLabelPosition, MarkCommonLineAnimationType> =\n MarkerAttrs<MarkCommonLineAnimationType> &\n Omit<CommonSegmentAttributes, 'state' | 'lineStyle'> & {\n /**\n * 标签\n */\n label?: {\n /**\n * label 相对line的位置\n */\n position?: LineLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkRef &\n IMarkLabel;\n /**\n * 辅助线各种状态下的样式\n */\n state?: MarkCommonLineState<LineAttr>;\n };\n\nexport type MarkLineAttrs = MarkCommonLineAttrs<\n ILineGraphicWithCornerRadius | ILineGraphicAttribute[],\n keyof typeof IMarkLineLabelPosition,\n MarkCommonLineAnimationType\n> & {\n /**\n * 将辅助线的类型设置为 'line'\n */\n type?: 'line';\n /**\n * 是否对 points 进行多段处理,默认为 false,即直接将所有的点连接成线。\n * 如果需要进行多段处理,需要将 points 属性配置为 Point[][] 类型\n * @default false\n */\n multiSegment?: boolean;\n /**\n * 在 `multiSegment` 属性开启的前提下,用于声明那一段线段用来作为主线段,如果不声明,默认全段为主线段\n */\n mainSegmentIndex?: number;\n /**\n * 构成line的点: 如果是两个点,则为直线;多个点则为折线\n */\n points: Point[] | Point[][];\n /**\n * 线的样式设置\n */\n lineStyle?: ILineGraphicAttribute;\n};\n\nexport type MarkArcLineAttrs = MarkCommonLineAttrs<\n IArcGraphicAttribute,\n keyof typeof IMarkCommonArcLabelPosition,\n MarkCommonLineAnimationType\n> & {\n /**\n * 将辅助线的类型设置为 'arc-line',即弧线\n */\n type?: 'arc-line';\n /**\n * 弧线中心位置\n */\n center: {\n x: number;\n y: number;\n };\n /**\n * 弧线半径\n */\n radius: number;\n /**\n * 弧线起始角度(弧度)\n */\n startAngle: number;\n /**\n * 弧线终点角度(弧度)\n */\n endAngle: number;\n /**\n * 设置弧线的样式\n */\n lineStyle?: IArcGraphicAttribute;\n};\n\nexport type MarkAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {\n type?: 'area';\n /**\n * 构成area的点\n */\n points: Point[];\n /**\n * 标签\n */\n label?: {\n /**\n * 设置标签的位置\n */\n position?: keyof typeof IMarkAreaLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IPolygonAttribute;\n /**\n * 设置标注区域在各种状态下的样式\n */\n state?: CommonMarkAreaState<IPolygonGraphicAttribute>;\n};\n\nexport type MarkArcAreaAttrs = MarkerAttrs<CommonMarkAreaAnimationType> & {\n type?: 'arc-area';\n /**\n * 扇区中心位置\n */\n center: {\n x: number;\n y: number;\n };\n /**\n * 扇区内半径\n */\n innerRadius: number;\n /**\n * 扇区外半径\n */\n outerRadius: number;\n /**\n * 扇区起始角度(弧度)\n */\n startAngle: number;\n /**\n * 扇区终点角度(弧度)\n */\n endAngle: number;\n /**\n * 标签\n */\n label?: {\n /**\n * 标签的位置\n */\n position?: keyof typeof IMarkCommonArcLabelPosition;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n } & IMarkRef &\n IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IArcGraphicAttribute;\n /**\n * 辅助区域这种状态下各个图元的样式设置\n */\n state?: CommonMarkAreaState<IArcGraphicAttribute>;\n};\n\nexport type IItemContent = IMarkRef & {\n /**\n * 标注类型\n * Tips: 保留'richText'与之前的定义做兼容\n */\n type?: 'symbol' | 'text' | 'image' | 'richText' | 'custom';\n /**\n * 设置标注的位置\n */\n position?: keyof typeof IMarkPointItemPosition;\n /**\n * x 方向偏移量\n */\n offsetX?: number;\n /**\n * y 方向偏移量\n */\n offsetY?: number;\n /**\n * type为symbol时, symbol的样式\n */\n symbolStyle?: ISymbolGraphicAttribute;\n /**\n * type为image时, image的样式\n */\n imageStyle?: IImageGraphicAttribute;\n /**\n * type为text时, text的配置\n * 'text'类型的ItemContent新增三种子类型:'text','rich','html'。配置在textStyle.type上,继承自TagAttributes。\n */\n textStyle?: IMarkLabel;\n /**\n * type为rich text时, rich text的样式\n */\n richTextStyle?: IRichTextGraphicAttribute;\n /**\n * type为custom时,允许以callback的方式传入需要render的item\n */\n renderCustomCallback?: () => IGroup;\n /**\n * 当 mark 配置了 limitRect 之后,label 是否自动调整位置\n * @default false\n */\n confine?: boolean;\n};\n\nexport type IItemLine = {\n /** TODO:'type-opo' */\n type?: 'type-s' | 'type-do' | 'type-po' | 'type-op' | 'type-arc';\n /**\n * 是否展示该标注\n */\n visible?: boolean;\n /**\n * 当type为type-arc时生效, 数值决定曲率, 符号决定法向, 不能等于0\n * @default 0.8\n */\n arcRatio?: number;\n /**\n * 垂直于引导线的装饰线,参考案例: https://observablehq.com/@mikelotis/edmonton-population-history-line-chart\n */\n decorativeLine?: {\n /**\n * 是否显示引导线的装饰线\n */\n visible?: boolean;\n /**\n * 装饰线的长度\n */\n length?: number;\n };\n} & Omit<SegmentAttributes, 'points'>;\n\nexport type MarkPointAttrs = Omit<MarkerAttrs<MarkPointAnimationType>, 'labelStyle'> & {\n /**\n * markPoint的位置(也是path的起点)\n */\n position: Point;\n /**\n * 标注引导线\n */\n itemLine?: IItemLine;\n\n /**\n * 标注内容\n */\n itemContent?: IItemContent;\n\n /**\n * 被标注的内容\n */\n targetSymbol?: {\n /**\n * 被标注内容与标记线间的间隙\n * @default 0\n */\n offset?: number;\n /**\n * 是否显示\n * @default false\n */\n visible?: boolean;\n /**\n * 大小\n * @default 20\n */\n size?: number;\n /**\n * 被标注内容的样式设置\n */\n style?: ISymbol;\n };\n /**\n * 标注点各个状态下的样式\n */\n state?: MarkPointState;\n} & BaseMarkerAnimation<MarkPointAnimationType>;\n"]}
|
|
@@ -49,6 +49,7 @@ export declare class ScrollBar extends AbstractComponent<Required<ScrollBarAttri
|
|
|
49
49
|
private _computeScrollValue;
|
|
50
50
|
private _onSliderPointerMove;
|
|
51
51
|
private _onSliderPointerMoveWithDelay;
|
|
52
|
+
private _clearDragEvents;
|
|
52
53
|
private _onSliderPointerUp;
|
|
53
54
|
private _reset;
|
|
54
55
|
}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.ScrollBar = void 0;
|
|
6
6
|
|
|
7
|
-
const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), register_1 = require("./register"), constant_1 = require("../constant"), delayMap = {
|
|
7
|
+
const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), register_1 = require("./register"), constant_1 = require("../constant"), event_1 = require("../util/event"), delayMap = {
|
|
8
8
|
debounce: vutils_1.debounce,
|
|
9
9
|
throttle: vutils_1.throttle
|
|
10
10
|
};
|
|
@@ -27,17 +27,20 @@ class ScrollBar extends base_1.AbstractComponent {
|
|
|
27
27
|
this.setScrollRange([ currentScrollValue - (range[1] - range[0]) / 2, currentScrollValue + (range[1] - range[0]) / 2 ], !1),
|
|
28
28
|
this.stage && !this.stage.autoRender && this.stage.renderNextFrame();
|
|
29
29
|
}, this._onSliderPointerDown = e => {
|
|
30
|
+
this._clearDragEvents();
|
|
30
31
|
const {stopSliderDownPropagation: stopSliderDownPropagation = !0} = this.attribute;
|
|
31
32
|
stopSliderDownPropagation && e.stopPropagation();
|
|
32
33
|
const {direction: direction} = this.attribute, {x: x, y: y} = this.stage.eventPointTransform(e);
|
|
33
34
|
this._prePos = "horizontal" === direction ? x : y, this._dispatchEvent(constant_1.SCROLLBAR_START_EVENT, {
|
|
34
35
|
pos: this._prePos,
|
|
35
36
|
event: e
|
|
36
|
-
})
|
|
37
|
+
});
|
|
38
|
+
const triggers = (0, event_1.getEndTriggersOfDrag)(), obj = "browser" === vrender_core_1.vglobal.env ? vrender_core_1.vglobal : this.stage;
|
|
39
|
+
obj.addEventListener("pointermove", this._onSliderPointerMoveWithDelay, {
|
|
37
40
|
capture: !0
|
|
38
|
-
}),
|
|
39
|
-
|
|
40
|
-
})
|
|
41
|
+
}), triggers.forEach((trigger => {
|
|
42
|
+
obj.addEventListener(trigger, this._onSliderPointerUp);
|
|
43
|
+
}));
|
|
41
44
|
}, this._computeScrollValue = e => {
|
|
42
45
|
const {direction: direction} = this.attribute, {x: x, y: y} = this.stage.eventPointTransform(e);
|
|
43
46
|
let currentScrollValue, currentPos, delta = 0;
|
|
@@ -58,11 +61,7 @@ class ScrollBar extends base_1.AbstractComponent {
|
|
|
58
61
|
this._dispatchEvent(constant_1.SCROLLBAR_END_EVENT, {
|
|
59
62
|
pre: preRange,
|
|
60
63
|
value: (0, vutils_1.clampRange)(range, limitRange[0], limitRange[1])
|
|
61
|
-
}),
|
|
62
|
-
capture: !0
|
|
63
|
-
}), vrender_core_1.vglobal.removeEventListener("pointerup", this._onSliderPointerUp)) : (this.stage.removeEventListener("pointermove", this._onSliderPointerMoveWithDelay, {
|
|
64
|
-
capture: !0
|
|
65
|
-
}), this.stage.removeEventListener("pointerup", this._onSliderPointerUp), this.stage.removeEventListener("pointerupoutside", this._onSliderPointerUp));
|
|
64
|
+
}), this._clearDragEvents();
|
|
66
65
|
};
|
|
67
66
|
}
|
|
68
67
|
setScrollRange(range, render = !0) {
|
|
@@ -163,6 +162,14 @@ class ScrollBar extends base_1.AbstractComponent {
|
|
|
163
162
|
return "horizontal" === direction ? (0, vutils_1.clampRange)([ x1 + min * width, x1 + max * width ], x1, width - sliderSize) : (0,
|
|
164
163
|
vutils_1.clampRange)([ y1 + min * height, y1 + max * height ], y1, height - sliderSize);
|
|
165
164
|
}
|
|
165
|
+
_clearDragEvents() {
|
|
166
|
+
const triggers = (0, event_1.getEndTriggersOfDrag)(), obj = "browser" === vrender_core_1.vglobal.env ? vrender_core_1.vglobal : this.stage;
|
|
167
|
+
obj.removeEventListener("pointermove", this._onSliderPointerMoveWithDelay, {
|
|
168
|
+
capture: !0
|
|
169
|
+
}), triggers.forEach((trigger => {
|
|
170
|
+
obj.removeEventListener(trigger, this._onSliderPointerUp);
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
166
173
|
_reset() {
|
|
167
174
|
this._sliderRenderBounds = null, this._sliderLimitRange = null;
|
|
168
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/scrollbar/scrollbar.ts"],"names":[],"mappings":";;;AAKA,yDAAiD;AACjD,6CAAkG;AAClG,uCAAiD;AAIjD,yCAAoD;AACpD,0CAA0F;AAW1F,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,iBAAQ;IAClB,QAAQ,EAAE,iBAAQ;CACnB,CAAC;AAEF,IAAA,iCAAsB,GAAE,CAAC;AAEzB,MAAa,SAAU,SAAQ,wBAAgD;IAmC7E,YAAY,UAA+B,EAAE,OAA0B;QACrE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,SAAS,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAnChG,SAAI,GAAG,WAAW,CAAC;QAsPX,uBAAkB,GAAG,CAAC,CAAwB,EAAE,EAAE;YAGxD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YAC3B,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,SAAgC,CAAC;YAClF,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;YACpC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1C,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U,EAAC,CAAC,EAAE,GAAG,GAAG,GAAG,MAAM,EAAE,EAAE,GAAG,GAAG,GAAG,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;IAClF,CAAC;IAiHO,MAAM;QACZ,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAChC,CAAC;;AAzWH,8BA0WC;AAvWQ,2BAAiB,GAAG;IACzB,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,EAAE;IACd,WAAW,EAAE;QACX,IAAI,EAAE,mBAAmB;KAC1B;IACD,SAAS,EAAE;QACT,IAAI,EAAE,mBAAmB;KAC1B;IACD,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACnB,SAAS,EAAE,UAAU;IACrB,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,IAAI;CACf,CAAC","file":"scrollbar.js","sourcesContent":["/**\n * @description 滚动条组件\n */\nimport type { IRectGraphicAttribute, FederatedPointerEvent, IGroup, IRect } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { vglobal } from '@visactor/vrender-core';\nimport { merge, normalizePadding, clamp, clampRange, debounce, throttle } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\n\nimport type { ScrollBarAttributes } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { loadScrollbarComponent } from './register';\nimport { SCROLLBAR_START_EVENT, SCROLLBAR_EVENT, SCROLLBAR_END_EVENT } from '../constant';\n\ntype ComponentBounds = {\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n width: number;\n height: number;\n};\n\nconst delayMap = {\n debounce: debounce,\n throttle: throttle\n};\n\nloadScrollbarComponent();\n\nexport class ScrollBar extends AbstractComponent<Required<ScrollBarAttributes>> {\n name = 'scrollbar';\n\n static defaultAttributes = {\n direction: 'horizontal',\n round: true,\n sliderSize: 20,\n sliderStyle: {\n fill: 'rgba(0, 0, 0, .5)'\n },\n railStyle: {\n fill: 'rgba(0, 0, 0, .0)'\n },\n padding: 2,\n scrollRange: [0, 1],\n delayType: 'throttle',\n delayTime: 0,\n realTime: true\n };\n\n private _container!: IGroup;\n // 滚动条滑块\n private _slider!: IRect;\n // 滚动条滑轨\n private _rail!: IRect;\n // 滑块可渲染的区域包围盒\n private _sliderRenderBounds!: ComponentBounds | null;\n // 滑块滑动的范围\n private _sliderLimitRange!: [number, number] | null;\n // 保留滑块上一次的位置\n private _prePos!: number;\n // TODO: 临时方案\n private _viewPosition!: { x: number; y: number };\n private _sliderSize!: number;\n\n constructor(attributes: ScrollBarAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, ScrollBar.defaultAttributes, attributes));\n }\n\n setScrollRange(range: [number, number], render = true) {\n const {\n direction = 'horizontal',\n limitRange = [0, 1],\n range: preRange,\n realTime = true\n } = this.attribute as ScrollBarAttributes;\n\n const currScrollRange = clampRange(range, limitRange[0], limitRange[1]);\n if (render) {\n // 更新图形\n const sliderPos = this._getSliderPos(currScrollRange);\n if (this._slider) {\n const sliderSize = sliderPos[1] - sliderPos[0];\n this._sliderSize = sliderSize;\n\n if (direction === 'horizontal') {\n this._slider.setAttributes(\n {\n x: sliderPos[0],\n width: sliderSize\n },\n true\n );\n } else {\n this._slider.setAttributes(\n {\n y: sliderPos[0],\n height: sliderSize\n },\n true\n );\n }\n\n if (this.stage && !this.stage.autoRender) {\n this.stage.renderNextFrame();\n }\n }\n }\n (this.attribute as ScrollBarAttributes).range = currScrollRange;\n // 发射 change 事件\n if (realTime) {\n this._dispatchEvent(SCROLLBAR_EVENT, {\n pre: preRange,\n value: currScrollRange\n });\n }\n }\n\n getScrollRange(): [number, number] {\n return (this.attribute as ScrollBarAttributes).range;\n }\n\n // public setLocation(point: PointLocationCfg) {\n // this.translateTo(point.x, point.y);\n // }\n\n // 绑定事件\n protected bindEvents(): void {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n const { delayType = 'throttle', delayTime = 0 } = this.attribute as ScrollBarAttributes;\n // TODO: wheel 事件支持\n if (this._rail) {\n this._rail.addEventListener(\n 'pointerdown',\n delayMap[delayType](this._onRailPointerDown, delayTime) as EventListener\n );\n }\n if (this._slider) {\n this._slider.addEventListener('pointerdown', this._onSliderPointerDown as EventListener);\n }\n }\n\n protected render() {\n this._reset();\n const {\n direction = 'horizontal',\n width,\n height,\n range,\n limitRange = [0, 1],\n // sliderSize = 20,\n // scrollValue = 0,\n // scrollRange = [0, 1],\n railStyle,\n sliderStyle,\n padding = 2\n } = this.attribute as ScrollBarAttributes;\n\n const group = this.createOrUpdateChild('scrollbar-container', {}, 'group') as IGroup;\n // 绘制轨道\n\n const rail = group.createOrUpdateChild(\n 'scrollbar-rail',\n {\n x: 0,\n y: 0,\n width,\n height,\n ...railStyle\n },\n 'rect'\n ) as IRect;\n this._rail = rail;\n\n // 滑块\n const sliderRenderBounds = this.getSliderRenderBounds();\n const sliderPos = this._getSliderPos(clampRange(range, limitRange[0], limitRange[1]));\n const sliderSize = sliderPos[1] - sliderPos[0];\n this._sliderSize = sliderSize;\n // const sliderRangePos = this._getScrollRange();\n\n let sliderAttribute: IRectGraphicAttribute;\n if (direction === 'horizontal') {\n sliderAttribute = {\n x: sliderPos[0],\n y: sliderRenderBounds.y1,\n width: sliderSize,\n height: sliderRenderBounds.height\n };\n } else {\n sliderAttribute = {\n x: sliderRenderBounds.x1,\n y: sliderPos[0],\n width: sliderRenderBounds.width,\n height: sliderSize\n };\n }\n\n const slider = group.createOrUpdateChild(\n 'slider',\n {\n ...sliderAttribute,\n cornerRadius: this._getDefaultSliderCornerRadius(),\n ...sliderStyle,\n boundsPadding: normalizePadding(padding),\n pickMode: 'imprecise'\n },\n 'rect'\n ) as IRect;\n this._slider = slider;\n this._container = group;\n\n const containerAABBBounds = this._container.AABBBounds;\n this._viewPosition = {\n x: containerAABBBounds.x1,\n y: containerAABBBounds.y1\n };\n }\n\n // 获取滑块渲染的包围盒区域\n getSliderRenderBounds() {\n if (this._sliderRenderBounds) {\n return this._sliderRenderBounds;\n }\n const { width, height, padding = 2 } = this.attribute as ScrollBarAttributes;\n const [top, right, bottom, left] = normalizePadding(padding);\n const renderBounds = {\n x1: left,\n y1: top,\n x2: width - right,\n y2: height - bottom,\n width: Math.max(0, width - (left + right)),\n height: Math.max(0, height - (top + bottom))\n };\n this._sliderRenderBounds = renderBounds;\n return renderBounds;\n }\n\n // 获取默认的滑块圆角\n private _getDefaultSliderCornerRadius() {\n const { direction, round } = this.attribute as ScrollBarAttributes;\n\n if (round) {\n const { width, height } = this.getSliderRenderBounds();\n return direction === 'horizontal' ? height : width;\n }\n\n return 0;\n }\n\n // 计算滑块在轨道的位置\n private _getSliderPos(range: [number, number]) {\n const { direction } = this.attribute as ScrollBarAttributes;\n const { width, height, x1, y1 } = this.getSliderRenderBounds();\n\n if (direction === 'horizontal') {\n return [width * range[0] + x1, width * range[1] + x1];\n }\n return [height * range[0] + y1, height * range[1] + y1];\n }\n\n private _getScrollRange() {\n if (this._sliderLimitRange) {\n return this._sliderLimitRange;\n }\n const { limitRange = [0, 1], direction } = this.attribute as ScrollBarAttributes;\n const [min, max] = clampRange(limitRange, 0, 1);\n const { width, height, x1, y1 } = this.getSliderRenderBounds();\n const sliderSize = this._sliderSize;\n\n return direction === 'horizontal'\n ? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)\n : clampRange([y1 + min * height, y1 + max * height], y1, height - sliderSize);\n }\n\n private _onRailPointerDown = (e: FederatedPointerEvent) => {\n // 将事件坐标转换为实际的滑块位置\n // TODO: 这里有问题,应该拿 viewX viewY,同时 graphic 要提供接口获取它的 相对 view 的坐标\n const { viewX, viewY } = e;\n const { direction, width, height, range } = this.attribute as ScrollBarAttributes;\n const sliderSize = this._sliderSize;\n const [min, max] = this._getScrollRange();\n let currentScrollValue;\n if (direction === 'vertical') {\n const relativeY = viewY - this._viewPosition.y;\n const currentYPos = clamp(relativeY - sliderSize / 2, min, max);\n currentScrollValue = relativeY / height;\n this._slider.setAttribute('y', currentYPos, true);\n } else {\n const relativeX = viewX - this._viewPosition.x;\n const currentXPos = clamp(relativeX - sliderSize / 2, min, max);\n currentScrollValue = relativeX / width;\n this._slider.setAttribute('x', currentXPos, true);\n }\n\n this.setScrollRange(\n [currentScrollValue - (range[1] - range[0]) / 2, currentScrollValue + (range[1] - range[0]) / 2],\n false\n );\n\n if (this.stage && !this.stage.autoRender) {\n this.stage.renderNextFrame();\n }\n };\n\n private _onSliderPointerDown = (e: FederatedPointerEvent) => {\n const { stopSliderDownPropagation = true } = this.attribute as ScrollBarAttributes;\n if (stopSliderDownPropagation) {\n e.stopPropagation();\n }\n const { direction } = this.attribute as ScrollBarAttributes;\n const { x, y } = this.stage.eventPointTransform(e);\n this._prePos = direction === 'horizontal' ? x : y;\n this._dispatchEvent(SCROLLBAR_START_EVENT, {\n pos: this._prePos,\n event: e\n });\n if (vglobal.env === 'browser') {\n vglobal.addEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n vglobal.addEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.addEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n this.stage.addEventListener('pointerup', this._onSliderPointerUp);\n this.stage.addEventListener('pointerupoutside', this._onSliderPointerUp);\n }\n };\n\n private _computeScrollValue = (e: any) => {\n const { direction } = this.attribute as ScrollBarAttributes;\n const { x, y } = this.stage.eventPointTransform(e);\n\n let currentScrollValue;\n let currentPos;\n let delta = 0;\n\n const { width, height } = this.getSliderRenderBounds();\n if (direction === 'vertical') {\n currentPos = y;\n delta = currentPos - this._prePos;\n currentScrollValue = delta / height;\n } else {\n currentPos = x;\n delta = currentPos - this._prePos;\n currentScrollValue = delta / width;\n }\n return [currentPos, currentScrollValue];\n };\n\n private _onSliderPointerMove = (e: any) => {\n const { stopSliderMovePropagation = true } = this.attribute as ScrollBarAttributes;\n if (stopSliderMovePropagation) {\n e.stopPropagation();\n }\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n this.setScrollRange([preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue], true);\n this._prePos = currentPos;\n };\n\n private _onSliderPointerMoveWithDelay =\n this.attribute.delayTime === 0\n ? this._onSliderPointerMove\n : delayMap[this.attribute.delayType](this._onSliderPointerMove, this.attribute.delayTime);\n\n private _onSliderPointerUp = (e: any) => {\n e.preventDefault();\n const { range: preRange, limitRange = [0, 1] } = this.attribute as ScrollBarAttributes;\n // 发射 change 事件\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n const range: [number, number] = [preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue];\n\n this._dispatchEvent(SCROLLBAR_END_EVENT, {\n pre: preRange,\n value: clampRange(range, limitRange[0], limitRange[1])\n });\n if (vglobal.env === 'browser') {\n vglobal.removeEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n vglobal.removeEventListener('pointerup', this._onSliderPointerUp);\n } else {\n this.stage.removeEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n this.stage.removeEventListener('pointerup', this._onSliderPointerUp);\n this.stage.removeEventListener('pointerupoutside', this._onSliderPointerUp);\n }\n };\n\n private _reset() {\n this._sliderRenderBounds = null;\n this._sliderLimitRange = null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/scrollbar/scrollbar.ts"],"names":[],"mappings":";;;AAKA,yDAAiD;AACjD,6CAAkG;AAClG,uCAAiD;AAIjD,yCAAoD;AACpD,0CAA0F;AAC1F,yCAAqD;AAWrD,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,iBAAQ;IAClB,QAAQ,EAAE,iBAAQ;CACnB,CAAC;AAEF,IAAA,iCAAsB,GAAE,CAAC;AAEzB,MAAa,SAAU,SAAQ,wBAAgD;IAmC7E,YAAY,UAA+B,EAAE,OAA0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GAAG,GAAG,GAAG,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;IAClF,CAAC;IA4FO,gBAAgB;QACtB,MAAM,QAAQ,GAAG,IAAA,4BAAoB,GAAE,CAAC;QACxC,MAAM,GAAG,GAAG,sBAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,sBAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;QAE7D,GAAG,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,6BAA6B,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9F,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAe,EAAE,EAAE;YACnC,GAAG,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC;IAkBO,MAAM;QACZ,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAChC,CAAC;;AA9WH,8BA+WC;AA5WQ,2BAAiB,GAAG;IACzB,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,EAAE;IACd,WAAW,EAAE;QACX,IAAI,EAAE,mBAAmB;KAC1B;IACD,SAAS,EAAE;QACT,IAAI,EAAE,mBAAmB;KAC1B;IACD,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACnB,SAAS,EAAE,UAAU;IACrB,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,IAAI;CACf,CAAC","file":"scrollbar.js","sourcesContent":["/**\n * @description 滚动条组件\n */\nimport type { IRectGraphicAttribute, FederatedPointerEvent, IGroup, IRect } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { vglobal } from '@visactor/vrender-core';\nimport { merge, normalizePadding, clamp, clampRange, debounce, throttle } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\n\nimport type { ScrollBarAttributes } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { loadScrollbarComponent } from './register';\nimport { SCROLLBAR_START_EVENT, SCROLLBAR_EVENT, SCROLLBAR_END_EVENT } from '../constant';\nimport { getEndTriggersOfDrag } from '../util/event';\n\ntype ComponentBounds = {\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n width: number;\n height: number;\n};\n\nconst delayMap = {\n debounce: debounce,\n throttle: throttle\n};\n\nloadScrollbarComponent();\n\nexport class ScrollBar extends AbstractComponent<Required<ScrollBarAttributes>> {\n name = 'scrollbar';\n\n static defaultAttributes = {\n direction: 'horizontal',\n round: true,\n sliderSize: 20,\n sliderStyle: {\n fill: 'rgba(0, 0, 0, .5)'\n },\n railStyle: {\n fill: 'rgba(0, 0, 0, .0)'\n },\n padding: 2,\n scrollRange: [0, 1],\n delayType: 'throttle',\n delayTime: 0,\n realTime: true\n };\n\n private _container!: IGroup;\n // 滚动条滑块\n private _slider!: IRect;\n // 滚动条滑轨\n private _rail!: IRect;\n // 滑块可渲染的区域包围盒\n private _sliderRenderBounds!: ComponentBounds | null;\n // 滑块滑动的范围\n private _sliderLimitRange!: [number, number] | null;\n // 保留滑块上一次的位置\n private _prePos!: number;\n // TODO: 临时方案\n private _viewPosition!: { x: number; y: number };\n private _sliderSize!: number;\n\n constructor(attributes: ScrollBarAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, ScrollBar.defaultAttributes, attributes));\n }\n\n setScrollRange(range: [number, number], render = true) {\n const {\n direction = 'horizontal',\n limitRange = [0, 1],\n range: preRange,\n realTime = true\n } = this.attribute as ScrollBarAttributes;\n\n const currScrollRange = clampRange(range, limitRange[0], limitRange[1]);\n if (render) {\n // 更新图形\n const sliderPos = this._getSliderPos(currScrollRange);\n if (this._slider) {\n const sliderSize = sliderPos[1] - sliderPos[0];\n this._sliderSize = sliderSize;\n\n if (direction === 'horizontal') {\n this._slider.setAttributes(\n {\n x: sliderPos[0],\n width: sliderSize\n },\n true\n );\n } else {\n this._slider.setAttributes(\n {\n y: sliderPos[0],\n height: sliderSize\n },\n true\n );\n }\n\n if (this.stage && !this.stage.autoRender) {\n this.stage.renderNextFrame();\n }\n }\n }\n (this.attribute as ScrollBarAttributes).range = currScrollRange;\n // 发射 change 事件\n if (realTime) {\n this._dispatchEvent(SCROLLBAR_EVENT, {\n pre: preRange,\n value: currScrollRange\n });\n }\n }\n\n getScrollRange(): [number, number] {\n return (this.attribute as ScrollBarAttributes).range;\n }\n\n // public setLocation(point: PointLocationCfg) {\n // this.translateTo(point.x, point.y);\n // }\n\n // 绑定事件\n protected bindEvents(): void {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n const { delayType = 'throttle', delayTime = 0 } = this.attribute as ScrollBarAttributes;\n // TODO: wheel 事件支持\n if (this._rail) {\n this._rail.addEventListener(\n 'pointerdown',\n delayMap[delayType](this._onRailPointerDown, delayTime) as EventListener\n );\n }\n if (this._slider) {\n this._slider.addEventListener('pointerdown', this._onSliderPointerDown as EventListener);\n }\n }\n\n protected render() {\n this._reset();\n const {\n direction = 'horizontal',\n width,\n height,\n range,\n limitRange = [0, 1],\n // sliderSize = 20,\n // scrollValue = 0,\n // scrollRange = [0, 1],\n railStyle,\n sliderStyle,\n padding = 2\n } = this.attribute as ScrollBarAttributes;\n\n const group = this.createOrUpdateChild('scrollbar-container', {}, 'group') as IGroup;\n // 绘制轨道\n\n const rail = group.createOrUpdateChild(\n 'scrollbar-rail',\n {\n x: 0,\n y: 0,\n width,\n height,\n ...railStyle\n },\n 'rect'\n ) as IRect;\n this._rail = rail;\n\n // 滑块\n const sliderRenderBounds = this.getSliderRenderBounds();\n const sliderPos = this._getSliderPos(clampRange(range, limitRange[0], limitRange[1]));\n const sliderSize = sliderPos[1] - sliderPos[0];\n this._sliderSize = sliderSize;\n // const sliderRangePos = this._getScrollRange();\n\n let sliderAttribute: IRectGraphicAttribute;\n if (direction === 'horizontal') {\n sliderAttribute = {\n x: sliderPos[0],\n y: sliderRenderBounds.y1,\n width: sliderSize,\n height: sliderRenderBounds.height\n };\n } else {\n sliderAttribute = {\n x: sliderRenderBounds.x1,\n y: sliderPos[0],\n width: sliderRenderBounds.width,\n height: sliderSize\n };\n }\n\n const slider = group.createOrUpdateChild(\n 'slider',\n {\n ...sliderAttribute,\n cornerRadius: this._getDefaultSliderCornerRadius(),\n ...sliderStyle,\n boundsPadding: normalizePadding(padding),\n pickMode: 'imprecise'\n },\n 'rect'\n ) as IRect;\n this._slider = slider;\n this._container = group;\n\n const containerAABBBounds = this._container.AABBBounds;\n this._viewPosition = {\n x: containerAABBBounds.x1,\n y: containerAABBBounds.y1\n };\n }\n\n // 获取滑块渲染的包围盒区域\n getSliderRenderBounds() {\n if (this._sliderRenderBounds) {\n return this._sliderRenderBounds;\n }\n const { width, height, padding = 2 } = this.attribute as ScrollBarAttributes;\n const [top, right, bottom, left] = normalizePadding(padding);\n const renderBounds = {\n x1: left,\n y1: top,\n x2: width - right,\n y2: height - bottom,\n width: Math.max(0, width - (left + right)),\n height: Math.max(0, height - (top + bottom))\n };\n this._sliderRenderBounds = renderBounds;\n return renderBounds;\n }\n\n // 获取默认的滑块圆角\n private _getDefaultSliderCornerRadius() {\n const { direction, round } = this.attribute as ScrollBarAttributes;\n\n if (round) {\n const { width, height } = this.getSliderRenderBounds();\n return direction === 'horizontal' ? height : width;\n }\n\n return 0;\n }\n\n // 计算滑块在轨道的位置\n private _getSliderPos(range: [number, number]) {\n const { direction } = this.attribute as ScrollBarAttributes;\n const { width, height, x1, y1 } = this.getSliderRenderBounds();\n\n if (direction === 'horizontal') {\n return [width * range[0] + x1, width * range[1] + x1];\n }\n return [height * range[0] + y1, height * range[1] + y1];\n }\n\n private _getScrollRange() {\n if (this._sliderLimitRange) {\n return this._sliderLimitRange;\n }\n const { limitRange = [0, 1], direction } = this.attribute as ScrollBarAttributes;\n const [min, max] = clampRange(limitRange, 0, 1);\n const { width, height, x1, y1 } = this.getSliderRenderBounds();\n const sliderSize = this._sliderSize;\n\n return direction === 'horizontal'\n ? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)\n : clampRange([y1 + min * height, y1 + max * height], y1, height - sliderSize);\n }\n\n private _onRailPointerDown = (e: FederatedPointerEvent) => {\n // 将事件坐标转换为实际的滑块位置\n // TODO: 这里有问题,应该拿 viewX viewY,同时 graphic 要提供接口获取它的 相对 view 的坐标\n const { viewX, viewY } = e;\n const { direction, width, height, range } = this.attribute as ScrollBarAttributes;\n const sliderSize = this._sliderSize;\n const [min, max] = this._getScrollRange();\n let currentScrollValue;\n if (direction === 'vertical') {\n const relativeY = viewY - this._viewPosition.y;\n const currentYPos = clamp(relativeY - sliderSize / 2, min, max);\n currentScrollValue = relativeY / height;\n this._slider.setAttribute('y', currentYPos, true);\n } else {\n const relativeX = viewX - this._viewPosition.x;\n const currentXPos = clamp(relativeX - sliderSize / 2, min, max);\n currentScrollValue = relativeX / width;\n this._slider.setAttribute('x', currentXPos, true);\n }\n\n this.setScrollRange(\n [currentScrollValue - (range[1] - range[0]) / 2, currentScrollValue + (range[1] - range[0]) / 2],\n false\n );\n\n if (this.stage && !this.stage.autoRender) {\n this.stage.renderNextFrame();\n }\n };\n\n private _onSliderPointerDown = (e: FederatedPointerEvent) => {\n this._clearDragEvents();\n const { stopSliderDownPropagation = true } = this.attribute as ScrollBarAttributes;\n if (stopSliderDownPropagation) {\n e.stopPropagation();\n }\n const { direction } = this.attribute as ScrollBarAttributes;\n const { x, y } = this.stage.eventPointTransform(e);\n this._prePos = direction === 'horizontal' ? x : y;\n this._dispatchEvent(SCROLLBAR_START_EVENT, {\n pos: this._prePos,\n event: e\n });\n\n const triggers = getEndTriggersOfDrag();\n const obj = vglobal.env === 'browser' ? vglobal : this.stage;\n\n obj.addEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n triggers.forEach((trigger: string) => {\n obj.addEventListener(trigger, this._onSliderPointerUp);\n });\n };\n\n private _computeScrollValue = (e: any) => {\n const { direction } = this.attribute as ScrollBarAttributes;\n const { x, y } = this.stage.eventPointTransform(e);\n\n let currentScrollValue;\n let currentPos;\n let delta = 0;\n\n const { width, height } = this.getSliderRenderBounds();\n if (direction === 'vertical') {\n currentPos = y;\n delta = currentPos - this._prePos;\n currentScrollValue = delta / height;\n } else {\n currentPos = x;\n delta = currentPos - this._prePos;\n currentScrollValue = delta / width;\n }\n return [currentPos, currentScrollValue];\n };\n\n private _onSliderPointerMove = (e: any) => {\n const { stopSliderMovePropagation = true } = this.attribute as ScrollBarAttributes;\n if (stopSliderMovePropagation) {\n e.stopPropagation();\n }\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n this.setScrollRange([preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue], true);\n this._prePos = currentPos;\n };\n\n private _onSliderPointerMoveWithDelay =\n this.attribute.delayTime === 0\n ? this._onSliderPointerMove\n : delayMap[this.attribute.delayType](this._onSliderPointerMove, this.attribute.delayTime);\n\n private _clearDragEvents() {\n const triggers = getEndTriggersOfDrag();\n const obj = vglobal.env === 'browser' ? vglobal : this.stage;\n\n obj.removeEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n triggers.forEach((trigger: string) => {\n obj.removeEventListener(trigger, this._onSliderPointerUp);\n });\n }\n\n private _onSliderPointerUp = (e: any) => {\n e.preventDefault();\n const { range: preRange, limitRange = [0, 1] } = this.attribute as ScrollBarAttributes;\n // 发射 change 事件\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n const range: [number, number] = [preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue];\n\n this._dispatchEvent(SCROLLBAR_END_EVENT, {\n pre: preRange,\n value: clampRange(range, limitRange[0], limitRange[1])\n });\n\n this._clearDragEvents();\n };\n\n private _reset() {\n this._sliderRenderBounds = null;\n this._sliderLimitRange = null;\n }\n}\n"]}
|
package/cjs/slider/slider.d.ts
CHANGED
|
@@ -109,6 +109,7 @@ export declare class Slider extends AbstractComponent<Required<SliderAttributes>
|
|
|
109
109
|
private _onTooltipUpdate;
|
|
110
110
|
private _onTooltipHide;
|
|
111
111
|
private _onHandlerPointerdown;
|
|
112
|
+
private _clearAllDragEvents;
|
|
112
113
|
private _onHandlerPointerMove;
|
|
113
114
|
private _onHandlerPointerUp;
|
|
114
115
|
private _onTrackPointerdown;
|
package/cjs/slider/slider.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.Slider = void 0;
|
|
6
6
|
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), vrender_core_1 = require("@visactor/vrender-core"), base_1 = require("../core/base"), constant_1 = require("./constant"), register_1 = require("./register");
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), vrender_core_1 = require("@visactor/vrender-core"), base_1 = require("../core/base"), constant_1 = require("./constant"), register_1 = require("./register"), event_1 = require("../util/event");
|
|
8
8
|
|
|
9
9
|
function convertValueToRange(value) {
|
|
10
10
|
return (0, vutils_1.isArray)(value) ? value : [ value, value ];
|
|
@@ -51,13 +51,15 @@ class Slider extends base_1.AbstractComponent {
|
|
|
51
51
|
tooltip && tooltip.alwaysShow || (this._tooltipState = null, this._tooltipShape && this._tooltipShape.setAttribute("visible", !1),
|
|
52
52
|
this._tooltipText && this._tooltipText.setAttribute("visible", !1), this._dispatchTooltipEvent("sliderTooltipHide"));
|
|
53
53
|
}, this._onHandlerPointerdown = e => {
|
|
54
|
-
e.stopPropagation(), this._isChanging = !0;
|
|
54
|
+
e.stopPropagation(), this._clearAllDragEvents(), this._isChanging = !0;
|
|
55
55
|
const {x: x, y: y} = this.stage.eventPointTransform(e);
|
|
56
|
-
this._currentHandler = e.target, this._prePos = this._isHorizontal ? x : y
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
this._currentHandler = e.target, this._prePos = this._isHorizontal ? x : y;
|
|
57
|
+
const triggers = (0, event_1.getEndTriggersOfDrag)(), obj = "browser" === vrender_core_1.vglobal.env ? vrender_core_1.vglobal : this.stage;
|
|
58
|
+
obj.addEventListener("pointermove", this._onHandlerPointerMove, {
|
|
59
59
|
capture: !0
|
|
60
|
-
}),
|
|
60
|
+
}), triggers.forEach((trigger => {
|
|
61
|
+
obj.addEventListener(trigger, this._onHandlerPointerUp);
|
|
62
|
+
}));
|
|
61
63
|
}, this._onHandlerPointerMove = e => {
|
|
62
64
|
var _a, _b;
|
|
63
65
|
e.stopPropagation(), this._isChanging = !0;
|
|
@@ -72,19 +74,17 @@ class Slider extends base_1.AbstractComponent {
|
|
|
72
74
|
"text" === this._currentHandler.type ? this._updateHandlerText(this._currentHandler, newPos, currentValue) : this._updateHandler(this._currentHandler, newPos, currentValue),
|
|
73
75
|
this._updateTrack(), this._prePos = currentPos, this._dispatchChangeEvent();
|
|
74
76
|
}, this._onHandlerPointerUp = e => {
|
|
75
|
-
e.preventDefault(), this._isChanging = !1, this._currentHandler = null,
|
|
76
|
-
capture: !0
|
|
77
|
-
}), vrender_core_1.vglobal.removeEventListener("pointerup", this._onHandlerPointerUp)) : (this.stage.removeEventListener("pointermove", this._onHandlerPointerMove, {
|
|
78
|
-
capture: !0
|
|
79
|
-
}), this.stage.removeEventListener("pointerup", this._onHandlerPointerUp), this.stage.removeEventListener("pointerupoutside", this._onHandlerPointerUp));
|
|
77
|
+
e.preventDefault(), this._isChanging = !1, this._currentHandler = null, this._clearAllDragEvents();
|
|
80
78
|
}, this._onTrackPointerdown = e => {
|
|
81
|
-
e.stopPropagation(), this._isChanging = !0;
|
|
79
|
+
e.stopPropagation(), this._clearAllDragEvents(), this._isChanging = !0;
|
|
82
80
|
const {x: x, y: y} = this.stage.eventPointTransform(e);
|
|
83
|
-
this._prePos = this._isHorizontal ? x : y
|
|
81
|
+
this._prePos = this._isHorizontal ? x : y;
|
|
82
|
+
const triggers = (0, event_1.getEndTriggersOfDrag)(), obj = "browser" === vrender_core_1.vglobal.env ? vrender_core_1.vglobal : this.stage;
|
|
83
|
+
obj.addEventListener("pointermove", this._onTrackPointerMove, {
|
|
84
84
|
capture: !0
|
|
85
|
-
}),
|
|
86
|
-
|
|
87
|
-
})
|
|
85
|
+
}), triggers.forEach((trigger => {
|
|
86
|
+
obj.addEventListener(trigger, this._onTrackPointerUp);
|
|
87
|
+
}));
|
|
88
88
|
}, this._onTrackPointerMove = e => {
|
|
89
89
|
e.stopPropagation(), this._isChanging = !0;
|
|
90
90
|
const {railWidth: railWidth, railHeight: railHeight, min: min, max: max, inverse: inverse} = this.attribute;
|
|
@@ -113,13 +113,9 @@ class Slider extends base_1.AbstractComponent {
|
|
|
113
113
|
}
|
|
114
114
|
this._prePos = currentPos, this._dispatchChangeEvent();
|
|
115
115
|
}, this._onTrackPointerUp = e => {
|
|
116
|
-
e.preventDefault(), this._isChanging = !1,
|
|
117
|
-
capture: !0
|
|
118
|
-
}), vrender_core_1.vglobal.removeEventListener("pointerup", this._onTrackPointerUp)) : (this.stage.removeEventListener("pointermove", this._onTrackPointerMove, {
|
|
119
|
-
capture: !0
|
|
120
|
-
}), this.stage.removeEventListener("pointerup", this._onTrackPointerUp), this.stage.removeEventListener("pointerupoutside", this._onTrackPointerUp));
|
|
116
|
+
e.preventDefault(), this._isChanging = !1, this._clearAllDragEvents();
|
|
121
117
|
}, this._onRailPointerDown = e => {
|
|
122
|
-
e.stopPropagation(), this._isChanging = !0;
|
|
118
|
+
e.stopPropagation(), this._clearAllDragEvents(), this._isChanging = !0;
|
|
123
119
|
const {railWidth: railWidth, railHeight: railHeight, min: min, max: max} = this.attribute;
|
|
124
120
|
if (max === min) return;
|
|
125
121
|
const startHandler = this._startHandler, endHandler = this._endHandler;
|
|
@@ -371,6 +367,18 @@ class Slider extends base_1.AbstractComponent {
|
|
|
371
367
|
this.attribute.disableTriggerEvent || (this._mainContainer.addEventListener("pointerenter", this._onTooltipShow),
|
|
372
368
|
this._mainContainer.addEventListener("pointermove", this._onTooltipUpdate), this._mainContainer.addEventListener("pointerleave", this._onTooltipHide));
|
|
373
369
|
}
|
|
370
|
+
_clearAllDragEvents() {
|
|
371
|
+
const triggers = (0, event_1.getEndTriggersOfDrag)(), obj = "browser" === vrender_core_1.vglobal.env ? vrender_core_1.vglobal : this.stage;
|
|
372
|
+
obj.removeEventListener("pointermove", this._onHandlerPointerMove, {
|
|
373
|
+
capture: !0
|
|
374
|
+
}), triggers.forEach((trigger => {
|
|
375
|
+
obj.removeEventListener(trigger, this._onHandlerPointerUp);
|
|
376
|
+
})), obj.removeEventListener("pointermove", this._onTrackPointerMove, {
|
|
377
|
+
capture: !0
|
|
378
|
+
}), triggers.forEach((trigger => {
|
|
379
|
+
obj.removeEventListener(trigger, this._onTrackPointerUp);
|
|
380
|
+
}));
|
|
381
|
+
}
|
|
374
382
|
_updateTrack() {
|
|
375
383
|
const {inverse: inverse, railWidth: railWidth, railHeight: railHeight} = this.attribute, startHandler = this._startHandler, endHandler = this._endHandler;
|
|
376
384
|
if (this._isHorizontal) {
|