@visactor/vrender-components 1.0.41-alpha.1 → 1.0.41

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/label/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n EasingType,\n IGraphic,\n IGroupGraphicAttribute,\n ITextGraphicAttribute,\n IRichTextGraphicAttribute,\n IText,\n TextAlignType,\n TextBaselineType,\n ILineGraphicAttribute,\n IRichTextCharacter,\n IRichText,\n ILine,\n ICustomPath2D,\n IArc,\n IGroup\n} from '@visactor/vrender-core';\nimport type { BoundsAnchorType, IPointLike, InsideBoundsAnchorType } from '@visactor/vutils';\n\nexport type LabelItemStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n [key: string]: T;\n};\n\nexport type LabelItem = {\n // 用于动画\n id?: string;\n // 原始数据\n data?: any;\n [key: string]: any;\n // 文本类型:text, rich, html (区分于图元类型)\n textType?: string;\n /**\n * 文本内容,如果需要进行换行,则使用数组形式,如 ['abc', '123']\n * 支持富文本内容, 如textConfig, html\n */\n text?: string | string[] | number | number[] | IRichTextCharacter[];\n /**\n * 兼容ITextGraphicAttribute与IRichTextGraphicAttribute的textAlign属性\n */\n textAlign?: 'left' | 'right' | 'center' | 'start' | 'end';\n textBaseline?: 'top' | 'middle' | 'bottom' | 'alphabetic';\n} & (\n | Omit<Partial<ITextGraphicAttribute>, 'textAlign' | 'textBaseline'>\n | Omit<Partial<IRichTextGraphicAttribute>, 'textAlign' | 'textBaseline'>\n);\n\nexport interface BaseLabelAttrs extends IGroupGraphicAttribute {\n type: string;\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n /**\n * @hack not recommend to use\n * @returns\n */\n getBaseMarks?: () => IGraphic[];\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 标签数据\n */\n data: LabelItem[];\n\n /** 文本样式,优先级低于 data */\n textStyle?: Partial<ITextGraphicAttribute>;\n\n /** 文本交互样式 */\n state?: LabelItemStateStyle<ITextGraphicAttribute>;\n\n /** 连接线样式 */\n line?: ILabelLineSpec;\n\n /** 连线的交互样式 */\n labelLineState?: LabelItemStateStyle<ILineGraphicAttribute>;\n\n syncState?: boolean;\n\n /** 标签默认位置 */\n position?: Functional<string>;\n\n /** 偏移量 */\n offset?: number;\n\n /** 是否开启防重叠\n * @default true\n */\n overlap?: OverlapAttrs | boolean;\n\n /** 智能反色 */\n smartInvert?: SmartInvertAttrs | boolean;\n\n /** 动画配置 */\n animation?: ILabelAnimation | boolean;\n /**\n * 新增标签动画\n */\n animationEnter?: ILabelUpdateAnimation | boolean;\n /**\n * 标签更新动画\n */\n animationUpdate?: ILabelUpdateAnimation | ILabelUpdateChannelAnimation[] | boolean;\n /**\n * 标签被删除的动画配置\n */\n animationExit?: ILabelExitAnimation | boolean;\n\n /**\n * 数据过滤自定义函数,可以用于 排序 or 删减\n */\n dataFilter?: (data: LabelItem[]) => LabelItem[];\n\n /** 自定义布局函数\n * @description 当配置了 customLayoutFunc 后,默认布局逻辑将不再生效。(position/offset不生效)\n */\n customLayoutFunc?: (\n item: LabelItem[],\n labels: (IText | IRichText)[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint: ((data: LabelItem) => IPointLike) | null | undefined,\n labelComponent: IGroup\n ) => (IText | IRichText)[];\n\n /** 自定义标签躲避函数\n * @description 当配置了 customOverlapFunc 后,会根据 position 和 offset 进行初始布局。配置的防重叠逻辑(overlap)不生效。\n */\n customOverlapFunc?: (\n label: (IText | IRichText)[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint: ((data: LabelItem) => IPointLike) | null | undefined,\n labelComponent: IGroup\n ) => (IText | IRichText)[];\n /**\n * 防重叠计算完成后的回调函数\n * @since 1.19.16\n */\n onAfterOverlapping?: (\n labels: (IText | IRichText)[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint: ((data: LabelItem) => IPointLike) | null | undefined,\n labelComponent: IGroup\n ) => void;\n\n /**\n * 防重叠计算前的回调函数\n * 返回true的标签会被计算防重叠\n * 返回false的标签会被直接跳过防重叠计算\n * @since 1.19.16\n */\n filterBeforeOverlap?: (\n label: IText | IRichText,\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n labelComponent: IGroup\n ) => boolean;\n\n /**\n * 关闭交互效果\n * @default false\n */\n disableTriggerEvent?: boolean;\n /** 唯一标志符 */\n id?: string;\n}\n\nexport interface OverlapAttrs {\n /**\n * 防重叠的区域大小\n */\n size?: {\n /**\n * 防重叠区域的宽度\n */\n width: number;\n /**\n * 防重叠区域的高度\n */\n height: number;\n };\n\n /**\n * 发生重叠后,是否隐藏标签\n * @default true\n */\n hideOnHit?: boolean;\n\n /**\n * 是否约束标签在指定 size 的范围内。开启后若标签被区域裁剪,会向内收缩。\n * @default true\n */\n clampForce?: boolean;\n\n /**\n * 标签是否超出区域裁剪\n * @default false\n */\n hideOnOverflow?: boolean;\n\n /**\n * 是否躲避基础图元\n * @default false\n */\n avoidBaseMark?: boolean;\n\n /**\n * 躲避指定图元\n * @default []\n */\n avoidMarks?: string[] | IGraphic[];\n\n /**\n * 发生重叠后的躲避策略\n * @since 0.20.10 支持全局 Y 方向偏移策略 'shiftY'。当标签发生重叠时,会保相对位置并在 Y 方向上散开。由于 'shiftY' 是全局布局策略,不与其他策略同时生效。\n */\n strategy?: Strategy[] | ShiftYStrategy;\n\n /**\n * 文字在防重叠计算中预留的边距。\n * @default 0\n */\n overlapPadding?: number;\n\n /**\n * 防重叠的顺序权重\n * @since 0.20.10\n * @param labelItem\n * @returns number 数值越大,权重越高。权重越高的标签越优先被布局。\n */\n priority?: (labelItem: LabelItem) => number;\n\n /**\n * 防重叠计算前的回调函数\n * 返回true的标签会被计算防重叠\n * 返回false的标签会被直接跳过防重叠计算\n * @since 1.0.24\n */\n filterBeforeOverlap?: (\n label: IText | IRichText,\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n labelComponent: IGroup\n ) => boolean;\n}\n\nexport interface SmartInvertAttrs {\n /**\n * 对比度度量\n * 'WCAG' | 'lightness'\n * 默认使用'WCAG'\n */\n mode?: string;\n /**\n * 文本类型\n * 包含普通文本和大文本,对应不同的对比度标准,label默认为普通文本\n * 'normalText' | 'largeText'\n * @default 'normalText'\n */\n textType?: string;\n /**\n * 自定义对比度阈值\n */\n contrastRatiosThreshold?: number;\n /**\n * 自定义备选label颜色\n */\n alternativeColors?: string | string[];\n /**\n * fillStrategy四种策略:\n * - base(baseMark色),\n * - invertBase(执行智能反色),\n * - similarBase(智能反色的补色),\n * - null(不执行智能反色,保持fill设置的颜色)\n * @default 'invertBase'\n */\n fillStrategy?: 'base' | 'invertBase' | 'similarBase' | 'null';\n /**\n * strokeStrategy的四种策略:\n * - base(baseMark色),\n * - invertBase(执行智能反色),\n * - similarBase(智能反色的补色),\n * - null(不执行智能反色,保持stroke设置的颜色)\n * @default 'base'\n */\n strokeStrategy?: 'base' | 'invertBase' | 'similarBase' | 'null';\n /**\n * 前景色与亮色具有对比度时,similarSeries使用该色\n * @default '#ffffff'\n */\n brightColor?: string;\n /**\n * 前景色与暗色具有对比度时,similarSeries使用该色\n * @default '#000000'\n */\n darkColor?: string;\n /**\n * label超出mark范围,也以mark作为背景色进行反色\n */\n outsideEnable?: boolean;\n /**\n * 当标签和mark相交,但是没有完全在mark内部的时候,支持四种处理方式:\n *\n * * none:不做任何处理\n * * stroked:标签存在描边的时候,根据描边进行处理\n * * inside: 和标签完全在mark内部一样处理\n * * background:关闭标签描边,并将标签背景色设置为 mark 的填充色\n */\n interactInvertType?: 'none' | 'stroked' | 'inside' | 'background';\n}\n\nexport type ShiftYStrategy = {\n /**\n * 将防重叠策略设置为 'shiftY'\n */\n type: 'shiftY';\n /**\n * 布局迭代次数\n * @default 10\n */\n iteration?: number;\n /**\n * 布局容差\n * @default 0.1\n */\n maxError?: number;\n /**\n * 散开后的间距\n * @default 1\n */\n padding?: number;\n};\n\nexport type PositionStrategy = {\n /**\n * 将防重叠的策略设置为'position',即可选位置策略。\n * 若默认位置没有足够的空间放置标签,则考虑 position 内的备选位置。\n */\n type: 'position';\n /**\n * 所有的备选位置\n */\n position?: Functional<LabelPosition[]>;\n /**\n * 当 position 内的备选位置依然无法放下标签时,标签是否放回原位。\n * 默认为 true,若为 false,则标签会被放在 position 数组的最后一个位置。\n * @since 0.20.18\n * @default true\n */\n restorePosition?: boolean;\n};\n\nexport type BoundStrategy = {\n /**\n * 将防重叠策略设置为'bound',当标签配置在图形内部时使用。\n * 当图形大小不足以放下标签,则考虑 position 内的备选位置。\n */\n type: 'bound';\n /**\n * 所有的备选位置\n */\n position?: Functional<LabelPosition[]>;\n /**\n * 当 position 内的备选位置依然无法放下标签时,标签是否放回原位。\n * 默认为 true,若为 false,则标签会被放在 position 数组的最后一个位置。\n * @since 0.20.18\n * @default true\n */\n restorePosition?: boolean;\n};\n\nexport type MoveYStrategy = {\n /**\n * 将防重叠策略设置为'moveY'\n * 若默认位置没有足够的空间放置标签,则根据 offset 在Y方向上寻找位置。\n */\n type: 'moveY';\n /**\n * Y方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type MoveXStrategy = {\n /**\n * 将防重叠策略设置为'moveX'\n * 若默认位置没有足够的空间放置标签,则根据 offset 在X方向上寻找位置。\n */\n type: 'moveX';\n /**\n * X方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type Strategy = PositionStrategy | BoundStrategy | MoveYStrategy | MoveXStrategy;\n\nexport type LabelPosition = SymbolLabelAttrs['position'] | RectLabelAttrs['position'];\n\nexport interface SymbolLabelAttrs extends BaseLabelAttrs {\n type: 'symbol';\n\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<BoundsAnchorType>;\n}\n\nexport interface RectLabelAttrs extends BaseLabelAttrs {\n type: 'rect';\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<InsideBoundsAnchorType | BoundsAnchorType>;\n}\n\nexport interface LineLabelAttrs extends BaseLabelAttrs {\n type: 'line';\n /**\n * 标签位置\n * @default 'end'\n */\n position?: Functional<'start' | 'end'>;\n}\n\nexport interface AreaLabelAttrs extends BaseLabelAttrs {\n type: 'area';\n /**\n * 标签位置\n * @default 'end'\n */\n position?: Functional<'start' | 'end'>;\n}\n\nexport interface LineDataLabelAttrs extends BaseLabelAttrs {\n type: 'line-data';\n\n /**\n * 标签位置\n * @default 'top'\n * @since 0.21.1 支持 'inside-middle' 在面积图元中显示在中间位置\n */\n position?: Functional<BoundsAnchorType | 'inside-middle'>;\n}\n\nexport interface PolygonLabelAttrs extends BaseLabelAttrs {\n type: 'polygon';\n /**\n * 标签位置\n * @default 'center'\n */\n position?: Functional<'center'>;\n}\n\nexport interface ArcLabelAttrs extends BaseLabelAttrs {\n type: 'arc';\n\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n\n /**\n * 标签位置\n * @default 'outside'\n * @since 0.20.1 support 'inside-center'\n */\n position?: 'inside' | 'outside' | 'inside-inner' | 'inside-outer' | 'inside-center';\n\n // 画布宽度\n width?: number;\n // 画布高度\n height?: number;\n\n /**\n * 是否允许标签重叠\n * @default false\n */\n coverEnable?: boolean;\n /**\n * 是否允许标签旋转\n * @default true\n */\n rotate?: boolean;\n\n /**\n * 文字与引导线间隔宽度\n * @default 5\n */\n spaceWidth?: number;\n /**\n * 标签旋转角度\n */\n angle?: number;\n /**\n * 标签旋转角度的偏移角度\n */\n offsetAngle?: number;\n /**\n * 标签相对于 `outerRadius` 的径向偏移,目前仅作用于 inside 标签\n */\n offsetRadius?: number;\n /**\n * 标签横向点对齐\n */\n textAlign?: TextAlignType;\n /**\n * 标签纵向点对齐\n */\n textBaseline?: TextBaselineType;\n /**\n * 扇区间标签的间隔\n * @default 6\n */\n layoutArcGap?: number;\n /** 标签引导线样式 */\n line?: IArcLabelLineSpec;\n /** 标签布局配置 */\n layout?: IArcLabelLayoutSpec;\n /** 标签引导线点集 */\n points?: IPoint[];\n /** 饼图扇区中心偏移 */\n centerOffset?: number;\n}\n\nexport interface ILabelLineSpec {\n /**\n * 是否显示引导线\n * @default true\n */\n visible?: boolean;\n /**\n * 自定义路径\n * @since 0.19.21\n */\n customShape?: (container: IGroup, attrs: Partial<ILineGraphicAttribute>, path: ICustomPath2D) => ICustomPath2D;\n /**\n * 引导线样式\n */\n style?: Partial<ILineGraphicAttribute>;\n}\n\nexport interface IArcLabelLineSpec extends ILabelLineSpec {\n /**\n * 引导线 line1 部分最小长度\n * @default 20\n */\n line1MinLength?: number;\n /**\n * 引导线 line2 部分最小长度\n * @default 10\n * @since 0.20.3 支持函数回调\n */\n line2MinLength?: number | ((texts: IGraphic[], arcs: IArc[], attrs: Partial<ArcLabelAttrs>) => number);\n /**\n * 引导线是否光滑\n * @default false\n */\n smooth?: boolean;\n}\n\nexport type ArcLabelAlignType = 'arc' | 'labelLine' | 'edge';\n\nexport type ArcLabelStrategyType = 'priority' | 'vertical' | 'none';\n\nexport interface IArcLabelLayoutSpec {\n /**\n * 标签对齐方式\n * @default 'arc'\n */\n textAlign?: ArcLabelAlignType;\n /** @deprecate 建议统一使用textAlign,后续将废除 */\n align?: ArcLabelAlignType;\n /**\n * 标签对齐的偏移量\n * @since 0.20.3\n */\n alignOffset?: number | ((texts: IGraphic[], arcs: IArc[], attrs: Partial<ArcLabelAttrs>) => number);\n /**\n * 标签布局策略\n * @default 'priority'\n */\n strategy?: ArcLabelStrategyType;\n /**\n * 是否启用切线约束\n * @default true\n */\n tangentConstraint?: boolean;\n}\n\nexport interface DataLabelAttrs extends IGroupGraphicAttribute {\n dataLabels: (RectLabelAttrs | SymbolLabelAttrs | ArcLabelAttrs | LineDataLabelAttrs)[];\n /**\n * 防重叠的区域大小\n */\n size: { width: number; height: number; padding?: { top?: number; left?: number; right?: number; bottom?: number } };\n}\n\nexport type Functional<T> = T | ((data: any) => T);\n\n/**\n * 标签的离场动画配置\n */\nexport interface ILabelExitAnimation {\n /**\n * 动画执行的时长\n */\n duration?: number;\n /**\n * 动画延迟的时长\n */\n delay?: number;\n /**\n * 动画的缓动函数\n */\n easing?: EasingType;\n}\n\n/**\n * 标签的入场动画配置\n */\nexport interface ILabelEnterAnimation extends ILabelExitAnimation {\n /**\n * 标签动画的模式,支持三种类型\n * - same-time:标签出现动画和关联图形的动画同时进行\n * - after:当关联动图的出场动画结束后,执行标签的出场动画\n * - after-all:当所有关联图元的出场动画结束后,执行标签的出场动画\n */\n mode?: 'same-time' | 'after' | 'after-all';\n}\n\n/**\n * 标签的更新动画配置\n */\nexport interface ILabelUpdateAnimation extends ILabelExitAnimation {\n /**\n * 是否开启 increaseCount 动画\n * @default true\n */\n increaseEffect?: boolean;\n}\n\n/**\n * 标签更新的时候,动画的通道配置\n */\nexport interface ILabelUpdateChannelAnimation extends ILabelUpdateAnimation {\n /**\n * 进行插值动画的视觉通道\n */\n channel?: string[];\n /**\n * 动画的配置\n */\n options?: {\n /**\n * 忽略的视觉通道\n */\n excludeChannels?: string[];\n };\n}\n\nexport interface ILabelAnimation extends ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation {}\n\nexport interface IPoint {\n x: number;\n y: number;\n}\n\nexport interface IPolarPoint {\n radius: number;\n angle: number;\n}\n\nexport type Quadrant = 1 | 2 | 3 | 4;\n\nexport type TextAlign = 'left' | 'right' | 'center';\n\nexport type LabelContent = {\n text: IText | IRichText;\n labelLine?: ILine;\n};\n"]}
1
+ {"version":3,"sources":["../src/label/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n EasingType,\n IGraphic,\n IGroupGraphicAttribute,\n ITextGraphicAttribute,\n IRichTextGraphicAttribute,\n IText,\n TextAlignType,\n TextBaselineType,\n ILineGraphicAttribute,\n IRichTextCharacter,\n IRichText,\n ILine,\n ICustomPath2D,\n IArc,\n IGroup\n} from '@visactor/vrender-core';\nimport type { BoundsAnchorType, IPointLike, InsideBoundsAnchorType } from '@visactor/vutils';\n\nexport type LabelItemStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n [key: string]: T;\n};\n\nexport type LabelItem = {\n // 用于动画\n id?: string;\n // 原始数据\n data?: any;\n [key: string]: any;\n // 文本类型:text, rich, html (区分于图元类型)\n textType?: string;\n /**\n * 文本内容,如果需要进行换行,则使用数组形式,如 ['abc', '123']\n * 支持富文本内容, 如textConfig, html\n */\n text?: string | string[] | number | number[] | IRichTextCharacter[];\n /**\n * 兼容ITextGraphicAttribute与IRichTextGraphicAttribute的textAlign属性\n */\n textAlign?: 'left' | 'right' | 'center' | 'start' | 'end';\n textBaseline?: 'top' | 'middle' | 'bottom' | 'alphabetic';\n} & (\n | Omit<Partial<ITextGraphicAttribute>, 'textAlign' | 'textBaseline'>\n | Omit<Partial<IRichTextGraphicAttribute>, 'textAlign' | 'textBaseline'>\n);\n\nexport interface BaseLabelAttrs extends IGroupGraphicAttribute {\n type: string;\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n /**\n * @hack not recommend to use\n * @returns\n */\n getBaseMarks?: () => IGraphic[];\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 标签数据\n */\n data: LabelItem[];\n\n /** 文本样式,优先级低于 data */\n textStyle?: Partial<ITextGraphicAttribute>;\n\n /** 文本交互样式 */\n state?: LabelItemStateStyle<ITextGraphicAttribute>;\n\n /** 连接线样式 */\n line?: ILabelLineSpec;\n\n /** 连线的交互样式 */\n labelLineState?: LabelItemStateStyle<ILineGraphicAttribute>;\n\n syncState?: boolean;\n\n /** 标签默认位置 */\n position?: Functional<string>;\n\n /** 偏移量 */\n offset?: number;\n\n /** 是否开启防重叠\n * @default true\n */\n overlap?: OverlapAttrs | boolean;\n\n /** 智能反色 */\n smartInvert?: SmartInvertAttrs | boolean;\n\n /** 动画配置 */\n animation?: ILabelAnimation | boolean;\n /**\n * 新增标签动画\n */\n animationEnter?: ILabelUpdateAnimation | boolean;\n /**\n * 标签更新动画\n */\n animationUpdate?: ILabelUpdateAnimation | ILabelUpdateChannelAnimation[] | boolean;\n /**\n * 标签被删除的动画配置\n */\n animationExit?: ILabelExitAnimation | boolean;\n\n /**\n * 数据过滤自定义函数,可以用于 排序 or 删减\n */\n dataFilter?: (data: LabelItem[]) => LabelItem[];\n\n /** 自定义布局函数\n * @description 当配置了 customLayoutFunc 后,默认布局逻辑将不再生效。(position/offset不生效)\n */\n customLayoutFunc?: (\n item: LabelItem[],\n labels: (IText | IRichText)[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint: ((data: LabelItem) => IPointLike) | null | undefined,\n labelComponent: IGroup\n ) => (IText | IRichText)[];\n\n /** 自定义标签躲避函数\n * @description 当配置了 customOverlapFunc 后,会根据 position 和 offset 进行初始布局。配置的防重叠逻辑(overlap)不生效。\n */\n customOverlapFunc?: (\n label: (IText | IRichText)[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint: ((data: LabelItem) => IPointLike) | null | undefined,\n labelComponent: IGroup\n ) => (IText | IRichText)[];\n /**\n * 防重叠计算完成后的回调函数\n * @since 1.19.16\n */\n onAfterOverlapping?: (\n labels: (IText | IRichText)[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint: ((data: LabelItem) => IPointLike) | null | undefined,\n labelComponent: IGroup\n ) => void;\n\n /**\n * 防重叠计算前的回调函数\n * 返回true的标签会被计算防重叠\n * 返回false的标签会被直接跳过防重叠计算\n * @since 1.19.16\n */\n filterBeforeOverlap?: (\n label: IText | IRichText,\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n labelComponent: IGroup\n ) => boolean;\n\n /**\n * 关闭交互效果\n * @default false\n */\n disableTriggerEvent?: boolean;\n /** 唯一标志符 */\n id?: string;\n}\n\nexport interface OverlapAttrs {\n /**\n * 防重叠的区域大小\n */\n size?: {\n /**\n * 防重叠区域的宽度\n */\n width: number;\n /**\n * 防重叠区域的高度\n */\n height: number;\n };\n\n /**\n * 发生重叠后,是否隐藏标签\n * @default true\n */\n hideOnHit?: boolean;\n\n /**\n * 是否约束标签在指定 size 的范围内。开启后若标签被区域裁剪,会向内收缩。\n * @default true\n */\n clampForce?: boolean;\n\n /**\n * 标签是否超出区域裁剪\n * @default false\n */\n hideOnOverflow?: boolean;\n\n /**\n * 是否躲避基础图元\n * @default false\n */\n avoidBaseMark?: boolean;\n\n /**\n * 躲避指定图元\n * @default []\n */\n avoidMarks?: string[] | IGraphic[];\n\n /**\n * 发生重叠后的躲避策略\n * @since 0.20.10 支持全局 Y 方向偏移策略 'shiftY'。当标签发生重叠时,会保相对位置并在 Y 方向上散开。由于 'shiftY' 是全局布局策略,不与其他策略同时生效。\n */\n strategy?: Strategy[] | ShiftYStrategy;\n\n /**\n * 文字在防重叠计算中预留的边距。\n * @default 0\n */\n overlapPadding?: number;\n\n /**\n * 防重叠的顺序权重\n * @since 0.20.10\n * @param labelItem\n * @returns number 数值越大,权重越高。权重越高的标签越优先被布局。\n */\n priority?: (labelItem: LabelItem) => number;\n\n /**\n * 防重叠计算前的回调函数\n * 返回true的标签会被计算防重叠\n * 返回false的标签会被直接跳过防重叠计算\n * @since 1.0.24\n */\n filterBeforeOverlap?: (\n label: IText | IRichText,\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n labelComponent: IGroup\n ) => boolean;\n}\n\nexport interface SmartInvertAttrs {\n /**\n * 对比度度量\n * 'WCAG' | 'lightness'\n * 默认使用'WCAG'\n */\n mode?: string;\n /**\n * 文本类型\n * 包含普通文本和大文本,对应不同的对比度标准,label默认为普通文本\n * 'normalText' | 'largeText'\n * @default 'normalText'\n */\n textType?: string;\n /**\n * 自定义对比度阈值\n */\n contrastRatiosThreshold?: number;\n /**\n * 自定义备选label颜色\n */\n alternativeColors?: string | string[];\n /**\n * fillStrategy四种策略:\n * - base(baseMark色),\n * - invertBase(执行智能反色),\n * - similarBase(智能反色的补色),\n * - null(不执行智能反色,保持fill设置的颜色)\n * @default 'invertBase'\n */\n fillStrategy?: 'base' | 'invertBase' | 'similarBase' | 'null';\n /**\n * strokeStrategy的四种策略:\n * - base(baseMark色),\n * - invertBase(执行智能反色),\n * - similarBase(智能反色的补色),\n * - null(不执行智能反色,保持stroke设置的颜色)\n * @default 'base'\n */\n strokeStrategy?: 'base' | 'invertBase' | 'similarBase' | 'null';\n /**\n * 前景色与亮色具有对比度时,similarSeries使用该色\n * @default '#ffffff'\n */\n brightColor?: string;\n /**\n * 前景色与暗色具有对比度时,similarSeries使用该色\n * @default '#000000'\n */\n darkColor?: string;\n /**\n * label超出mark范围,也以mark作为背景色进行反色\n */\n outsideEnable?: boolean;\n /**\n * 当标签和mark相交,但是没有完全在mark内部的时候,支持三种处理方式:\n *\n * * none:不做任何处理\n * * stroked:标签存在描边的时候,根据描边进行处理\n * * inside: 和标签完全在mark内部一样处理\n */\n interactInvertType?: 'none' | 'stroked' | 'inside';\n}\n\nexport type ShiftYStrategy = {\n /**\n * 将防重叠策略设置为 'shiftY'\n */\n type: 'shiftY';\n /**\n * 布局迭代次数\n * @default 10\n */\n iteration?: number;\n /**\n * 布局容差\n * @default 0.1\n */\n maxError?: number;\n /**\n * 散开后的间距\n * @default 1\n */\n padding?: number;\n};\n\nexport type PositionStrategy = {\n /**\n * 将防重叠的策略设置为'position',即可选位置策略。\n * 若默认位置没有足够的空间放置标签,则考虑 position 内的备选位置。\n */\n type: 'position';\n /**\n * 所有的备选位置\n */\n position?: Functional<LabelPosition[]>;\n /**\n * 当 position 内的备选位置依然无法放下标签时,标签是否放回原位。\n * 默认为 true,若为 false,则标签会被放在 position 数组的最后一个位置。\n * @since 0.20.18\n * @default true\n */\n restorePosition?: boolean;\n};\n\nexport type BoundStrategy = {\n /**\n * 将防重叠策略设置为'bound',当标签配置在图形内部时使用。\n * 当图形大小不足以放下标签,则考虑 position 内的备选位置。\n */\n type: 'bound';\n /**\n * 所有的备选位置\n */\n position?: Functional<LabelPosition[]>;\n /**\n * 当 position 内的备选位置依然无法放下标签时,标签是否放回原位。\n * 默认为 true,若为 false,则标签会被放在 position 数组的最后一个位置。\n * @since 0.20.18\n * @default true\n */\n restorePosition?: boolean;\n};\n\nexport type MoveYStrategy = {\n /**\n * 将防重叠策略设置为'moveY'\n * 若默认位置没有足够的空间放置标签,则根据 offset 在Y方向上寻找位置。\n */\n type: 'moveY';\n /**\n * Y方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type MoveXStrategy = {\n /**\n * 将防重叠策略设置为'moveX'\n * 若默认位置没有足够的空间放置标签,则根据 offset 在X方向上寻找位置。\n */\n type: 'moveX';\n /**\n * X方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type Strategy = PositionStrategy | BoundStrategy | MoveYStrategy | MoveXStrategy;\n\nexport type LabelPosition = SymbolLabelAttrs['position'] | RectLabelAttrs['position'];\n\nexport interface SymbolLabelAttrs extends BaseLabelAttrs {\n type: 'symbol';\n\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<BoundsAnchorType>;\n}\n\nexport interface RectLabelAttrs extends BaseLabelAttrs {\n type: 'rect';\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<InsideBoundsAnchorType | BoundsAnchorType>;\n}\n\nexport interface LineLabelAttrs extends BaseLabelAttrs {\n type: 'line';\n /**\n * 标签位置\n * @default 'end'\n */\n position?: Functional<'start' | 'end'>;\n}\n\nexport interface AreaLabelAttrs extends BaseLabelAttrs {\n type: 'area';\n /**\n * 标签位置\n * @default 'end'\n */\n position?: Functional<'start' | 'end'>;\n}\n\nexport interface LineDataLabelAttrs extends BaseLabelAttrs {\n type: 'line-data';\n\n /**\n * 标签位置\n * @default 'top'\n * @since 0.21.1 支持 'inside-middle' 在面积图元中显示在中间位置\n */\n position?: Functional<BoundsAnchorType | 'inside-middle'>;\n}\n\nexport interface PolygonLabelAttrs extends BaseLabelAttrs {\n type: 'polygon';\n /**\n * 标签位置\n * @default 'center'\n */\n position?: Functional<'center'>;\n}\n\nexport interface ArcLabelAttrs extends BaseLabelAttrs {\n type: 'arc';\n\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n\n /**\n * 标签位置\n * @default 'outside'\n * @since 0.20.1 support 'inside-center'\n */\n position?: 'inside' | 'outside' | 'inside-inner' | 'inside-outer' | 'inside-center';\n\n // 画布宽度\n width?: number;\n // 画布高度\n height?: number;\n\n /**\n * 是否允许标签重叠\n * @default false\n */\n coverEnable?: boolean;\n /**\n * 是否允许标签旋转\n * @default true\n */\n rotate?: boolean;\n\n /**\n * 文字与引导线间隔宽度\n * @default 5\n */\n spaceWidth?: number;\n /**\n * 标签旋转角度\n */\n angle?: number;\n /**\n * 标签旋转角度的偏移角度\n */\n offsetAngle?: number;\n /**\n * 标签相对于 `outerRadius` 的径向偏移,目前仅作用于 inside 标签\n */\n offsetRadius?: number;\n /**\n * 标签横向点对齐\n */\n textAlign?: TextAlignType;\n /**\n * 标签纵向点对齐\n */\n textBaseline?: TextBaselineType;\n /**\n * 扇区间标签的间隔\n * @default 6\n */\n layoutArcGap?: number;\n /** 标签引导线样式 */\n line?: IArcLabelLineSpec;\n /** 标签布局配置 */\n layout?: IArcLabelLayoutSpec;\n /** 标签引导线点集 */\n points?: IPoint[];\n /** 饼图扇区中心偏移 */\n centerOffset?: number;\n}\n\nexport interface ILabelLineSpec {\n /**\n * 是否显示引导线\n * @default true\n */\n visible?: boolean;\n /**\n * 自定义路径\n * @since 0.19.21\n */\n customShape?: (container: IGroup, attrs: Partial<ILineGraphicAttribute>, path: ICustomPath2D) => ICustomPath2D;\n /**\n * 引导线样式\n */\n style?: Partial<ILineGraphicAttribute>;\n}\n\nexport interface IArcLabelLineSpec extends ILabelLineSpec {\n /**\n * 引导线 line1 部分最小长度\n * @default 20\n */\n line1MinLength?: number;\n /**\n * 引导线 line2 部分最小长度\n * @default 10\n * @since 0.20.3 支持函数回调\n */\n line2MinLength?: number | ((texts: IGraphic[], arcs: IArc[], attrs: Partial<ArcLabelAttrs>) => number);\n /**\n * 引导线是否光滑\n * @default false\n */\n smooth?: boolean;\n}\n\nexport type ArcLabelAlignType = 'arc' | 'labelLine' | 'edge';\n\nexport type ArcLabelStrategyType = 'priority' | 'vertical' | 'none';\n\nexport interface IArcLabelLayoutSpec {\n /**\n * 标签对齐方式\n * @default 'arc'\n */\n textAlign?: ArcLabelAlignType;\n /** @deprecate 建议统一使用textAlign,后续将废除 */\n align?: ArcLabelAlignType;\n /**\n * 标签对齐的偏移量\n * @since 0.20.3\n */\n alignOffset?: number | ((texts: IGraphic[], arcs: IArc[], attrs: Partial<ArcLabelAttrs>) => number);\n /**\n * 标签布局策略\n * @default 'priority'\n */\n strategy?: ArcLabelStrategyType;\n /**\n * 是否启用切线约束\n * @default true\n */\n tangentConstraint?: boolean;\n}\n\nexport interface DataLabelAttrs extends IGroupGraphicAttribute {\n dataLabels: (RectLabelAttrs | SymbolLabelAttrs | ArcLabelAttrs | LineDataLabelAttrs)[];\n /**\n * 防重叠的区域大小\n */\n size: { width: number; height: number; padding?: { top?: number; left?: number; right?: number; bottom?: number } };\n}\n\nexport type Functional<T> = T | ((data: any) => T);\n\n/**\n * 标签的离场动画配置\n */\nexport interface ILabelExitAnimation {\n /**\n * 动画执行的时长\n */\n duration?: number;\n /**\n * 动画延迟的时长\n */\n delay?: number;\n /**\n * 动画的缓动函数\n */\n easing?: EasingType;\n}\n\n/**\n * 标签的入场动画配置\n */\nexport interface ILabelEnterAnimation extends ILabelExitAnimation {\n /**\n * 标签动画的模式,支持三种类型\n * - same-time:标签出现动画和关联图形的动画同时进行\n * - after:当关联动图的出场动画结束后,执行标签的出场动画\n * - after-all:当所有关联图元的出场动画结束后,执行标签的出场动画\n */\n mode?: 'same-time' | 'after' | 'after-all';\n}\n\n/**\n * 标签的更新动画配置\n */\nexport interface ILabelUpdateAnimation extends ILabelExitAnimation {\n /**\n * 是否开启 increaseCount 动画\n * @default true\n */\n increaseEffect?: boolean;\n}\n\n/**\n * 标签更新的时候,动画的通道配置\n */\nexport interface ILabelUpdateChannelAnimation extends ILabelUpdateAnimation {\n /**\n * 进行插值动画的视觉通道\n */\n channel?: string[];\n /**\n * 动画的配置\n */\n options?: {\n /**\n * 忽略的视觉通道\n */\n excludeChannels?: string[];\n };\n}\n\nexport interface ILabelAnimation extends ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation {}\n\nexport interface IPoint {\n x: number;\n y: number;\n}\n\nexport interface IPolarPoint {\n radius: number;\n angle: number;\n}\n\nexport type Quadrant = 1 | 2 | 3 | 4;\n\nexport type TextAlign = 'left' | 'right' | 'center';\n\nexport type LabelContent = {\n text: IText | IRichText;\n labelLine?: ILine;\n};\n"]}
@@ -122,4 +122,5 @@ export declare abstract class BasePlayer<T> extends AbstractComponent<Required<P
122
122
  renderSlider(): void;
123
123
  renderController(): void;
124
124
  dispatchCustomEvent(eventType: PlayerEventEnum, dataIndex: number): void;
125
+ release(all: boolean): void;
125
126
  }
@@ -158,6 +158,9 @@ export class BasePlayer extends AbstractComponent {
158
158
  value: this._data[dataIndex]
159
159
  });
160
160
  }
161
+ release(all) {
162
+ this._sliderVisible || this._slider.release(all), super.release(all);
163
+ }
161
164
  }
162
165
 
163
166
  BasePlayer.defaultAttributes = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/player/base-player.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAU1C,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,S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OAAO,EAAE,IAAI;QACb,KAAK,kCAAO,2BAA2B,KAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,GAAE;QACpF,KAAK,kCAAO,2BAA2B,KAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAE;QAC1E,OAAO,kCAAO,2BAA2B,KAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,GAAE;QAC5E,QAAQ,kCAAO,2BAA2B,KAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,GAAE;KACjF;CACF,CAAC","file":"base-player.js","sourcesContent":["import type { INode } from '@visactor/vrender-core';\nimport { isNumber, isValidNumber, max, merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { ComponentOptions, OrientType } from '../interface';\nimport type { SliderAttributes } from '../slider';\nimport { Slider } from '../slider';\nimport type { ControllerAttributes } from './controller';\nimport { Controller } from './controller';\nimport type {\n Datum,\n PlayerEventEnum,\n PlayerAttributes,\n RailStyleType,\n ControllerType,\n TrackStyleType,\n HandlerStyleType\n} from './type';\nimport { RailDefaultSize, defaultControllerAttributes } from './constant';\nimport { isHorizontal } from './utils';\n\n/**\n * 基本播放器组件\n * 提供最基本的布局能力,\n */\nexport abstract class BasePlayer<T> extends AbstractComponent<Required<PlayerAttributes>> {\n static defaultAttributes = {\n visible: true,\n data: [] as Datum[],\n interval: 1000,\n orient: 'bottom',\n align: 'center',\n size: {\n height: 20,\n width: 300\n },\n slider: {\n visible: true,\n space: 10,\n dx: 0,\n dy: 0,\n railStyle: {\n cornerRadius: 5\n },\n trackStyle: {},\n handlerStyle: {}\n },\n controller: {\n visible: true,\n start: { ...defaultControllerAttributes, key: 'start', position: 'start', space: 0 },\n pause: { ...defaultControllerAttributes, key: 'pause', position: 'start' },\n forward: { ...defaultControllerAttributes, key: 'forward', position: 'end' },\n backward: { ...defaultControllerAttributes, key: 'backward', position: 'start' }\n }\n };\n\n // 组件属性\n protected _slider: Slider;\n protected _controller: Controller;\n\n // 数据属性\n protected _data = [] as Datum[];\n protected _minIndex: number;\n getMinIndex() {\n return this._minIndex;\n }\n protected _maxIndex: number;\n getMaxIndex() {\n return this._maxIndex;\n }\n\n // 滑轨属性\n private _sliderVisible: boolean;\n private _railStyle: RailStyleType;\n private _trackStyle: TrackStyleType;\n private _handlerStyle: HandlerStyleType;\n\n // 控件属性\n private _controllerVisible: boolean;\n private _start: ControllerType;\n private _pause: ControllerType;\n private _forward: ControllerType;\n private _backward: ControllerType;\n\n // 布局属性\n private _size: { width: number; height: number };\n private _orient: OrientType;\n\n // dataIndex, 代表slider的value\n protected _dataIndex: number = 0;\n getDataIndex() {\n return this._dataIndex;\n }\n\n private _layoutInfo: {\n // 滚动条位置\n slider?: { x: number; y: number; size: number };\n\n // 控件位置\n start?: { x: number; y: number; size: number };\n pause?: { x: number; y: number; size: number };\n backward?: { x: number; y: number; size: number };\n forward?: { x: number; y: number; size: number };\n } = {};\n\n abstract play(): void;\n abstract pause(): void;\n abstract backward(): void;\n abstract forward(): void;\n\n constructor(attributes: T, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, BasePlayer.defaultAttributes, attributes));\n // 先初始化属性, 再初始化Slider、Controller, 最后初始化事件.\n this._initAttributes();\n this._initDataIndex();\n this._initLayoutInfo();\n this._initController();\n this._initSlider();\n }\n\n /**\n * 初始化属性\n */\n _initAttributes() {\n // 基本布局属性\n this._size = this.attribute.size;\n this._orient = this.attribute.orient;\n\n // Slider范围, 起点一定要从0开始\n this._data = this.attribute.data;\n this._minIndex = 0;\n this._maxIndex = this._data.length - 1;\n\n const { slider = {}, controller = {} as PlayerAttributes['controller'] } = this.attribute;\n // 轨道样式\n this._sliderVisible = slider.visible;\n this._railStyle = { ...slider.railStyle };\n this._trackStyle = { ...slider.trackStyle };\n this._handlerStyle = { ...slider.handlerStyle };\n\n // 控制器样式\n this._controllerVisible = controller.visible;\n this._start = { ...controller.start };\n this._pause = { ...controller.pause };\n this._forward = { ...controller.forward };\n this._backward = { ...controller.backward };\n }\n\n /**\n * 初始化dataIndex\n */\n _initDataIndex() {\n this._dataIndex = this.attribute.dataIndex ?? 0;\n }\n\n private _initLayoutInfo() {\n // 控制器\n const controllers = [this._start, this._backward, this._forward].sort((a, b) => a.order - b.order);\n // 在开始位置的控制器\n const startControllers = controllers.filter(d => d.position !== 'end');\n // 在结束位置的控制器\n const endControllers = controllers.filter(d => d.position === 'end');\n // 滑轨横切面长度\n const railSectionLength =\n (isHorizontal(this._orient) ? this._railStyle.height : this._railStyle.width) ?? RailDefaultSize[1];\n\n // 1. 计算所有组件自身占据的宽度 or 高度\n const controllerPx = controllers.reduce((len, controller) => {\n const size = controller.style.size;\n const maxSize = isNumber(size) ? size : max(size[0], size[1]);\n return len + controller.space + maxSize;\n }, 0);\n\n // 2. 计算slider的总占据像素\n const sliderPx = this._sliderVisible\n ? (isHorizontal(this._orient) ? this._size?.width : this._size?.height) - controllerPx\n : 0;\n\n // 3. 计算slider滑轨的总占据像素\n const railPx = sliderPx - this.attribute.slider.space;\n\n // 4. 计算起点控件坐标\n const startPx = startControllers.reduce((px, controller) => {\n const {\n key,\n space,\n style: { size }\n } = controller;\n const maxSize = isNumber(size) ? size : max(size[0], size[1]);\n this._layoutInfo[key] = {\n ...this._layoutInfo[key],\n size: maxSize,\n x: isHorizontal(this._orient) ? px + space : (this._size.width - maxSize) / 2,\n y: isHorizontal(this._orient) ? (this._size.height - maxSize) / 2 : px + space\n };\n return px + space + maxSize;\n }, 0);\n\n // 5. 计算slider的起点坐标\n this._layoutInfo.slider = {\n ...this._layoutInfo.slider,\n size: railPx,\n x: isHorizontal(this._orient)\n ? startPx + this.attribute.slider.space\n : (this._size.width - railSectionLength) / 2,\n y: isHorizontal(this._orient)\n ? (this._size.height - railSectionLength) / 2\n : startPx + this.attribute.slider.space\n };\n\n // 6. 计算终点控件坐标\n endControllers.reduce((px, controller) => {\n const {\n key,\n space,\n style: { size }\n } = controller;\n const maxSize = isNumber(size) ? size : max(size[0], size[1]);\n this._layoutInfo[key] = {\n ...this._layoutInfo[key],\n size: maxSize,\n x: isHorizontal(this._orient) ? px + space : (this._size.width - maxSize) / 2,\n y: isHorizontal(this._orient) ? (this._size.height - maxSize) / 2 : px + space\n };\n return px + space + maxSize;\n }, startPx + sliderPx);\n }\n\n /**\n * 初始化滑动条\n */\n private _updateSliderAttrs = () => {\n let handlerSize;\n if (isValidNumber(this._handlerStyle.size)) {\n handlerSize = this._handlerStyle.size;\n } else if (this._handlerStyle.size && this._handlerStyle.size.length) {\n handlerSize = max(this._handlerStyle.size[0], this._handlerStyle.size[1]);\n }\n\n const attrs: SliderAttributes = {\n visible: this._sliderVisible,\n // 重要参数\n min: this._minIndex,\n max: this._maxIndex,\n value: this._dataIndex,\n railWidth: this._railStyle.width,\n railHeight: this._railStyle.height,\n railStyle: this._railStyle,\n trackStyle: this._trackStyle,\n handlerSize: isValidNumber(handlerSize) ? handlerSize : undefined,\n handlerStyle: this._handlerStyle,\n // 不重要, 但需要预设的参数\n dy: this.attribute.slider.dy,\n dx: this.attribute.slider.dx,\n slidable: true,\n range: false,\n handlerText: { visible: false },\n startText: { visible: false },\n endText: { visible: false },\n disableTriggerEvent: this.attribute.disableTriggerEvent\n };\n\n // 横向布局\n if (isHorizontal(this._orient)) {\n // 滑动条水平居中\n const railWidth = Math.max(0, this._layoutInfo.slider.size);\n const railHeight = this._railStyle.height ?? RailDefaultSize[1];\n\n // 属性修改\n attrs.layout = 'horizontal';\n attrs.railHeight = railHeight;\n attrs.railWidth = railWidth;\n attrs.x = this._layoutInfo.slider.x;\n attrs.y = this._layoutInfo.slider.y;\n }\n // 纵向布局\n else {\n // 滑动条垂直居中\n const railHeight = Math.max(0, this._layoutInfo.slider.size);\n const railWidth = this._railStyle.width ?? RailDefaultSize[1];\n\n // 属性修改\n attrs.layout = 'vertical';\n attrs.railWidth = railWidth;\n attrs.railHeight = railHeight;\n attrs.x = this._layoutInfo.slider.x;\n attrs.y = this._layoutInfo.slider.y;\n }\n return attrs;\n };\n\n private _initSlider = () => {\n const attrs = this._updateSliderAttrs();\n this._slider = new Slider(attrs);\n if (this._sliderVisible) {\n this.add(this._slider as unknown as INode);\n }\n };\n\n /**\n * 初始化控制器\n */\n private _updateControllerAttrs = () => {\n const attrs: ControllerAttributes = {\n start: this._start,\n pause: this._pause,\n forward: this._forward,\n backward: this._backward,\n disableTriggerEvent: this.attribute.disableTriggerEvent\n };\n // 横向布局\n attrs.layout = isHorizontal(this._orient) ? 'horizontal' : 'vertical';\n attrs.start = {\n ...attrs.start,\n style: {\n ...attrs.start.style,\n x: this._layoutInfo.start.x,\n y: this._layoutInfo.start.y\n }\n };\n attrs.pause = {\n ...attrs.pause,\n // 暂停按钮, 复用开始按钮的布局\n style: {\n ...attrs.pause.style,\n x: this._layoutInfo.start.x,\n y: this._layoutInfo.start.y\n }\n };\n attrs.backward = {\n ...attrs.backward,\n style: {\n ...attrs.backward.style,\n x: this._layoutInfo.backward.x,\n y: this._layoutInfo.backward.y\n }\n };\n attrs.forward = {\n ...attrs.forward,\n style: {\n ...attrs.forward.style,\n x: this._layoutInfo.forward.x,\n y: this._layoutInfo.forward.y\n }\n };\n return attrs;\n };\n\n private _initController = () => {\n const attrs = this._updateControllerAttrs();\n this._controller = new Controller(attrs);\n if (this._controllerVisible) {\n this.add(this._controller as unknown as INode);\n }\n };\n\n /**\n * 渲染\n */\n render() {\n this._initLayoutInfo();\n this.renderSlider();\n this.renderController();\n }\n\n /**\n * 更新滑动条\n */\n renderSlider() {\n const attrs = this._updateSliderAttrs();\n this._slider.setAttributes(attrs);\n }\n\n /**\n * 更新控制器\n */\n renderController() {\n const attrs = this._updateControllerAttrs();\n this._controller.setAttributes(attrs);\n }\n\n /**\n * 触发事件\n * @param eventType 事件类型\n * @param dataIndex 数据下标\n */\n dispatchCustomEvent(eventType: PlayerEventEnum, dataIndex: number) {\n this._dispatchEvent(eventType, {\n eventType,\n index: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AC,GAAY;QAClB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACxB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;SAC3B;QACD,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;;AArXM,4BAAiB,GAAG;IACzB,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,EAAa;IACnB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE;QACJ,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,GAAG;KACX;IACD,MAAM,EAAE;QACN,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,EAAE;QACT,EAAE,EAAE,CAAC;QACL,EAAE,EAAE,CAAC;QACL,SAAS,EAAE;YACT,YAAY,EAAE,CAAC;SAChB;QACD,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,EAAE;KACjB;IACD,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,KAAK,kCAAO,2BAA2B,KAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,GAAE;QACpF,KAAK,kCAAO,2BAA2B,KAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAE;QAC1E,OAAO,kCAAO,2BAA2B,KAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,GAAE;QAC5E,QAAQ,kCAAO,2BAA2B,KAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,GAAE;KACjF;CACF,CAAC","file":"base-player.js","sourcesContent":["import type { INode } from '@visactor/vrender-core';\nimport { isNumber, isValidNumber, max, merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { ComponentOptions, OrientType } from '../interface';\nimport type { SliderAttributes } from '../slider';\nimport { Slider } from '../slider';\nimport type { ControllerAttributes } from './controller';\nimport { Controller } from './controller';\nimport type {\n Datum,\n PlayerEventEnum,\n PlayerAttributes,\n RailStyleType,\n ControllerType,\n TrackStyleType,\n HandlerStyleType\n} from './type';\nimport { RailDefaultSize, defaultControllerAttributes } from './constant';\nimport { isHorizontal } from './utils';\n\n/**\n * 基本播放器组件\n * 提供最基本的布局能力,\n */\nexport abstract class BasePlayer<T> extends AbstractComponent<Required<PlayerAttributes>> {\n static defaultAttributes = {\n visible: true,\n data: [] as Datum[],\n interval: 1000,\n orient: 'bottom',\n align: 'center',\n size: {\n height: 20,\n width: 300\n },\n slider: {\n visible: true,\n space: 10,\n dx: 0,\n dy: 0,\n railStyle: {\n cornerRadius: 5\n },\n trackStyle: {},\n handlerStyle: {}\n },\n controller: {\n visible: true,\n start: { ...defaultControllerAttributes, key: 'start', position: 'start', space: 0 },\n pause: { ...defaultControllerAttributes, key: 'pause', position: 'start' },\n forward: { ...defaultControllerAttributes, key: 'forward', position: 'end' },\n backward: { ...defaultControllerAttributes, key: 'backward', position: 'start' }\n }\n };\n\n // 组件属性\n protected _slider: Slider;\n protected _controller: Controller;\n\n // 数据属性\n protected _data = [] as Datum[];\n protected _minIndex: number;\n getMinIndex() {\n return this._minIndex;\n }\n protected _maxIndex: number;\n getMaxIndex() {\n return this._maxIndex;\n }\n\n // 滑轨属性\n private _sliderVisible: boolean;\n private _railStyle: RailStyleType;\n private _trackStyle: TrackStyleType;\n private _handlerStyle: HandlerStyleType;\n\n // 控件属性\n private _controllerVisible: boolean;\n private _start: ControllerType;\n private _pause: ControllerType;\n private _forward: ControllerType;\n private _backward: ControllerType;\n\n // 布局属性\n private _size: { width: number; height: number };\n private _orient: OrientType;\n\n // dataIndex, 代表slider的value\n protected _dataIndex: number = 0;\n getDataIndex() {\n return this._dataIndex;\n }\n\n private _layoutInfo: {\n // 滚动条位置\n slider?: { x: number; y: number; size: number };\n\n // 控件位置\n start?: { x: number; y: number; size: number };\n pause?: { x: number; y: number; size: number };\n backward?: { x: number; y: number; size: number };\n forward?: { x: number; y: number; size: number };\n } = {};\n\n abstract play(): void;\n abstract pause(): void;\n abstract backward(): void;\n abstract forward(): void;\n\n constructor(attributes: T, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, BasePlayer.defaultAttributes, attributes));\n // 先初始化属性, 再初始化Slider、Controller, 最后初始化事件.\n this._initAttributes();\n this._initDataIndex();\n this._initLayoutInfo();\n this._initController();\n this._initSlider();\n }\n\n /**\n * 初始化属性\n */\n _initAttributes() {\n // 基本布局属性\n this._size = this.attribute.size;\n this._orient = this.attribute.orient;\n\n // Slider范围, 起点一定要从0开始\n this._data = this.attribute.data;\n this._minIndex = 0;\n this._maxIndex = this._data.length - 1;\n\n const { slider = {}, controller = {} as PlayerAttributes['controller'] } = this.attribute;\n // 轨道样式\n this._sliderVisible = slider.visible;\n this._railStyle = { ...slider.railStyle };\n this._trackStyle = { ...slider.trackStyle };\n this._handlerStyle = { ...slider.handlerStyle };\n\n // 控制器样式\n this._controllerVisible = controller.visible;\n this._start = { ...controller.start };\n this._pause = { ...controller.pause };\n this._forward = { ...controller.forward };\n this._backward = { ...controller.backward };\n }\n\n /**\n * 初始化dataIndex\n */\n _initDataIndex() {\n this._dataIndex = this.attribute.dataIndex ?? 0;\n }\n\n private _initLayoutInfo() {\n // 控制器\n const controllers = [this._start, this._backward, this._forward].sort((a, b) => a.order - b.order);\n // 在开始位置的控制器\n const startControllers = controllers.filter(d => d.position !== 'end');\n // 在结束位置的控制器\n const endControllers = controllers.filter(d => d.position === 'end');\n // 滑轨横切面长度\n const railSectionLength =\n (isHorizontal(this._orient) ? this._railStyle.height : this._railStyle.width) ?? RailDefaultSize[1];\n\n // 1. 计算所有组件自身占据的宽度 or 高度\n const controllerPx = controllers.reduce((len, controller) => {\n const size = controller.style.size;\n const maxSize = isNumber(size) ? size : max(size[0], size[1]);\n return len + controller.space + maxSize;\n }, 0);\n\n // 2. 计算slider的总占据像素\n const sliderPx = this._sliderVisible\n ? (isHorizontal(this._orient) ? this._size?.width : this._size?.height) - controllerPx\n : 0;\n\n // 3. 计算slider滑轨的总占据像素\n const railPx = sliderPx - this.attribute.slider.space;\n\n // 4. 计算起点控件坐标\n const startPx = startControllers.reduce((px, controller) => {\n const {\n key,\n space,\n style: { size }\n } = controller;\n const maxSize = isNumber(size) ? size : max(size[0], size[1]);\n this._layoutInfo[key] = {\n ...this._layoutInfo[key],\n size: maxSize,\n x: isHorizontal(this._orient) ? px + space : (this._size.width - maxSize) / 2,\n y: isHorizontal(this._orient) ? (this._size.height - maxSize) / 2 : px + space\n };\n return px + space + maxSize;\n }, 0);\n\n // 5. 计算slider的起点坐标\n this._layoutInfo.slider = {\n ...this._layoutInfo.slider,\n size: railPx,\n x: isHorizontal(this._orient)\n ? startPx + this.attribute.slider.space\n : (this._size.width - railSectionLength) / 2,\n y: isHorizontal(this._orient)\n ? (this._size.height - railSectionLength) / 2\n : startPx + this.attribute.slider.space\n };\n\n // 6. 计算终点控件坐标\n endControllers.reduce((px, controller) => {\n const {\n key,\n space,\n style: { size }\n } = controller;\n const maxSize = isNumber(size) ? size : max(size[0], size[1]);\n this._layoutInfo[key] = {\n ...this._layoutInfo[key],\n size: maxSize,\n x: isHorizontal(this._orient) ? px + space : (this._size.width - maxSize) / 2,\n y: isHorizontal(this._orient) ? (this._size.height - maxSize) / 2 : px + space\n };\n return px + space + maxSize;\n }, startPx + sliderPx);\n }\n\n /**\n * 初始化滑动条\n */\n private _updateSliderAttrs = () => {\n let handlerSize;\n if (isValidNumber(this._handlerStyle.size)) {\n handlerSize = this._handlerStyle.size;\n } else if (this._handlerStyle.size && this._handlerStyle.size.length) {\n handlerSize = max(this._handlerStyle.size[0], this._handlerStyle.size[1]);\n }\n\n const attrs: SliderAttributes = {\n visible: this._sliderVisible,\n // 重要参数\n min: this._minIndex,\n max: this._maxIndex,\n value: this._dataIndex,\n railWidth: this._railStyle.width,\n railHeight: this._railStyle.height,\n railStyle: this._railStyle,\n trackStyle: this._trackStyle,\n handlerSize: isValidNumber(handlerSize) ? handlerSize : undefined,\n handlerStyle: this._handlerStyle,\n // 不重要, 但需要预设的参数\n dy: this.attribute.slider.dy,\n dx: this.attribute.slider.dx,\n slidable: true,\n range: false,\n handlerText: { visible: false },\n startText: { visible: false },\n endText: { visible: false },\n disableTriggerEvent: this.attribute.disableTriggerEvent\n };\n\n // 横向布局\n if (isHorizontal(this._orient)) {\n // 滑动条水平居中\n const railWidth = Math.max(0, this._layoutInfo.slider.size);\n const railHeight = this._railStyle.height ?? RailDefaultSize[1];\n\n // 属性修改\n attrs.layout = 'horizontal';\n attrs.railHeight = railHeight;\n attrs.railWidth = railWidth;\n attrs.x = this._layoutInfo.slider.x;\n attrs.y = this._layoutInfo.slider.y;\n }\n // 纵向布局\n else {\n // 滑动条垂直居中\n const railHeight = Math.max(0, this._layoutInfo.slider.size);\n const railWidth = this._railStyle.width ?? RailDefaultSize[1];\n\n // 属性修改\n attrs.layout = 'vertical';\n attrs.railWidth = railWidth;\n attrs.railHeight = railHeight;\n attrs.x = this._layoutInfo.slider.x;\n attrs.y = this._layoutInfo.slider.y;\n }\n return attrs;\n };\n\n private _initSlider = () => {\n const attrs = this._updateSliderAttrs();\n this._slider = new Slider(attrs);\n if (this._sliderVisible) {\n this.add(this._slider as unknown as INode);\n }\n };\n\n /**\n * 初始化控制器\n */\n private _updateControllerAttrs = () => {\n const attrs: ControllerAttributes = {\n start: this._start,\n pause: this._pause,\n forward: this._forward,\n backward: this._backward,\n disableTriggerEvent: this.attribute.disableTriggerEvent\n };\n // 横向布局\n attrs.layout = isHorizontal(this._orient) ? 'horizontal' : 'vertical';\n attrs.start = {\n ...attrs.start,\n style: {\n ...attrs.start.style,\n x: this._layoutInfo.start.x,\n y: this._layoutInfo.start.y\n }\n };\n attrs.pause = {\n ...attrs.pause,\n // 暂停按钮, 复用开始按钮的布局\n style: {\n ...attrs.pause.style,\n x: this._layoutInfo.start.x,\n y: this._layoutInfo.start.y\n }\n };\n attrs.backward = {\n ...attrs.backward,\n style: {\n ...attrs.backward.style,\n x: this._layoutInfo.backward.x,\n y: this._layoutInfo.backward.y\n }\n };\n attrs.forward = {\n ...attrs.forward,\n style: {\n ...attrs.forward.style,\n x: this._layoutInfo.forward.x,\n y: this._layoutInfo.forward.y\n }\n };\n return attrs;\n };\n\n private _initController = () => {\n const attrs = this._updateControllerAttrs();\n this._controller = new Controller(attrs);\n if (this._controllerVisible) {\n this.add(this._controller as unknown as INode);\n }\n };\n\n /**\n * 渲染\n */\n render() {\n this._initLayoutInfo();\n this.renderSlider();\n this.renderController();\n }\n\n /**\n * 更新滑动条\n */\n renderSlider() {\n const attrs = this._updateSliderAttrs();\n this._slider.setAttributes(attrs);\n }\n\n /**\n * 更新控制器\n */\n renderController() {\n const attrs = this._updateControllerAttrs();\n this._controller.setAttributes(attrs);\n }\n\n /**\n * 触发事件\n * @param eventType 事件类型\n * @param dataIndex 数据下标\n */\n dispatchCustomEvent(eventType: PlayerEventEnum, dataIndex: number) {\n this._dispatchEvent(eventType, {\n eventType,\n index: dataIndex,\n value: this._data[dataIndex]\n });\n }\n\n release(all: boolean) {\n if (!this._sliderVisible) {\n this._slider.release(all);\n }\n super.release(all);\n }\n}\n"]}
@@ -179,7 +179,7 @@ export class ScrollBar extends AbstractComponent {
179
179
  this._sliderRenderBounds = null, this._sliderLimitRange = null;
180
180
  }
181
181
  release(all) {
182
- super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).addEventListener("touchmove", this._handleTouchMove, {
182
+ super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).removeEventListener("touchmove", this._handleTouchMove, {
183
183
  passive: !1
184
184
  }), this._clearDragEvents();
185
185
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/scrollbar/scrollbar.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,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;QACZ,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,GAAa;QAInB,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,gBAAgB,EAAE;YACtG,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QACH,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;;AAhaM,2BAAiB,GAAG;IACzB,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,EAAE;IACd,aAAa,EAAE,CAAC;IAChB,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, isValid } 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 minSliderSize: 0,\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 (vglobal.env === 'browser' ? vglobal : this.stage).addEventListener('touchmove', this._handleTouchMove, {\n passive: false\n });\n }\n\n private _handleTouchMove = (e: TouchEvent) => {\n if (isValid(this._prePos)) {\n // 正在滚动中的时候\n /**\n * https://developer.mozilla.org/zh-CN/docs/Web/CSS/overscroll-behavior\n * 由于浏览器的overscroll-behavior属性,需要在move的时候阻止浏览器默认行为,否则会因为浏览器检测到scroll行为,阻止pointer事件,\n * 抛出pointercancel事件,导致拖拽行为中断。\n */\n e.preventDefault();\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 * 计算滑块在轨道的位置(像素),应用最小展示尺寸但不改变 range 语义\n */\n private _getSliderPos(range: [number, number]) {\n const { direction, minSliderSize = 0 } = this.attribute as ScrollBarAttributes;\n const { width, height, x1, y1 } = this.getSliderRenderBounds();\n const track = direction === 'horizontal' ? width : height;\n const origin = direction === 'horizontal' ? x1 : y1;\n const start = clamp(range[0], 0, 1);\n const end = clamp(range[1], 0, 1);\n const ratio = clamp(end - start, 0, 1);\n const L = Math.max(ratio * track, minSliderSize);\n const T = Math.max(track - L, 0);\n const denom = Math.max(1 - ratio, 1e-12);\n const pStart = origin + (start / denom) * T;\n const pEnd = pStart + L;\n return [pStart, pEnd];\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 /**\n * move的时候,需要通过 capture: true,能够在捕获截断被拦截,\n * move的时候,需要显示的设置passive: false,因为在移动端需要禁用浏览器默认行为\n */\n obj.addEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n triggers.forEach((trigger: string) => {\n obj.addEventListener(trigger, this._onSliderPointerUp);\n });\n };\n\n /**\n * 将拖拽像素位移映射为逻辑 range 增量,保证最小尺寸下仍覆盖 [0,1]\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 = 0;\n let currentPos;\n let delta = 0;\n\n const { width, height } = this.getSliderRenderBounds();\n const track = direction === 'vertical' ? height : width;\n const travel = Math.max(track - this._sliderSize, 0);\n const { range } = this.attribute as ScrollBarAttributes;\n const ratio = clamp(range[1] - range[0], 0, 1);\n\n if (direction === 'vertical') {\n currentPos = y;\n delta = currentPos - this._prePos;\n } else {\n currentPos = x;\n delta = currentPos - this._prePos;\n }\n\n if (travel > 0 && ratio < 1) {\n currentScrollValue = (delta / travel) * (1 - ratio);\n } else {\n currentScrollValue = 0;\n }\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 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 this._prePos = null;\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 release(all?: boolean): void {\n /**\n * 浏览器上的事件必须解绑,防止内存泄漏,场景树上的事件会自动解绑\n */\n super.release(all);\n (vglobal.env === 'browser' ? vglobal : this.stage).addEventListener('touchmove', this._handleTouchMove, {\n passive: false\n });\n this._clearDragEvents();\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/scrollbar/scrollbar.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAIjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAA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AAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,gBAAgB,EAAE;YACzG,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QACH,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;;AAhaM,2BAAiB,GAAG;IACzB,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,EAAE;IACd,aAAa,EAAE,CAAC;IAChB,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, isValid } 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 minSliderSize: 0,\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 (vglobal.env === 'browser' ? vglobal : this.stage).addEventListener('touchmove', this._handleTouchMove, {\n passive: false\n });\n }\n\n private _handleTouchMove = (e: TouchEvent) => {\n if (isValid(this._prePos)) {\n // 正在滚动中的时候\n /**\n * https://developer.mozilla.org/zh-CN/docs/Web/CSS/overscroll-behavior\n * 由于浏览器的overscroll-behavior属性,需要在move的时候阻止浏览器默认行为,否则会因为浏览器检测到scroll行为,阻止pointer事件,\n * 抛出pointercancel事件,导致拖拽行为中断。\n */\n e.preventDefault();\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 * 计算滑块在轨道的位置(像素),应用最小展示尺寸但不改变 range 语义\n */\n private _getSliderPos(range: [number, number]) {\n const { direction, minSliderSize = 0 } = this.attribute as ScrollBarAttributes;\n const { width, height, x1, y1 } = this.getSliderRenderBounds();\n const track = direction === 'horizontal' ? width : height;\n const origin = direction === 'horizontal' ? x1 : y1;\n const start = clamp(range[0], 0, 1);\n const end = clamp(range[1], 0, 1);\n const ratio = clamp(end - start, 0, 1);\n const L = Math.max(ratio * track, minSliderSize);\n const T = Math.max(track - L, 0);\n const denom = Math.max(1 - ratio, 1e-12);\n const pStart = origin + (start / denom) * T;\n const pEnd = pStart + L;\n return [pStart, pEnd];\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 /**\n * move的时候,需要通过 capture: true,能够在捕获截断被拦截,\n * move的时候,需要显示的设置passive: false,因为在移动端需要禁用浏览器默认行为\n */\n obj.addEventListener('pointermove', this._onSliderPointerMoveWithDelay, { capture: true });\n triggers.forEach((trigger: string) => {\n obj.addEventListener(trigger, this._onSliderPointerUp);\n });\n };\n\n /**\n * 将拖拽像素位移映射为逻辑 range 增量,保证最小尺寸下仍覆盖 [0,1]\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 = 0;\n let currentPos;\n let delta = 0;\n\n const { width, height } = this.getSliderRenderBounds();\n const track = direction === 'vertical' ? height : width;\n const travel = Math.max(track - this._sliderSize, 0);\n const { range } = this.attribute as ScrollBarAttributes;\n const ratio = clamp(range[1] - range[0], 0, 1);\n\n if (direction === 'vertical') {\n currentPos = y;\n delta = currentPos - this._prePos;\n } else {\n currentPos = x;\n delta = currentPos - this._prePos;\n }\n\n if (travel > 0 && ratio < 1) {\n currentScrollValue = (delta / travel) * (1 - ratio);\n } else {\n currentScrollValue = 0;\n }\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 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 this._prePos = null;\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 release(all?: boolean): void {\n /**\n * 浏览器上的事件必须解绑,防止内存泄漏,场景树上的事件会自动解绑\n */\n super.release(all);\n (vglobal.env === 'browser' ? vglobal : this.stage).removeEventListener('touchmove', this._handleTouchMove, {\n passive: false\n });\n this._clearDragEvents();\n }\n}\n"]}
@@ -470,7 +470,7 @@ export class Slider extends AbstractComponent {
470
470
  };
471
471
  }
472
472
  release(all) {
473
- super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).addEventListener("touchmove", this._handleTouchMove, {
473
+ super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).removeEventListener("touchmove", this._handleTouchMove, {
474
474
  passive: !1
475
475
  }), this._clearAllDragEvents();
476
476
  }