@visactor/vrender-components 0.20.5 → 0.20.6-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/axis/util.js +1 -2
- package/cjs/brush/type.js +2 -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.js +6 -2
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/legend/discrete/type.d.ts +1 -0
- package/cjs/legend/discrete/type.js.map +1 -1
- package/cjs/scrollbar/scrollbar.d.ts +10 -1
- package/cjs/scrollbar/scrollbar.js +6 -6
- package/cjs/scrollbar/scrollbar.js.map +1 -1
- package/dist/index.es.js +19 -7
- package/es/axis/util.js +1 -2
- package/es/brush/type.js +2 -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.js +6 -2
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/legend/discrete/type.d.ts +1 -0
- package/es/legend/discrete/type.js.map +1 -1
- package/es/scrollbar/scrollbar.d.ts +10 -1
- package/es/scrollbar/scrollbar.js +6 -6
- package/es/scrollbar/scrollbar.js.map +1 -1
- package/package.json +5 -5
|
@@ -41,7 +41,7 @@ class ScrollBar extends base_1.AbstractComponent {
|
|
|
41
41
|
}, this._computeScrollValue = e => {
|
|
42
42
|
const {direction: direction} = this.attribute, {x: x, y: y} = this.stage.eventPointTransform(e);
|
|
43
43
|
let currentScrollValue, currentPos, delta = 0;
|
|
44
|
-
const {width: width, height: height} = this.
|
|
44
|
+
const {width: width, height: height} = this.getSliderRenderBounds();
|
|
45
45
|
return "vertical" === direction ? (currentPos = y, delta = currentPos - this._prePos,
|
|
46
46
|
currentScrollValue = delta / height) : (currentPos = x, delta = currentPos - this._prePos,
|
|
47
47
|
currentScrollValue = delta / width), [ currentPos, currentScrollValue ];
|
|
@@ -104,7 +104,7 @@ class ScrollBar extends base_1.AbstractComponent {
|
|
|
104
104
|
height: height
|
|
105
105
|
}, railStyle), "rect");
|
|
106
106
|
this._rail = rail;
|
|
107
|
-
const sliderRenderBounds = this.
|
|
107
|
+
const sliderRenderBounds = this.getSliderRenderBounds(), sliderPos = this._getSliderPos((0,
|
|
108
108
|
vutils_1.clampRange)(range, limitRange[0], limitRange[1])), sliderSize = sliderPos[1] - sliderPos[0];
|
|
109
109
|
let sliderAttribute;
|
|
110
110
|
this._sliderSize = sliderSize, sliderAttribute = "horizontal" === direction ? {
|
|
@@ -131,7 +131,7 @@ class ScrollBar extends base_1.AbstractComponent {
|
|
|
131
131
|
y: containerAABBBounds.y1
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
getSliderRenderBounds() {
|
|
135
135
|
if (this._sliderRenderBounds) return this._sliderRenderBounds;
|
|
136
136
|
const {width: width, height: height, padding: padding = 2} = this.attribute, [top, right, bottom, left] = (0,
|
|
137
137
|
vutils_1.normalizePadding)(padding), renderBounds = {
|
|
@@ -147,19 +147,19 @@ class ScrollBar extends base_1.AbstractComponent {
|
|
|
147
147
|
_getDefaultSliderCornerRadius() {
|
|
148
148
|
const {direction: direction, round: round} = this.attribute;
|
|
149
149
|
if (round) {
|
|
150
|
-
const {width: width, height: height} = this.
|
|
150
|
+
const {width: width, height: height} = this.getSliderRenderBounds();
|
|
151
151
|
return "horizontal" === direction ? height : width;
|
|
152
152
|
}
|
|
153
153
|
return 0;
|
|
154
154
|
}
|
|
155
155
|
_getSliderPos(range) {
|
|
156
|
-
const {direction: direction} = this.attribute, {width: width, height: height, x1: x1, y1: y1} = this.
|
|
156
|
+
const {direction: direction} = this.attribute, {width: width, height: height, x1: x1, y1: y1} = this.getSliderRenderBounds();
|
|
157
157
|
return "horizontal" === direction ? [ width * range[0] + x1, width * range[1] + x1 ] : [ height * range[0] + y1, height * range[1] + y1 ];
|
|
158
158
|
}
|
|
159
159
|
_getScrollRange() {
|
|
160
160
|
if (this._sliderLimitRange) return this._sliderLimitRange;
|
|
161
161
|
const {limitRange: limitRange = [ 0, 1 ], direction: direction} = this.attribute, [min, max] = (0,
|
|
162
|
-
vutils_1.clampRange)(limitRange, 0, 1), {width: width, height: height, x1: x1, y1: y1} = this.
|
|
162
|
+
vutils_1.clampRange)(limitRange, 0, 1), {width: width, height: height, x1: x1, y1: y1} = this.getSliderRenderBounds(), sliderSize = this._sliderSize;
|
|
163
163
|
return "horizontal" === direction ? (0, vutils_1.clampRange)([ x1 + min * width, x1 + max * width ], x1, width - sliderSize) : (0,
|
|
164
164
|
vutils_1.clampRange)([ y1 + min * height, y1 + max * height ], y1, height - sliderSize);
|
|
165
165
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/scrollbar/scrollbar.ts"],"names":[],"mappings":";;;AAKA,yDAAiD;AACjD,6CAAkG;AAClG,uCAAiD;AAIjD,yCAAoD;AACpD,0CAA8C;AAW9C,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,I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G,GAAG,KAAK,EAAE,EAAE,GAAG,GAAG,GAAG,KAAK,CAAC,EAAE,EAAE,EAAE,KAAK,GAAG,UAAU,CAAC;YAC1E,CAAC,CAAC,IAAA,mBAAU,EAAC,CAAC,EAAE,GAAG,GAAG,GAAG,MAAM,EAAE,EAAE,GAAG,GAAG,GAAG,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;IAClF,CAAC;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_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 private _getSliderRenderBounds() {\n if (this._sliderRenderBounds) {\n return this._sliderRenderBounds;\n }\n const { width, height, padding = 2 } = this.attribute as ScrollBarAttributes;\n const [top, right, bottom, left] = normalizePadding(padding);\n const renderBounds = {\n x1: left,\n y1: top,\n x2: width - right,\n y2: height - bottom,\n width: 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('scrollDown', {\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 { realTime = true, range: preRange, limitRange = [0, 1] } = this.attribute as ScrollBarAttributes;\n // 发射 change 事件\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n const range: [number, number] = [preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue];\n\n this._dispatchEvent('scrollUp', {\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,0CAA8C;AAW9C,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,iBAAQ;IAClB,QAAQ,EAAE,iBAAQ;CACnB,CAAC;AAEF,IAAA,iCAAsB,GAAE,CAAC;AAEzB,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;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_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('scrollDown', {\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 { realTime = true, range: preRange, limitRange = [0, 1] } = this.attribute as ScrollBarAttributes;\n // 发射 change 事件\n const preScrollRange = this.getScrollRange();\n const [currentPos, currentScrollValue] = this._computeScrollValue(e);\n const range: [number, number] = [preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue];\n\n this._dispatchEvent('scrollUp', {\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"]}
|
package/dist/index.es.js
CHANGED
|
@@ -14139,7 +14139,7 @@ class ScrollBar extends AbstractComponent {
|
|
|
14139
14139
|
let currentScrollValue;
|
|
14140
14140
|
let currentPos;
|
|
14141
14141
|
let delta = 0;
|
|
14142
|
-
const { width, height } = this.
|
|
14142
|
+
const { width, height } = this.getSliderRenderBounds();
|
|
14143
14143
|
if (direction === 'vertical') {
|
|
14144
14144
|
currentPos = y;
|
|
14145
14145
|
delta = currentPos - this._prePos;
|
|
@@ -14241,7 +14241,7 @@ class ScrollBar extends AbstractComponent {
|
|
|
14241
14241
|
const rail = group.createOrUpdateChild('scrollbar-rail', Object.assign({ x: 0, y: 0, width,
|
|
14242
14242
|
height }, railStyle), 'rect');
|
|
14243
14243
|
this._rail = rail;
|
|
14244
|
-
const sliderRenderBounds = this.
|
|
14244
|
+
const sliderRenderBounds = this.getSliderRenderBounds();
|
|
14245
14245
|
const sliderPos = this._getSliderPos(clampRange(range, limitRange[0], limitRange[1]));
|
|
14246
14246
|
const sliderSize = sliderPos[1] - sliderPos[0];
|
|
14247
14247
|
this._sliderSize = sliderSize;
|
|
@@ -14271,7 +14271,7 @@ class ScrollBar extends AbstractComponent {
|
|
|
14271
14271
|
y: containerAABBBounds.y1
|
|
14272
14272
|
};
|
|
14273
14273
|
}
|
|
14274
|
-
|
|
14274
|
+
getSliderRenderBounds() {
|
|
14275
14275
|
if (this._sliderRenderBounds) {
|
|
14276
14276
|
return this._sliderRenderBounds;
|
|
14277
14277
|
}
|
|
@@ -14291,14 +14291,14 @@ class ScrollBar extends AbstractComponent {
|
|
|
14291
14291
|
_getDefaultSliderCornerRadius() {
|
|
14292
14292
|
const { direction, round } = this.attribute;
|
|
14293
14293
|
if (round) {
|
|
14294
|
-
const { width, height } = this.
|
|
14294
|
+
const { width, height } = this.getSliderRenderBounds();
|
|
14295
14295
|
return direction === 'horizontal' ? height : width;
|
|
14296
14296
|
}
|
|
14297
14297
|
return 0;
|
|
14298
14298
|
}
|
|
14299
14299
|
_getSliderPos(range) {
|
|
14300
14300
|
const { direction } = this.attribute;
|
|
14301
|
-
const { width, height, x1, y1 } = this.
|
|
14301
|
+
const { width, height, x1, y1 } = this.getSliderRenderBounds();
|
|
14302
14302
|
if (direction === 'horizontal') {
|
|
14303
14303
|
return [width * range[0] + x1, width * range[1] + x1];
|
|
14304
14304
|
}
|
|
@@ -14310,7 +14310,7 @@ class ScrollBar extends AbstractComponent {
|
|
|
14310
14310
|
}
|
|
14311
14311
|
const { limitRange = [0, 1], direction } = this.attribute;
|
|
14312
14312
|
const [min, max] = clampRange(limitRange, 0, 1);
|
|
14313
|
-
const { width, height, x1, y1 } = this.
|
|
14313
|
+
const { width, height, x1, y1 } = this.getSliderRenderBounds();
|
|
14314
14314
|
const sliderSize = this._sliderSize;
|
|
14315
14315
|
return direction === 'horizontal'
|
|
14316
14316
|
? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)
|
|
@@ -24700,6 +24700,15 @@ class DiscreteLegend extends LegendBase {
|
|
|
24700
24700
|
: (e) => {
|
|
24701
24701
|
return e.detail.current;
|
|
24702
24702
|
};
|
|
24703
|
+
const onScroll = (e) => {
|
|
24704
|
+
e.preventDefault();
|
|
24705
|
+
const scrollComponent = this._pagerComponent;
|
|
24706
|
+
const preScrollRange = scrollComponent.getScrollRange();
|
|
24707
|
+
const { direction } = scrollComponent.attribute;
|
|
24708
|
+
const { width, height } = scrollComponent.getSliderRenderBounds();
|
|
24709
|
+
const currentScrollValue = direction === 'vertical' ? e.deltaY / height : e.deltaX / width;
|
|
24710
|
+
scrollComponent.setScrollRange([preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue], true);
|
|
24711
|
+
};
|
|
24703
24712
|
const onPaging = (e) => {
|
|
24704
24713
|
const newPage = pageParser(e);
|
|
24705
24714
|
if (newPage === this._itemContext.currentPage) {
|
|
@@ -24724,6 +24733,9 @@ class DiscreteLegend extends LegendBase {
|
|
|
24724
24733
|
if (this._itemContext.isScrollbar) {
|
|
24725
24734
|
this._pagerComponent.addEventListener('scrollDrag', onPaging);
|
|
24726
24735
|
this._pagerComponent.addEventListener('scrollUp', onPaging);
|
|
24736
|
+
if (this.attribute.pager.roamScroll) {
|
|
24737
|
+
this.addEventListener('wheel', onScroll);
|
|
24738
|
+
}
|
|
24727
24739
|
}
|
|
24728
24740
|
else {
|
|
24729
24741
|
this._pagerComponent.addEventListener('toPrev', onPaging);
|
|
@@ -29002,6 +29014,6 @@ EmptyTip.defaultAttributes = {
|
|
|
29002
29014
|
}
|
|
29003
29015
|
};
|
|
29004
29016
|
|
|
29005
|
-
const version = "0.20.
|
|
29017
|
+
const version = "0.20.6-alpha.0";
|
|
29006
29018
|
|
|
29007
29019
|
export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, ticks, traverseGroup, version };
|
package/es/axis/util.js
CHANGED
|
@@ -82,5 +82,4 @@ export function getPolygonPath(points, closed) {
|
|
|
82
82
|
return 0 === points.length || (points.forEach(((point, index) => {
|
|
83
83
|
0 === index ? path = `M${point.x},${point.y}` : path += `L${point.x},${point.y}`;
|
|
84
84
|
})), closed && (path += "Z")), path;
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=util.js.map
|
|
85
|
+
}
|
package/es/brush/type.js
CHANGED
|
@@ -4,4 +4,5 @@ export var IOperateType;
|
|
|
4
4
|
IOperateType.drawStart = "drawStart", IOperateType.drawEnd = "drawEnd", IOperateType.drawing = "drawing",
|
|
5
5
|
IOperateType.moving = "moving", IOperateType.moveStart = "moveStart", IOperateType.moveEnd = "moveEnd",
|
|
6
6
|
IOperateType.brushClear = "brushClear";
|
|
7
|
-
}(IOperateType || (IOperateType = {}));
|
|
7
|
+
}(IOperateType || (IOperateType = {}));
|
|
8
|
+
//# sourceMappingURL=type.js.map
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.20.6-alpha.0\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './util';\n"]}
|
|
@@ -354,7 +354,11 @@ export class DiscreteLegend extends LegendBase {
|
|
|
354
354
|
let newPage = value[0] * this._itemContext.totalPage;
|
|
355
355
|
return pager.scrollByPosition ? newPage += 1 : newPage = Math.floor(newPage) + 1,
|
|
356
356
|
newPage;
|
|
357
|
-
} : e => e.detail.current,
|
|
357
|
+
} : e => e.detail.current, onScroll = e => {
|
|
358
|
+
e.preventDefault();
|
|
359
|
+
const scrollComponent = this._pagerComponent, preScrollRange = scrollComponent.getScrollRange(), {direction: direction} = scrollComponent.attribute, {width: width, height: height} = scrollComponent.getSliderRenderBounds(), currentScrollValue = "vertical" === direction ? e.deltaY / height : e.deltaX / width;
|
|
360
|
+
scrollComponent.setScrollRange([ preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue ], !0);
|
|
361
|
+
}, onPaging = e => {
|
|
358
362
|
const newPage = pageParser(e);
|
|
359
363
|
if (newPage !== this._itemContext.currentPage) {
|
|
360
364
|
if (this._itemContext.currentPage = newPage, this._itemContext && this._itemContext.startIndex < this._itemContext.items.length) {
|
|
@@ -368,7 +372,7 @@ export class DiscreteLegend extends LegendBase {
|
|
|
368
372
|
}
|
|
369
373
|
};
|
|
370
374
|
this._itemContext.isScrollbar ? (this._pagerComponent.addEventListener("scrollDrag", onPaging),
|
|
371
|
-
this._pagerComponent.addEventListener("scrollUp", onPaging)) : (this._pagerComponent.addEventListener("toPrev", onPaging),
|
|
375
|
+
this._pagerComponent.addEventListener("scrollUp", onPaging), this.attribute.pager.roamScroll && this.addEventListener("wheel", onScroll)) : (this._pagerComponent.addEventListener("toPrev", onPaging),
|
|
372
376
|
this._pagerComponent.addEventListener("toNext", onPaging));
|
|
373
377
|
}
|
|
374
378
|
_renderPager() {
|