@visactor/vrender-components 0.20.0 → 0.20.1-alpha.1
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/checkbox/checkbox.d.ts +2 -0
- package/cjs/checkbox/checkbox.js +4 -0
- package/cjs/checkbox/checkbox.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/player/base-player.d.ts +8 -1
- package/cjs/player/base-player.js +9 -0
- package/cjs/player/base-player.js.map +1 -1
- package/cjs/player/continuous-player.d.ts +1 -7
- package/cjs/player/continuous-player.js.map +1 -1
- package/cjs/player/discrete-player.d.ts +1 -7
- package/cjs/player/discrete-player.js.map +1 -1
- package/cjs/radio/radio.d.ts +2 -0
- package/cjs/radio/radio.js +4 -0
- package/cjs/radio/radio.js.map +1 -1
- package/cjs/tag/tag.d.ts +10 -0
- package/cjs/tag/tag.js +32 -2
- package/cjs/tag/tag.js.map +1 -1
- package/dist/index.es.js +76 -1
- package/es/checkbox/checkbox.d.ts +2 -0
- package/es/checkbox/checkbox.js +4 -0
- package/es/checkbox/checkbox.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/player/base-player.d.ts +8 -1
- package/es/player/base-player.js +9 -0
- package/es/player/base-player.js.map +1 -1
- package/es/player/continuous-player.d.ts +1 -7
- package/es/player/continuous-player.js.map +1 -1
- package/es/player/discrete-player.d.ts +1 -7
- package/es/player/discrete-player.js.map +1 -1
- package/es/radio/radio.d.ts +2 -0
- package/es/radio/radio.js +4 -0
- package/es/radio/radio.js.map +1 -1
- package/es/tag/tag.d.ts +10 -0
- package/es/tag/tag.js +32 -2
- package/es/tag/tag.js.map +1 -1
- package/package.json +5 -5
package/cjs/tag/tag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tag/tag.ts"],"names":[],"mappings":";;;;;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AE;QACL,IAAI,EAAE,MAAM;KACb;CACF,CAAC","file":"tag.js","sourcesContent":["/**\n * @description 标签组件\n */\nimport {\n type IGroup,\n type IRect,\n type ISymbol,\n type IText,\n type ITextAttribute,\n type ITextGraphicAttribute,\n type IRichTextGraphicAttribute,\n type IRichText,\n type IGraphicAttribute,\n CustomPath2D\n} from '@visactor/vrender-core';\nimport { isBoolean, isEmpty, isNil, isNumber, isObject, isValid, merge, normalizePadding } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { isRichText, measureTextSize, richTextAttributeTransform } from '../util';\nimport type { BackgroundAttributes, ComponentOptions } from '../interface';\nimport type { TagAttributes, TagShapeAttributes } from './type';\nimport { loadTagComponent } from './register';\nimport type { TextContent } from '../core/type';\n\nloadTagComponent();\nexport class Tag extends AbstractComponent<Required<TagAttributes>> {\n name = 'tag';\n\n private _bgRect!: IRect;\n private _textShape!: IText | IRichText;\n\n getBgRect() {\n return this._bgRect;\n }\n\n getTextShape() {\n return this._textShape;\n }\n\n static defaultAttributes: Partial<TagAttributes> = {\n visible: true,\n textStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'left',\n textBaseline: 'top'\n },\n space: 4,\n padding: 4,\n // @ts-ignore\n shape: {\n fill: '#000'\n }\n };\n\n constructor(attributes: TagAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Tag.defaultAttributes, attributes));\n }\n\n protected render() {\n const {\n text = '',\n textStyle = {} as ITextGraphicAttribute | IRichTextGraphicAttribute,\n shape = {} as TagShapeAttributes,\n panel = {} as BackgroundAttributes,\n space = 4,\n minWidth,\n maxWidth,\n padding = 4,\n visible,\n state,\n type,\n textAlwaysCenter,\n containerTextAlign\n } = this.attribute as TagAttributes;\n const parsedPadding = normalizePadding(padding);\n\n const group = this.createOrUpdateChild('tag-content', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup;\n\n let symbol;\n let tagWidth = parsedPadding[1] + parsedPadding[3];\n let tagHeight = parsedPadding[0] + parsedPadding[2];\n let textX = 0;\n let symbolPlaceWidth = 0;\n const { visible: shapeVisible, ...shapeStyle } = shape;\n if (isBoolean(shapeVisible)) {\n const size = shapeStyle?.size || 10;\n const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1])) as number;\n\n symbol = group.createOrUpdateChild(\n 'tag-shape',\n {\n symbolType: 'circle',\n size,\n strokeBoundsBuffer: 0,\n ...shapeStyle,\n visible: shapeVisible,\n x: maxSize / 2,\n y: maxSize / 2\n },\n 'symbol'\n ) as ISymbol;\n if (!isEmpty(state?.shape)) {\n symbol.states = state.shape;\n }\n\n if (shapeVisible) {\n symbolPlaceWidth = maxSize + space;\n }\n }\n\n tagWidth += symbolPlaceWidth;\n textX += symbolPlaceWidth;\n\n let textShape: IRichText | IText;\n const isRich = isRichText({ text } as TextContent) || type === 'rich';\n if (isRich) {\n const richTextAttrs = {\n ...richTextAttributeTransform({ type, text, ...textStyle } as any),\n ...(textStyle as IRichTextGraphicAttribute),\n visible: isValid(text) && visible !== false,\n x: textX,\n y: 0\n };\n textShape = group.createOrUpdateChild('tag-text', richTextAttrs, 'richtext') as IRichText;\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n if (visible && isBoolean(bgVisible)) {\n const bgRect = this.createOrUpdateChild(\n 'tag-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && !!text,\n x: textShape.AABBBounds.x1,\n y: textShape.AABBBounds.y1,\n width: textShape.AABBBounds.width(),\n height: textShape.AABBBounds.height()\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n if (backgroundStyle.customShape) {\n const customShape = backgroundStyle.customShape;\n bgRect.pathProxy = (attrs: Partial<IGraphicAttribute>) => {\n return customShape(textShape.attribute, attrs, new CustomPath2D());\n };\n }\n this._bgRect = bgRect;\n }\n } else {\n const textAttrs = {\n text: isObject(text) && 'type' in text && text.type === 'text' ? text.text : text,\n visible: isValid(text) && visible !== false,\n lineHeight: (textStyle as ITextGraphicAttribute)?.fontSize,\n ...(textStyle as ITextGraphicAttribute),\n x: textX,\n y: 0\n };\n if (isNil(textAttrs.lineHeight)) {\n textAttrs.lineHeight = (textStyle as ITextGraphicAttribute).fontSize;\n }\n textShape = group.createOrUpdateChild('tag-text', textAttrs as ITextGraphicAttribute, 'text') as IText;\n if (!isEmpty(state?.text)) {\n textShape.states = state.text;\n }\n\n // 因为文本可能发生旋转,所以需要使用 measureTextSize 方法\n const textBounds = measureTextSize(textAttrs.text as string, textStyle, this.stage?.getTheme()?.text);\n const textWidth = textBounds.width;\n const textHeight = textBounds.height;\n tagWidth += textWidth;\n const size = shape.size ?? 10;\n const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1])) as number;\n tagHeight += Math.max(textHeight, shape.visible ? maxSize : 0);\n\n const { textAlign, textBaseline } = textStyle as ITextAttribute;\n\n if (isValid(minWidth) || isValid(maxWidth)) {\n if (isValid(minWidth) && tagWidth < minWidth) {\n tagWidth = minWidth;\n }\n if (isValid(maxWidth) && tagWidth > maxWidth) {\n tagWidth = maxWidth;\n textShape.setAttribute('maxLineWidth', maxWidth - parsedPadding[1] - parsedPadding[2]);\n }\n }\n\n let x = 0;\n let y = 0;\n let flag = 0;\n if (textAlign === 'left' || textAlign === 'start') {\n flag = 1;\n } else if (textAlign === 'right' || textAlign === 'end') {\n flag = -1;\n } else if (textAlign === 'center') {\n flag = 0;\n }\n if (!flag) {\n x -= tagWidth / 2;\n if (symbol) {\n symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth / 2);\n }\n\n group.setAttribute('x', -symbolPlaceWidth / 2);\n } else if (flag < 0) {\n x -= tagWidth;\n if (symbol) {\n symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth);\n }\n\n group.setAttribute('x', -parsedPadding[1] - symbolPlaceWidth);\n } else if (flag > 0) {\n group.setAttribute('x', parsedPadding[3]);\n }\n\n const shouldCenter = containerTextAlign ? containerTextAlign === 'center' : textAlwaysCenter;\n const shouldRight = containerTextAlign === 'right' || containerTextAlign === 'end';\n const shouldLeft = containerTextAlign === 'left' || containerTextAlign === 'start';\n\n if (shouldCenter && flag) {\n // 文本容器内居中\n // 剔除padding后的内宽度\n const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];\n const tsWidth = textWidth + symbolPlaceWidth;\n const textX =\n flag === 1\n ? (containerWidth - tsWidth) / 2 + symbolPlaceWidth + textWidth / 2\n : parsedPadding[0] + symbolPlaceWidth - (tagWidth / 2 + tsWidth / 2 - symbolPlaceWidth) + textWidth / 2;\n\n textShape.setAttributes({\n x: textX,\n textAlign: 'center'\n });\n if (symbol) {\n const symbolX = textX - textWidth / 2 - symbolPlaceWidth + maxSize / 2;\n symbol.setAttributes({\n x: symbolX\n });\n }\n }\n\n if (shouldLeft && flag !== 1) {\n // 文本容器内朝左展示\n const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];\n const offset =\n flag === 0\n ? -containerWidth / 2 + symbolPlaceWidth / 2\n : -tagWidth + parsedPadding[3] + parsedPadding[1] + symbolPlaceWidth;\n const textX = offset + symbolPlaceWidth;\n\n textShape.setAttributes({\n x: textX,\n textAlign: 'left'\n });\n\n if (symbol) {\n const symbolX = offset + maxSize / 2;\n symbol.setAttributes({\n x: symbolX\n });\n }\n }\n\n if (shouldRight && flag !== -1) {\n // 文本容器内朝右展示\n const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];\n const textX = flag === 0 ? containerWidth / 2 + symbolPlaceWidth / 2 : containerWidth;\n\n textShape.setAttributes({\n x: textX,\n textAlign: 'right'\n });\n if (symbol) {\n const symbolX = textX - textWidth - symbolPlaceWidth + maxSize / 2;\n symbol.setAttributes({\n x: symbolX\n });\n }\n }\n\n if (textBaseline === 'middle') {\n y -= tagHeight / 2;\n if (symbol) {\n symbol.setAttribute('y', 0);\n }\n } else if (textBaseline === 'bottom') {\n y -= tagHeight;\n if (symbol) {\n symbol.setAttribute('y', -textHeight / 2);\n }\n\n group.setAttribute('y', -parsedPadding[2]);\n } else if (textBaseline === 'top') {\n group.setAttribute('y', parsedPadding[0]);\n if (symbol) {\n symbol.setAttribute('y', textHeight / 2);\n }\n }\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n if (visible && isBoolean(bgVisible)) {\n const bgRect = this.createOrUpdateChild(\n 'tag-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && !!text,\n x,\n y,\n width: tagWidth,\n height: tagHeight\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n if (backgroundStyle.customShape) {\n const customShape = backgroundStyle.customShape;\n bgRect.pathProxy = (attrs: Partial<IGraphicAttribute>) => {\n return customShape(textShape.attribute, attrs, new CustomPath2D());\n };\n }\n this._bgRect = bgRect;\n }\n }\n this._textShape = textShape;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/tag/tag.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,yDAWgC;AAChC,6CAAmH;AACnH,uCAAiD;AACjD,kCAAkF;AAGlF,yCAA8C;AAG9C,IAAA,2BAAgB,GAAE,CAAC;AACnB,MAAa,GAAI,SAAQ,wBAA0C;IAWjE,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAkBD,YAAY,UAAyB,EAAE,OAA0B;QAC/D,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,GAAG,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAnC1F,SAAI,GAAG,KAAK,CAAC;QAKL,eAAU,GAAa,EAAE,CAAC;QAC1B,gBAAW,GAAa,EAAE,CAAC;QAC3B,kBAAa,GAAa,EAAE,CAAC;QAC7B,gBAAW,GAAa,EA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AC,OAAO,0CAAE,WAAW,EAAE,CAAC;QAC5B,MAAA,IAAI,CAAC,UAAU,0CAAE,WAAW,EAAE,CAAC;IACjC,CAAC;IACD,WAAW;;QACT,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1D,IAAI,CAAC,WAAW,CAAC,MAAM,KAAI,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA,CAAC;QACrE,IAAI,CAAC,aAAa,CAAC,MAAM,KAAI,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA,CAAC;QACzE,IAAI,CAAC,WAAW,CAAC,MAAM,KAAI,MAAA,IAAI,CAAC,UAAU,0CAAE,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA,CAAC;IAC1E,CAAC;;AA3WH,kBA4WC;AAzVQ,qBAAiB,GAA2B;IACjD,OAAO,EAAE,IAAI;IACb,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IAEV,KAAK,EAAE;QACL,IAAI,EAAE,MAAM;KACb;CACF,CAAC","file":"tag.js","sourcesContent":["/**\n * @description 标签组件\n */\nimport {\n type IGroup,\n type IRect,\n type ISymbol,\n type IText,\n type ITextAttribute,\n type ITextGraphicAttribute,\n type IRichTextGraphicAttribute,\n type IRichText,\n type IGraphicAttribute,\n CustomPath2D\n} from '@visactor/vrender-core';\nimport { isBoolean, isEmpty, isNil, isNumber, isObject, isValid, merge, normalizePadding } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { isRichText, measureTextSize, richTextAttributeTransform } from '../util';\nimport type { BackgroundAttributes, ComponentOptions } from '../interface';\nimport type { TagAttributes, TagShapeAttributes } from './type';\nimport { loadTagComponent } from './register';\nimport type { TextContent } from '../core/type';\n\nloadTagComponent();\nexport class Tag extends AbstractComponent<Required<TagAttributes>> {\n name = 'tag';\n\n private _bgRect!: IRect;\n private _textShape!: IText | IRichText;\n private _symbol!: ISymbol;\n private _tagStates: string[] = [];\n private _rectStates: string[] = [];\n private _symbolStates: string[] = [];\n private _textStates: string[] = [];\n\n getBgRect() {\n return this._bgRect;\n }\n\n getTextShape() {\n return this._textShape;\n }\n\n static defaultAttributes: Partial<TagAttributes> = {\n visible: true,\n textStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'left',\n textBaseline: 'top'\n },\n space: 4,\n padding: 4,\n // @ts-ignore\n shape: {\n fill: '#000'\n }\n };\n\n constructor(attributes: TagAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Tag.defaultAttributes, attributes));\n }\n\n protected render() {\n this.cacheStates();\n const {\n text = '',\n textStyle = {} as ITextGraphicAttribute | IRichTextGraphicAttribute,\n shape = {} as TagShapeAttributes,\n panel = {} as BackgroundAttributes,\n space = 4,\n minWidth,\n maxWidth,\n padding = 4,\n visible,\n state,\n type,\n textAlwaysCenter,\n containerTextAlign\n } = this.attribute as TagAttributes;\n const parsedPadding = normalizePadding(padding);\n\n const group = this.createOrUpdateChild('tag-content', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup;\n\n let symbol;\n let tagWidth = parsedPadding[1] + parsedPadding[3];\n let tagHeight = parsedPadding[0] + parsedPadding[2];\n let textX = 0;\n let symbolPlaceWidth = 0;\n const { visible: shapeVisible, ...shapeStyle } = shape;\n if (isBoolean(shapeVisible)) {\n const size = shapeStyle?.size || 10;\n const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1])) as number;\n\n symbol = group.createOrUpdateChild(\n 'tag-shape',\n {\n symbolType: 'circle',\n size,\n strokeBoundsBuffer: 0,\n ...shapeStyle,\n visible: shapeVisible,\n x: maxSize / 2,\n y: maxSize / 2\n },\n 'symbol'\n ) as ISymbol;\n if (!isEmpty(state?.shape)) {\n symbol.states = state.shape;\n }\n\n if (shapeVisible) {\n symbolPlaceWidth = maxSize + space;\n }\n }\n\n tagWidth += symbolPlaceWidth;\n textX += symbolPlaceWidth;\n\n let textShape: IRichText | IText;\n const isRich = isRichText({ text } as TextContent) || type === 'rich';\n if (isRich) {\n const richTextAttrs = {\n ...richTextAttributeTransform({ type, text, ...textStyle } as any),\n ...(textStyle as IRichTextGraphicAttribute),\n visible: isValid(text) && visible !== false,\n x: textX,\n y: 0\n };\n textShape = group.createOrUpdateChild('tag-text', richTextAttrs, 'richtext') as IRichText;\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n if (visible && isBoolean(bgVisible)) {\n const bgRect = this.createOrUpdateChild(\n 'tag-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && !!text,\n x: textShape.AABBBounds.x1,\n y: textShape.AABBBounds.y1,\n width: textShape.AABBBounds.width(),\n height: textShape.AABBBounds.height()\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n if (backgroundStyle.customShape) {\n const customShape = backgroundStyle.customShape;\n bgRect.pathProxy = (attrs: Partial<IGraphicAttribute>) => {\n return customShape(textShape.attribute, attrs, new CustomPath2D());\n };\n }\n this._bgRect = bgRect;\n }\n } else {\n const textAttrs = {\n text: isObject(text) && 'type' in text && text.type === 'text' ? text.text : text,\n visible: isValid(text) && visible !== false,\n lineHeight: (textStyle as ITextGraphicAttribute)?.fontSize,\n ...(textStyle as ITextGraphicAttribute),\n x: textX,\n y: 0\n };\n if (isNil(textAttrs.lineHeight)) {\n textAttrs.lineHeight = (textStyle as ITextGraphicAttribute).fontSize;\n }\n textShape = group.createOrUpdateChild('tag-text', textAttrs as ITextGraphicAttribute, 'text') as IText;\n if (!isEmpty(state?.text)) {\n textShape.states = state.text;\n }\n\n // 因为文本可能发生旋转,所以需要使用 measureTextSize 方法\n const textBounds = measureTextSize(textAttrs.text as string, textStyle, this.stage?.getTheme()?.text);\n const textWidth = textBounds.width;\n const textHeight = textBounds.height;\n tagWidth += textWidth;\n const size = shape.size ?? 10;\n const maxSize = (isNumber(size) ? size : Math.max(size[0], size[1])) as number;\n tagHeight += Math.max(textHeight, shape.visible ? maxSize : 0);\n\n const { textAlign, textBaseline } = textStyle as ITextAttribute;\n\n if (isValid(minWidth) || isValid(maxWidth)) {\n if (isValid(minWidth) && tagWidth < minWidth) {\n tagWidth = minWidth;\n }\n if (isValid(maxWidth) && tagWidth > maxWidth) {\n tagWidth = maxWidth;\n textShape.setAttribute('maxLineWidth', maxWidth - parsedPadding[1] - parsedPadding[2]);\n }\n }\n\n let x = 0;\n let y = 0;\n let flag = 0;\n if (textAlign === 'left' || textAlign === 'start') {\n flag = 1;\n } else if (textAlign === 'right' || textAlign === 'end') {\n flag = -1;\n } else if (textAlign === 'center') {\n flag = 0;\n }\n if (!flag) {\n x -= tagWidth / 2;\n if (symbol) {\n symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth / 2);\n }\n\n group.setAttribute('x', -symbolPlaceWidth / 2);\n } else if (flag < 0) {\n x -= tagWidth;\n if (symbol) {\n symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth);\n }\n\n group.setAttribute('x', -parsedPadding[1] - symbolPlaceWidth);\n } else if (flag > 0) {\n group.setAttribute('x', parsedPadding[3]);\n }\n\n const shouldCenter = containerTextAlign ? containerTextAlign === 'center' : textAlwaysCenter;\n const shouldRight = containerTextAlign === 'right' || containerTextAlign === 'end';\n const shouldLeft = containerTextAlign === 'left' || containerTextAlign === 'start';\n\n if (shouldCenter && flag) {\n // 文本容器内居中\n // 剔除padding后的内宽度\n const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];\n const tsWidth = textWidth + symbolPlaceWidth;\n const textX =\n flag === 1\n ? (containerWidth - tsWidth) / 2 + symbolPlaceWidth + textWidth / 2\n : parsedPadding[0] + symbolPlaceWidth - (tagWidth / 2 + tsWidth / 2 - symbolPlaceWidth) + textWidth / 2;\n\n textShape.setAttributes({\n x: textX,\n textAlign: 'center'\n });\n if (symbol) {\n const symbolX = textX - textWidth / 2 - symbolPlaceWidth + maxSize / 2;\n symbol.setAttributes({\n x: symbolX\n });\n }\n }\n\n if (shouldLeft && flag !== 1) {\n // 文本容器内朝左展示\n const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];\n const offset =\n flag === 0\n ? -containerWidth / 2 + symbolPlaceWidth / 2\n : -tagWidth + parsedPadding[3] + parsedPadding[1] + symbolPlaceWidth;\n const textX = offset + symbolPlaceWidth;\n\n textShape.setAttributes({\n x: textX,\n textAlign: 'left'\n });\n\n if (symbol) {\n const symbolX = offset + maxSize / 2;\n symbol.setAttributes({\n x: symbolX\n });\n }\n }\n\n if (shouldRight && flag !== -1) {\n // 文本容器内朝右展示\n const containerWidth = tagWidth - parsedPadding[1] - parsedPadding[3];\n const textX = flag === 0 ? containerWidth / 2 + symbolPlaceWidth / 2 : containerWidth;\n\n textShape.setAttributes({\n x: textX,\n textAlign: 'right'\n });\n if (symbol) {\n const symbolX = textX - textWidth - symbolPlaceWidth + maxSize / 2;\n symbol.setAttributes({\n x: symbolX\n });\n }\n }\n\n if (textBaseline === 'middle') {\n y -= tagHeight / 2;\n if (symbol) {\n symbol.setAttribute('y', 0);\n }\n } else if (textBaseline === 'bottom') {\n y -= tagHeight;\n if (symbol) {\n symbol.setAttribute('y', -textHeight / 2);\n }\n\n group.setAttribute('y', -parsedPadding[2]);\n } else if (textBaseline === 'top') {\n group.setAttribute('y', parsedPadding[0]);\n if (symbol) {\n symbol.setAttribute('y', textHeight / 2);\n }\n }\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n if (visible && isBoolean(bgVisible)) {\n const bgRect = this.createOrUpdateChild(\n 'tag-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && !!text,\n x,\n y,\n width: tagWidth,\n height: tagHeight\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n if (backgroundStyle.customShape) {\n const customShape = backgroundStyle.customShape;\n bgRect.pathProxy = (attrs: Partial<IGraphicAttribute>) => {\n return customShape(textShape.attribute, attrs, new CustomPath2D());\n };\n }\n this._bgRect = bgRect;\n }\n }\n this._textShape = textShape;\n this._symbol = symbol;\n\n this.resetStates();\n }\n\n initAttributes(params: TagAttributes, options?: ComponentOptions) {\n params = options?.skipDefault ? params : merge({}, Tag.defaultAttributes, params);\n super.initAttributes(params);\n this.render();\n }\n\n addState(stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean): void {\n super.addState(stateName, keepCurrentStates, hasAnimation);\n if (this._textShape) {\n this._textShape.addState(stateName, keepCurrentStates, hasAnimation);\n }\n if (this._bgRect) {\n this._bgRect.addState(stateName, keepCurrentStates, hasAnimation);\n }\n if (this._symbol) {\n this._symbol.addState(stateName, keepCurrentStates, hasAnimation);\n }\n }\n\n removeState(stateName: string, hasAnimation?: boolean): void {\n super.removeState(stateName, hasAnimation);\n if (this._textShape) {\n this._textShape.removeState(stateName, hasAnimation);\n }\n if (this._bgRect) {\n this._bgRect.removeState(stateName, hasAnimation);\n }\n if (this._symbol) {\n this._symbol.removeState(stateName, hasAnimation);\n }\n }\n\n cacheStates() {\n this._tagStates = this.currentStates?.slice() ?? [];\n this._rectStates = this._bgRect?.currentStates?.slice() ?? [];\n this._symbolStates = this._symbol?.currentStates?.slice() ?? [];\n this._textStates = this._textShape?.currentStates?.slice() ?? [];\n this.clearStates();\n this._bgRect?.clearStates();\n this._symbol?.clearStates();\n this._textShape?.clearStates();\n }\n resetStates() {\n this._tagStates.length && this.useStates(this._tagStates);\n this._rectStates.length && this._bgRect?.useStates(this._rectStates);\n this._symbolStates.length && this._symbol?.useStates(this._symbolStates);\n this._textStates.length && this._textShape?.useStates(this._textStates);\n }\n}\n"]}
|
package/dist/index.es.js
CHANGED
|
@@ -14734,9 +14734,14 @@ class Tag extends AbstractComponent {
|
|
|
14734
14734
|
constructor(attributes, options) {
|
|
14735
14735
|
super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, Tag.defaultAttributes, attributes));
|
|
14736
14736
|
this.name = 'tag';
|
|
14737
|
+
this._tagStates = [];
|
|
14738
|
+
this._rectStates = [];
|
|
14739
|
+
this._symbolStates = [];
|
|
14740
|
+
this._textStates = [];
|
|
14737
14741
|
}
|
|
14738
14742
|
render() {
|
|
14739
14743
|
var _a, _b, _c;
|
|
14744
|
+
this.cacheStates();
|
|
14740
14745
|
const { text = '', textStyle = {}, shape = {}, panel = {}, space = 4, minWidth, maxWidth, padding = 4, visible, state, type, textAlwaysCenter, containerTextAlign } = this.attribute;
|
|
14741
14746
|
const parsedPadding = normalizePadding(padding);
|
|
14742
14747
|
const group = this.createOrUpdateChild('tag-content', { x: 0, y: 0, zIndex: 1 }, 'group');
|
|
@@ -14921,6 +14926,55 @@ class Tag extends AbstractComponent {
|
|
|
14921
14926
|
}
|
|
14922
14927
|
}
|
|
14923
14928
|
this._textShape = textShape;
|
|
14929
|
+
this._symbol = symbol;
|
|
14930
|
+
this.resetStates();
|
|
14931
|
+
}
|
|
14932
|
+
initAttributes(params, options) {
|
|
14933
|
+
params = (options === null || options === void 0 ? void 0 : options.skipDefault) ? params : merge({}, Tag.defaultAttributes, params);
|
|
14934
|
+
super.initAttributes(params);
|
|
14935
|
+
this.render();
|
|
14936
|
+
}
|
|
14937
|
+
addState(stateName, keepCurrentStates, hasAnimation) {
|
|
14938
|
+
super.addState(stateName, keepCurrentStates, hasAnimation);
|
|
14939
|
+
if (this._textShape) {
|
|
14940
|
+
this._textShape.addState(stateName, keepCurrentStates, hasAnimation);
|
|
14941
|
+
}
|
|
14942
|
+
if (this._bgRect) {
|
|
14943
|
+
this._bgRect.addState(stateName, keepCurrentStates, hasAnimation);
|
|
14944
|
+
}
|
|
14945
|
+
if (this._symbol) {
|
|
14946
|
+
this._symbol.addState(stateName, keepCurrentStates, hasAnimation);
|
|
14947
|
+
}
|
|
14948
|
+
}
|
|
14949
|
+
removeState(stateName, hasAnimation) {
|
|
14950
|
+
super.removeState(stateName, hasAnimation);
|
|
14951
|
+
if (this._textShape) {
|
|
14952
|
+
this._textShape.removeState(stateName, hasAnimation);
|
|
14953
|
+
}
|
|
14954
|
+
if (this._bgRect) {
|
|
14955
|
+
this._bgRect.removeState(stateName, hasAnimation);
|
|
14956
|
+
}
|
|
14957
|
+
if (this._symbol) {
|
|
14958
|
+
this._symbol.removeState(stateName, hasAnimation);
|
|
14959
|
+
}
|
|
14960
|
+
}
|
|
14961
|
+
cacheStates() {
|
|
14962
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
14963
|
+
this._tagStates = (_b = (_a = this.currentStates) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : [];
|
|
14964
|
+
this._rectStates = (_e = (_d = (_c = this._bgRect) === null || _c === void 0 ? void 0 : _c.currentStates) === null || _d === void 0 ? void 0 : _d.slice()) !== null && _e !== void 0 ? _e : [];
|
|
14965
|
+
this._symbolStates = (_h = (_g = (_f = this._symbol) === null || _f === void 0 ? void 0 : _f.currentStates) === null || _g === void 0 ? void 0 : _g.slice()) !== null && _h !== void 0 ? _h : [];
|
|
14966
|
+
this._textStates = (_l = (_k = (_j = this._textShape) === null || _j === void 0 ? void 0 : _j.currentStates) === null || _k === void 0 ? void 0 : _k.slice()) !== null && _l !== void 0 ? _l : [];
|
|
14967
|
+
this.clearStates();
|
|
14968
|
+
(_m = this._bgRect) === null || _m === void 0 ? void 0 : _m.clearStates();
|
|
14969
|
+
(_o = this._symbol) === null || _o === void 0 ? void 0 : _o.clearStates();
|
|
14970
|
+
(_p = this._textShape) === null || _p === void 0 ? void 0 : _p.clearStates();
|
|
14971
|
+
}
|
|
14972
|
+
resetStates() {
|
|
14973
|
+
var _a, _b, _c;
|
|
14974
|
+
this._tagStates.length && this.useStates(this._tagStates);
|
|
14975
|
+
this._rectStates.length && ((_a = this._bgRect) === null || _a === void 0 ? void 0 : _a.useStates(this._rectStates));
|
|
14976
|
+
this._symbolStates.length && ((_b = this._symbol) === null || _b === void 0 ? void 0 : _b.useStates(this._symbolStates));
|
|
14977
|
+
this._textStates.length && ((_c = this._textShape) === null || _c === void 0 ? void 0 : _c.useStates(this._textStates));
|
|
14924
14978
|
}
|
|
14925
14979
|
}
|
|
14926
14980
|
Tag.defaultAttributes = {
|
|
@@ -26600,6 +26654,15 @@ const forwardStep = (direction, currentIndex, min, max) => {
|
|
|
26600
26654
|
};
|
|
26601
26655
|
|
|
26602
26656
|
class BasePlayer extends AbstractComponent {
|
|
26657
|
+
getMinIndex() {
|
|
26658
|
+
return this._minIndex;
|
|
26659
|
+
}
|
|
26660
|
+
getMaxIndex() {
|
|
26661
|
+
return this._maxIndex;
|
|
26662
|
+
}
|
|
26663
|
+
getDataIndex() {
|
|
26664
|
+
return this._dataIndex;
|
|
26665
|
+
}
|
|
26603
26666
|
constructor(attributes, options) {
|
|
26604
26667
|
super((options === null || options === void 0 ? void 0 : options.skipDefault) ? attributes : merge({}, BasePlayer.defaultAttributes, attributes));
|
|
26605
26668
|
this._data = [];
|
|
@@ -28290,6 +28353,12 @@ class CheckBox extends AbstractComponent {
|
|
|
28290
28353
|
y: textY
|
|
28291
28354
|
});
|
|
28292
28355
|
}
|
|
28356
|
+
initAttributes(params, options) {
|
|
28357
|
+
params = (options === null || options === void 0 ? void 0 : options.skipDefault) ? params : merge({}, CheckBox.defaultAttributes, params);
|
|
28358
|
+
super.initAttributes(params);
|
|
28359
|
+
this.renderGroup();
|
|
28360
|
+
this.render();
|
|
28361
|
+
}
|
|
28293
28362
|
}
|
|
28294
28363
|
CheckBox.defaultAttributes = {
|
|
28295
28364
|
interactive: true,
|
|
@@ -28419,6 +28488,12 @@ class Radio extends AbstractComponent {
|
|
|
28419
28488
|
y: textY
|
|
28420
28489
|
});
|
|
28421
28490
|
}
|
|
28491
|
+
initAttributes(params, options) {
|
|
28492
|
+
params = (options === null || options === void 0 ? void 0 : options.skipDefault) ? params : merge({}, Radio.defaultAttributes, params);
|
|
28493
|
+
super.initAttributes(params);
|
|
28494
|
+
this.renderGroup();
|
|
28495
|
+
this.render();
|
|
28496
|
+
}
|
|
28422
28497
|
}
|
|
28423
28498
|
Radio.defaultAttributes = {
|
|
28424
28499
|
interactive: true,
|
|
@@ -28508,6 +28583,6 @@ EmptyTip.defaultAttributes = {
|
|
|
28508
28583
|
}
|
|
28509
28584
|
};
|
|
28510
28585
|
|
|
28511
|
-
const version = "0.20.
|
|
28586
|
+
const version = "0.20.1-alpha.1";
|
|
28512
28587
|
|
|
28513
28588
|
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, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, 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 };
|
|
@@ -8,6 +8,7 @@ export declare class CheckBox extends AbstractComponent<Required<CheckboxAttribu
|
|
|
8
8
|
_checkIcon: Image;
|
|
9
9
|
_indeterminateIcon: Image;
|
|
10
10
|
_text: Text;
|
|
11
|
+
name: 'checkbox';
|
|
11
12
|
constructor(attributes: CheckboxAttributes, options?: ComponentOptions);
|
|
12
13
|
render(): void;
|
|
13
14
|
renderBox(): void;
|
|
@@ -16,4 +17,5 @@ export declare class CheckBox extends AbstractComponent<Required<CheckboxAttribu
|
|
|
16
17
|
renderGroup(): void;
|
|
17
18
|
layout(): void;
|
|
18
19
|
private _handlePointerUp;
|
|
20
|
+
initAttributes(params: CheckboxAttributes, options?: ComponentOptions): void;
|
|
19
21
|
}
|
package/es/checkbox/checkbox.js
CHANGED
|
@@ -74,6 +74,10 @@ export class CheckBox extends AbstractComponent {
|
|
|
74
74
|
y: textY
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
+
initAttributes(params, options) {
|
|
78
|
+
params = (null == options ? void 0 : options.skipDefault) ? params : merge({}, CheckBox.defaultAttributes, params),
|
|
79
|
+
super.initAttributes(params), this.renderGroup(), this.render();
|
|
80
|
+
}
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
CheckBox.defaultAttributes = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/checkbox/checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,QAAQ,GACZ,wrBAAwrB,CAAC;AAE3rB,MAAM,gBAAgB,GACpB,2MAA2M,CAAC;AAE9M,qBAAqB,EAAE,CAAC;AACxB,MAAM,OAAO,QAAS,SAAQ,iBAA+C;IA2C3E,YAAY,UAA8B,EAAE,OAA0B;QACpE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAsHvF,qBAAgB,GAAG,GAAG,EAAE;YAC9B,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;gBAC3B,OAAO;aACR;iBAAM,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;gBACjC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;gBACpC,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;aAC3C;iBAAM;gBACL,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,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I,CAAC,KAAK,CAAC,aAAa,CAAC;YACvB,CAAC,EAAE,KAAK;YACR,CAAC,EAAE,KAAK;SACT,CAAC,CAAC;IACL,CAAC;;AA/JM,0BAAiB,GAAgC;IACtD,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;IACd,aAAa,EAAE,KAAK;IACpB,MAAM,EAAE,SAAS;IACjB,aAAa,EAAE,aAAa;IAC5B,uBAAuB,EAAE,CAAC;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,kBAAkB;QAC/B,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,KAAK;KAChB;IACD,IAAI,EAAE;QACJ,cAAc,EAAE,QAAQ;QACxB,sBAAsB,EAAE,gBAAgB;QACxC,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,KAAK;KAChB;IACD,GAAG,EAAE;QACH,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,CAAC;QACf,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,kBAAkB;QAC1B,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,kBAAkB;QAC/B,aAAa,EAAE,kBAAkB;QACjC,kBAAkB,EAAE,oBAAoB;QACxC,oBAAoB,EAAE,oBAAoB;QAC1C,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC","file":"checkbox.js","sourcesContent":["import { merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { CheckboxAttributes } from './type';\nimport { Image, Rect, Text } from '@visactor/vrender-core';\nimport type { ComponentOptions } from '../interface';\nimport { loadCheckBoxComponent } from './register';\n\nconst checkSvg =\n '<svg width=\"200\" height=\"200\" viewBox=\"0 0 1024 1024\" fill=\"#fff\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M877.44815445 206.10060629a64.72691371 64.72691371 0 0 0-95.14856334 4.01306852L380.73381888 685.46812814 235.22771741 533.48933518a64.72691371 64.72691371 0 0 0-92.43003222-1.03563036l-45.82665557 45.82665443a64.72691371 64.72691371 0 0 0-0.90617629 90.61767965l239.61903446 250.10479331a64.72691371 64.72691371 0 0 0 71.19960405 15.14609778 64.33855261 64.33855261 0 0 0 35.08198741-21.23042702l36.24707186-42.71976334 40.5190474-40.77795556-3.36579926-3.49525333 411.40426297-486.74638962a64.72691371 64.72691371 0 0 0-3.88361443-87.64024149l-45.3088404-45.43829334z\"></path></svg>';\n\nconst indeterminateSvg =\n '<svg width=\"200\" height=\"200\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\"><path stroke=\"#fff\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"5\" d=\"M5 12h14\"/></svg>';\n\nloadCheckBoxComponent();\nexport class CheckBox extends AbstractComponent<Required<CheckboxAttributes>> {\n static defaultAttributes: Partial<CheckboxAttributes> = {\n interactive: true,\n disabled: false,\n checked: false,\n indeterminate: false,\n cursor: 'pointer',\n disableCursor: 'not-allowed',\n spaceBetweenTextAndIcon: 8,\n text: {\n text: 'text',\n fontSize: 14,\n fill: '#000',\n disableFill: 'rgb(201,205,212)',\n textBaseline: 'top',\n pickable: false\n },\n icon: {\n checkIconImage: checkSvg,\n indeterminateIconImage: indeterminateSvg,\n width: 10,\n height: 10,\n pickable: false\n },\n box: {\n width: 14,\n height: 14,\n cornerRadius: 2,\n fill: '#fff',\n stroke: 'rgb(229,230,235)',\n disableFill: 'rgb(242,243,245)',\n checkedFill: 'rgb(22, 93, 255)',\n checkedStroke: 'rgb(22, 93, 255)',\n disableCheckedFill: 'rgb(148, 191, 255)',\n disableCheckedStroke: 'rgb(148, 191, 255)',\n pickable: false\n }\n };\n _box: Rect;\n _checkIcon: Image;\n _indeterminateIcon: Image;\n _text: Text;\n\n constructor(attributes: CheckboxAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, CheckBox.defaultAttributes, attributes));\n this.renderGroup();\n\n this.onBeforeAttributeUpdate = (val: any, attributes: any, key: null | string | string[]) => {\n if ('interactive' in val) {\n this.setAttribute('pickable', val.interactive);\n }\n if ('disabled' in val) {\n this.setAttribute('cursor', val.disable ? this.attribute.disableCursor : this.attribute.cursor);\n }\n return undefined;\n };\n\n this.addEventListener('pointerup', this._handlePointerUp);\n }\n\n render() {\n this.removeAllChild(true);\n\n this.renderBox();\n this.renderIcon();\n this.renderText();\n this.layout();\n }\n\n renderBox() {\n this._box = new Rect(merge({}, this.attribute.box));\n const isCheckedOrIndeterminate = this.attribute.checked || this.attribute.indeterminate;\n if (isCheckedOrIndeterminate && this.attribute.disabled) {\n this._box.setAttributes({\n fill: this.attribute.box.disableCheckedFill,\n stroke: this.attribute.box.disableCheckedStroke\n });\n } else if (isCheckedOrIndeterminate) {\n this._box.setAttributes({\n fill: this.attribute.box.checkedFill,\n stroke: this.attribute.box.checkedStroke\n });\n }\n this.appendChild(this._box);\n }\n\n renderIcon() {\n this._checkIcon = new Image(merge({ image: this.attribute.icon.checkIconImage }, this.attribute.icon));\n this.appendChild(this._checkIcon);\n this._indeterminateIcon = new Image(\n merge(\n {\n image: this.attribute.icon.indeterminateIconImage\n },\n this.attribute.icon\n )\n );\n this.appendChild(this._indeterminateIcon);\n\n if (this.attribute.checked) {\n this._checkIcon.setAttribute('visible', true);\n this._indeterminateIcon.setAttribute('visible', false);\n } else if (this.attribute.indeterminate) {\n this._checkIcon.setAttribute('visible', false);\n this._indeterminateIcon.setAttribute('visible', true);\n } else {\n this._checkIcon.setAttribute('visible', false);\n this._indeterminateIcon.setAttribute('visible', false);\n }\n }\n\n renderText() {\n this._text = new Text(merge({ wrap: true }, this.attribute.text));\n if (this.attribute.disabled) {\n this._text.setAttribute('fill', this.attribute.text.disableFill);\n }\n this.appendChild(this._text);\n }\n\n renderGroup() {\n if (!this.attribute.interactive) {\n this.setAttribute('pickable', false);\n }\n if (this.attribute.disabled) {\n this.setAttribute('cursor', this.attribute.disableCursor);\n }\n }\n\n layout() {\n const boxHeight = this.attribute.box.height;\n const iconHeight = this.attribute.icon.height;\n const textHeight = this._text.AABBBounds.height();\n const maxHeight = Math.max(boxHeight, iconHeight, textHeight);\n const boxY = maxHeight / 2 - boxHeight / 2;\n const iconY = maxHeight / 2 - iconHeight / 2;\n const textY = maxHeight / 2 - textHeight / 2;\n\n const boxWidth = this.attribute.box.width;\n const iconWidth = this.attribute.icon.width;\n const maxWidth = Math.max(boxWidth, iconWidth);\n const boxX = maxWidth / 2 - boxWidth / 2;\n const iconX = maxWidth / 2 - iconWidth / 2;\n const textX = maxWidth + this.attribute.spaceBetweenTextAndIcon;\n\n this._box.setAttributes({\n x: boxX,\n y: boxY\n });\n this._checkIcon.setAttributes({\n x: iconX,\n y: iconY\n });\n this._indeterminateIcon.setAttributes({\n x: iconX,\n y: iconY\n });\n this._text.setAttributes({\n x: textX,\n y: textY\n });\n }\n\n private _handlePointerUp = () => {\n if (this.attribute.disabled) {\n return;\n } else if (this.attribute.checked) {\n this.setAttribute('checked', false);\n this.setAttribute('indeterminate', false);\n } else {\n this.setAttribute('checked', true);\n this.setAttribute('indeterminate', false);\n }\n\n this._dispatchEvent('checkbox_state_change', {\n eventType: 'checkbox_state_change',\n checked: this.attribute.checked\n });\n\n this.stage.renderNextFrame();\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/checkbox/checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,QAAQ,GACZ,wrBAAwrB,CAAC;AAE3rB,MAAM,gBAAgB,GACp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B,MAAM,EAAE,SAAS;IACjB,aAAa,EAAE,aAAa;IAC5B,uBAAuB,EAAE,CAAC;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,kBAAkB;QAC/B,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,KAAK;KAChB;IACD,IAAI,EAAE;QACJ,cAAc,EAAE,QAAQ;QACxB,sBAAsB,EAAE,gBAAgB;QACxC,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,KAAK;KAChB;IACD,GAAG,EAAE;QACH,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,CAAC;QACf,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,kBAAkB;QAC1B,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,kBAAkB;QAC/B,aAAa,EAAE,kBAAkB;QACjC,kBAAkB,EAAE,oBAAoB;QACxC,oBAAoB,EAAE,oBAAoB;QAC1C,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC","file":"checkbox.js","sourcesContent":["import { merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { CheckboxAttributes } from './type';\nimport { Image, Rect, Text } from '@visactor/vrender-core';\nimport type { ComponentOptions } from '../interface';\nimport { loadCheckBoxComponent } from './register';\n\nconst checkSvg =\n '<svg width=\"200\" height=\"200\" viewBox=\"0 0 1024 1024\" fill=\"#fff\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M877.44815445 206.10060629a64.72691371 64.72691371 0 0 0-95.14856334 4.01306852L380.73381888 685.46812814 235.22771741 533.48933518a64.72691371 64.72691371 0 0 0-92.43003222-1.03563036l-45.82665557 45.82665443a64.72691371 64.72691371 0 0 0-0.90617629 90.61767965l239.61903446 250.10479331a64.72691371 64.72691371 0 0 0 71.19960405 15.14609778 64.33855261 64.33855261 0 0 0 35.08198741-21.23042702l36.24707186-42.71976334 40.5190474-40.77795556-3.36579926-3.49525333 411.40426297-486.74638962a64.72691371 64.72691371 0 0 0-3.88361443-87.64024149l-45.3088404-45.43829334z\"></path></svg>';\n\nconst indeterminateSvg =\n '<svg width=\"200\" height=\"200\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\"><path stroke=\"#fff\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"5\" d=\"M5 12h14\"/></svg>';\n\nloadCheckBoxComponent();\nexport class CheckBox extends AbstractComponent<Required<CheckboxAttributes>> {\n static defaultAttributes: Partial<CheckboxAttributes> = {\n interactive: true,\n disabled: false,\n checked: false,\n indeterminate: false,\n cursor: 'pointer',\n disableCursor: 'not-allowed',\n spaceBetweenTextAndIcon: 8,\n text: {\n text: 'text',\n fontSize: 14,\n fill: '#000',\n disableFill: 'rgb(201,205,212)',\n textBaseline: 'top',\n pickable: false\n },\n icon: {\n checkIconImage: checkSvg,\n indeterminateIconImage: indeterminateSvg,\n width: 10,\n height: 10,\n pickable: false\n },\n box: {\n width: 14,\n height: 14,\n cornerRadius: 2,\n fill: '#fff',\n stroke: 'rgb(229,230,235)',\n disableFill: 'rgb(242,243,245)',\n checkedFill: 'rgb(22, 93, 255)',\n checkedStroke: 'rgb(22, 93, 255)',\n disableCheckedFill: 'rgb(148, 191, 255)',\n disableCheckedStroke: 'rgb(148, 191, 255)',\n pickable: false\n }\n };\n _box: Rect;\n _checkIcon: Image;\n _indeterminateIcon: Image;\n _text: Text;\n\n name: 'checkbox';\n\n constructor(attributes: CheckboxAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, CheckBox.defaultAttributes, attributes));\n this.renderGroup();\n\n this.onBeforeAttributeUpdate = (val: any, attributes: any, key: null | string | string[]) => {\n if ('interactive' in val) {\n this.setAttribute('pickable', val.interactive);\n }\n if ('disabled' in val) {\n this.setAttribute('cursor', val.disable ? this.attribute.disableCursor : this.attribute.cursor);\n }\n return undefined;\n };\n\n this.addEventListener('pointerup', this._handlePointerUp);\n }\n\n render() {\n this.removeAllChild(true);\n\n this.renderBox();\n this.renderIcon();\n this.renderText();\n this.layout();\n }\n\n renderBox() {\n this._box = new Rect(merge({}, this.attribute.box));\n const isCheckedOrIndeterminate = this.attribute.checked || this.attribute.indeterminate;\n if (isCheckedOrIndeterminate && this.attribute.disabled) {\n this._box.setAttributes({\n fill: this.attribute.box.disableCheckedFill,\n stroke: this.attribute.box.disableCheckedStroke\n });\n } else if (isCheckedOrIndeterminate) {\n this._box.setAttributes({\n fill: this.attribute.box.checkedFill,\n stroke: this.attribute.box.checkedStroke\n });\n }\n this.appendChild(this._box);\n }\n\n renderIcon() {\n this._checkIcon = new Image(merge({ image: this.attribute.icon.checkIconImage }, this.attribute.icon));\n this.appendChild(this._checkIcon);\n this._indeterminateIcon = new Image(\n merge(\n {\n image: this.attribute.icon.indeterminateIconImage\n },\n this.attribute.icon\n )\n );\n this.appendChild(this._indeterminateIcon);\n\n if (this.attribute.checked) {\n this._checkIcon.setAttribute('visible', true);\n this._indeterminateIcon.setAttribute('visible', false);\n } else if (this.attribute.indeterminate) {\n this._checkIcon.setAttribute('visible', false);\n this._indeterminateIcon.setAttribute('visible', true);\n } else {\n this._checkIcon.setAttribute('visible', false);\n this._indeterminateIcon.setAttribute('visible', false);\n }\n }\n\n renderText() {\n this._text = new Text(merge({ wrap: true }, this.attribute.text));\n if (this.attribute.disabled) {\n this._text.setAttribute('fill', this.attribute.text.disableFill);\n }\n this.appendChild(this._text);\n }\n\n renderGroup() {\n if (!this.attribute.interactive) {\n this.setAttribute('pickable', false);\n }\n if (this.attribute.disabled) {\n this.setAttribute('cursor', this.attribute.disableCursor);\n }\n }\n\n layout() {\n const boxHeight = this.attribute.box.height;\n const iconHeight = this.attribute.icon.height;\n const textHeight = this._text.AABBBounds.height();\n const maxHeight = Math.max(boxHeight, iconHeight, textHeight);\n const boxY = maxHeight / 2 - boxHeight / 2;\n const iconY = maxHeight / 2 - iconHeight / 2;\n const textY = maxHeight / 2 - textHeight / 2;\n\n const boxWidth = this.attribute.box.width;\n const iconWidth = this.attribute.icon.width;\n const maxWidth = Math.max(boxWidth, iconWidth);\n const boxX = maxWidth / 2 - boxWidth / 2;\n const iconX = maxWidth / 2 - iconWidth / 2;\n const textX = maxWidth + this.attribute.spaceBetweenTextAndIcon;\n\n this._box.setAttributes({\n x: boxX,\n y: boxY\n });\n this._checkIcon.setAttributes({\n x: iconX,\n y: iconY\n });\n this._indeterminateIcon.setAttributes({\n x: iconX,\n y: iconY\n });\n this._text.setAttributes({\n x: textX,\n y: textY\n });\n }\n\n private _handlePointerUp = () => {\n if (this.attribute.disabled) {\n return;\n } else if (this.attribute.checked) {\n this.setAttribute('checked', false);\n this.setAttribute('indeterminate', false);\n } else {\n this.setAttribute('checked', true);\n this.setAttribute('indeterminate', false);\n }\n\n this._dispatchEvent('checkbox_state_change', {\n eventType: 'checkbox_state_change',\n checked: this.attribute.checked\n });\n\n this.stage.renderNextFrame();\n };\n\n initAttributes(params: CheckboxAttributes, options?: ComponentOptions) {\n params = options?.skipDefault ? params : merge({}, CheckBox.defaultAttributes, params);\n super.initAttributes(params);\n this.renderGroup();\n this.render();\n }\n}\n"]}
|
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.1-alpha.1\";\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"]}
|
|
@@ -3,7 +3,7 @@ import type { ComponentOptions } from '../interface';
|
|
|
3
3
|
import { Slider } from '../slider';
|
|
4
4
|
import { Controller } from './controller';
|
|
5
5
|
import type { PlayerEventEnum, PlayerAttributes } from './type';
|
|
6
|
-
export declare class BasePlayer<T> extends AbstractComponent<Required<PlayerAttributes>> {
|
|
6
|
+
export declare abstract class BasePlayer<T> extends AbstractComponent<Required<PlayerAttributes>> {
|
|
7
7
|
static defaultAttributes: {
|
|
8
8
|
visible: boolean;
|
|
9
9
|
data: any[];
|
|
@@ -89,7 +89,9 @@ export declare class BasePlayer<T> extends AbstractComponent<Required<PlayerAttr
|
|
|
89
89
|
protected _controller: Controller;
|
|
90
90
|
protected _data: any[];
|
|
91
91
|
protected _minIndex: number;
|
|
92
|
+
getMinIndex(): number;
|
|
92
93
|
protected _maxIndex: number;
|
|
94
|
+
getMaxIndex(): number;
|
|
93
95
|
private _sliderVisible;
|
|
94
96
|
private _railStyle;
|
|
95
97
|
private _trackStyle;
|
|
@@ -102,7 +104,12 @@ export declare class BasePlayer<T> extends AbstractComponent<Required<PlayerAttr
|
|
|
102
104
|
private _size;
|
|
103
105
|
private _orient;
|
|
104
106
|
protected _dataIndex: number;
|
|
107
|
+
getDataIndex(): number;
|
|
105
108
|
private _layoutInfo;
|
|
109
|
+
abstract play(): void;
|
|
110
|
+
abstract pause(): void;
|
|
111
|
+
abstract backward(): void;
|
|
112
|
+
abstract forward(): void;
|
|
106
113
|
constructor(attributes: T, options?: ComponentOptions);
|
|
107
114
|
_initAttributes(): void;
|
|
108
115
|
_initDataIndex(): void;
|
package/es/player/base-player.js
CHANGED
|
@@ -11,6 +11,15 @@ import { RailDefaultSize, defaultControllerAttributes } from "./constant";
|
|
|
11
11
|
import { isHorizontal } from "./utils";
|
|
12
12
|
|
|
13
13
|
export class BasePlayer extends AbstractComponent {
|
|
14
|
+
getMinIndex() {
|
|
15
|
+
return this._minIndex;
|
|
16
|
+
}
|
|
17
|
+
getMaxIndex() {
|
|
18
|
+
return this._maxIndex;
|
|
19
|
+
}
|
|
20
|
+
getDataIndex() {
|
|
21
|
+
return this._dataIndex;
|
|
22
|
+
}
|
|
14
23
|
constructor(attributes, options) {
|
|
15
24
|
super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, BasePlayer.defaultAttributes, attributes)),
|
|
16
25
|
this._data = [], this._dataIndex = 0, this._layoutInfo = {}, this._updateSliderAttrs = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{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AAE,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 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 protected _maxIndex: number;\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\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 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"]}
|
|
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,SAAS,CAAC;AAMvC,MAAM,OAAgB,UAAc,SAAQ,iBAA6C;IAsCvF,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAqBD,YAAY;QACV,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAkBD,YAAY,UAAa,EAAE,OAA0B;QACnD,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAlDvF,UAAK,GAAG,EAAa,CAAC;QA4BtB,eAAU,GAAW,CAAC,CAAC;QAKzB,gBAAW,GASf,EAAE,CAAC;QAgIC,uBAAkB,GAAG,GAAG,EAAE;;YAChC,IAAI,WAAW,CAAC;YAChB,IAAI,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;gBAC1C,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;aACvC;iBAAM,IAA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CAAC,SAAS,CAAC;SAC7B,CAAC,CAAC;IACL,CAAC;;AA9WM,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"]}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { BasePlayer } from './base-player';
|
|
2
2
|
import type { ContinuousPlayerAttributes } from './type';
|
|
3
3
|
import { PlayerEventEnum } from './type';
|
|
4
|
-
export
|
|
5
|
-
play: () => Promise<void>;
|
|
6
|
-
pause: () => void;
|
|
7
|
-
forward: () => void;
|
|
8
|
-
backward: () => void;
|
|
9
|
-
}
|
|
10
|
-
export declare class ContinuousPlayer extends BasePlayer<ContinuousPlayerAttributes> implements IContinuousPlayer {
|
|
4
|
+
export declare class ContinuousPlayer extends BasePlayer<ContinuousPlayerAttributes> {
|
|
11
5
|
attribute: ContinuousPlayerAttributes;
|
|
12
6
|
private _activeIndex;
|
|
13
7
|
protected _alternate: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/player/continuous-player.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACz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AG,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;YAEpC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAEzC,IAAI,OAAO,IAAI,IAAI,CAAC,cAAc,EAAE;gBAClC,IAAI,CAAC,UAAU,GAAG,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC;gBAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC;aACrC;iBAEI;gBACH,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC;gBAC7C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;aACzB;YAED,IAAI,CAAC,aAAa,EAAE,CAAC;YAErB,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACpD,CAAC,CAAC;QAxPA,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAoHD,mBAAmB,CAAC,SAA0B;QAC5C,KAAK,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;IAiID,MAAM;QACJ,KAAK,CAAC,MAAM,EAAE,CAAC;IACjB,CAAC;CACF","file":"continuous-player.js","sourcesContent":["import type { FederatedPointerEvent } from '@visactor/vrender-core';\nimport { vglobal } from '@visactor/vrender-core';\nimport { BasePlayer } from './base-player';\nimport type { ContinuousPlayerAttributes } from './type';\nimport { PlayerEventEnum } from './type';\nimport { ControllerEventEnum } from './controller/constant';\nimport { loadContinuousPlayerComponent } from './register';\n\nexport interface IContinuousPlayer {\n play: () => Promise<void>;\n pause: () => void;\n forward: () => void;\n backward: () => void;\n}\n\nloadContinuousPlayerComponent();\nexport class ContinuousPlayer extends BasePlayer<ContinuousPlayerAttributes> implements IContinuousPlayer {\n declare attribute: ContinuousPlayerAttributes;\n\n private _activeIndex: number;\n\n protected _alternate: boolean;\n protected _interval: number;\n protected _totalDuration: number;\n\n private _isPlaying = false;\n private _startTime: number = Date.now();\n private _elapsed: number;\n private _rafId: number;\n\n constructor(attributes: ContinuousPlayerAttributes) {\n super(attributes);\n\n this._initAttributes();\n this._initDataIndex();\n this._initEvents();\n }\n\n /**\n * 初始化属性\n */\n _initAttributes = () => {\n super._initAttributes();\n // 新增一个占位数据\n this._maxIndex = this._data.length;\n this._slider.setAttribute('max', this._maxIndex);\n\n this._isPlaying = false;\n this._elapsed = 0;\n this._interval = this.attribute.interval ?? 1000;\n\n // 播放帧数(10条数据, 需要10个播放帧)\n const frames = this._data.length;\n\n // 若用户配置了总时长\n if (this.attribute.totalDuration && this._data.length) {\n this._totalDuration = this.attribute.totalDuration;\n // 避免除0\n this._interval = this._totalDuration / (frames ?? 1);\n }\n // 若未配置总时长, 则根据interval算出一个总时长, interval有默认值\n else {\n this._totalDuration = this._interval * frames;\n this._interval = this.attribute.interval;\n }\n };\n\n /**\n * 初始化dataIndex\n */\n _initDataIndex = () => {\n this._dataIndex = this.attribute.dataIndex ?? this._minIndex;\n };\n\n /**\n * 初始化事件\n */\n private _initEvents = () => {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n this._controller.addEventListener(ControllerEventEnum.OnPlay, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.play();\n });\n this._controller.addEventListener(ControllerEventEnum.OnPause, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.pause();\n });\n this._controller.addEventListener(ControllerEventEnum.OnForward, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.forward();\n });\n this._controller.addEventListener(ControllerEventEnum.OnBackward, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.backward();\n });\n\n this._slider.addEventListener('change', (e: FederatedPointerEvent) => {\n e.stopPropagation();\n /**\n * 根据value, 反推开始时间\n * 1. 计算进度\n * 2. 计算流逝时间\n * 3. 用现在的时间, 模拟一个开始时间\n */\n const value = (e.detail as unknown as { value: number; position: number })?.value;\n const progress = value / this._maxIndex;\n this._elapsed = progress * this._totalDuration;\n this._startTime = Date.now() - this._elapsed;\n\n this._dispatchChange(value);\n });\n };\n\n /**\n * 根据已流逝时间和总时长, 计算slider的值\n */\n private _getSliderValue = () => {\n const progress = this._elapsed / this._totalDuration;\n return Math.min(progress * this._maxIndex, this._maxIndex);\n };\n\n /**\n * 根据流逝时间, 更新Slider的值\n */\n private _updateSlider = () => {\n const value = this._getSliderValue();\n this._dataIndex = Math.floor(value);\n this._slider.setValue(Math.min(value, this._maxIndex));\n this._dispatchChange(Math.floor(value));\n };\n\n /**\n * 根据Slider的值, 判断是否要触发Change事件.\n */\n private _dispatchChange = (value: number) => {\n const index = Math.floor(value);\n if (index !== this._activeIndex) {\n this._dataIndex = index;\n this._activeIndex = index;\n\n if (index !== this._maxIndex) {\n this.dispatchCustomEvent(PlayerEventEnum.change);\n }\n }\n };\n\n /**\n * 派遣事件\n * @param eventType 事件类型\n */\n dispatchCustomEvent(eventType: PlayerEventEnum) {\n super.dispatchCustomEvent(eventType, this._dataIndex);\n }\n\n /**\n * 播放接口\n */\n play = async () => {\n if (this._isPlaying) {\n return;\n }\n // 切换按钮\n this._controller.togglePause();\n // 播放状态更新\n this._isPlaying = true;\n // 播放结束后再点击play, 此条件下生效.\n if (this._elapsed >= this._totalDuration) {\n this._elapsed = 0;\n }\n // 此时此刻减去已流逝的时间, 则为起点对应的时间戳.\n this._startTime = Date.now() - this._elapsed;\n // 事件\n this.dispatchCustomEvent(PlayerEventEnum.play);\n // 开始播放动画\n this._rafId = vglobal.getRequestAnimationFrame()(this._play.bind(this));\n };\n\n /**\n * 播放动画主要逻辑\n */\n private _play = () => {\n // 计算已流逝的时间, 但不需要保存\n this._elapsed = Date.now() - this._startTime;\n // 计算Slider的值.\n const value = this._getSliderValue();\n // 更新Slider的值.\n this._updateSlider();\n\n // 播放终止条件\n if (value >= this._maxIndex) {\n this._playEnd();\n return;\n }\n\n // 持续播放\n this._rafId = vglobal.getRequestAnimationFrame()(this._play.bind(this));\n };\n\n /**\n * 播放结束时触发\n */\n private _playEnd = () => {\n // 播放状态更新\n this._isPlaying = false;\n // 取消播放动画\n vglobal.getCancelAnimationFrame()(this._rafId);\n // 切换按钮\n this._controller.togglePlay();\n // 事件\n this.dispatchCustomEvent(PlayerEventEnum.end);\n };\n\n /**\n * 暂停接口\n */\n pause = () => {\n if (!this._isPlaying) {\n return;\n }\n this._isPlaying = false;\n // 计算已流逝的时间, 需要记录下来\n this._elapsed = Date.now() - this._startTime;\n vglobal.getCancelAnimationFrame()(this._rafId);\n this._controller.togglePlay();\n\n this.dispatchCustomEvent(PlayerEventEnum.pause);\n };\n\n /**\n * 前进接口\n */\n backward = () => {\n // 按下按钮的时间\n const now = Date.now();\n // 步长\n const interval = this._interval * 1;\n // 流逝时间 减去 interval\n const elapsed = this._elapsed - interval;\n\n // 若到达起点\n if (elapsed <= 0) {\n this._elapsed = 0;\n this._startTime = now;\n }\n // 若未到达起点\n else {\n this._elapsed = elapsed;\n this._startTime = this._startTime + this._interval;\n }\n // 更新slider\n this._updateSlider();\n\n this.dispatchCustomEvent(PlayerEventEnum.backward);\n };\n\n /**\n * 后退接口\n */\n forward = () => {\n // 按下按钮的时间\n const now = Date.now();\n // 步长\n const interval = this._interval * 1;\n // 流逝时间 加上 1个interval\n const elapsed = this._elapsed + interval;\n // 若超过终点\n if (elapsed >= this._totalDuration) {\n this._startTime = now - this._totalDuration;\n this._elapsed = this._totalDuration;\n }\n // 未超过终点\n else {\n this._startTime = this._startTime - interval;\n this._elapsed = elapsed;\n }\n // 更新slider\n this._updateSlider();\n\n this.dispatchCustomEvent(PlayerEventEnum.forward);\n };\n\n render() {\n super.render();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/player/continuous-player.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,e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GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAEvB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;YAEpC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAEzC,IAAI,OAAO,IAAI,IAAI,CAAC,cAAc,EAAE;gBAClC,IAAI,CAAC,UAAU,GAAG,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC;gBAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC;aACrC;iBAEI;gBACH,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC;gBAC7C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;aACzB;YAED,IAAI,CAAC,aAAa,EAAE,CAAC;YAErB,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACpD,CAAC,CAAC;QAxPA,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAoHD,mBAAmB,CAAC,SAA0B;QAC5C,KAAK,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;IAiID,MAAM;QACJ,KAAK,CAAC,MAAM,EAAE,CAAC;IACjB,CAAC;CACF","file":"continuous-player.js","sourcesContent":["import type { FederatedPointerEvent } from '@visactor/vrender-core';\nimport { vglobal } from '@visactor/vrender-core';\nimport { BasePlayer } from './base-player';\nimport type { ContinuousPlayerAttributes } from './type';\nimport { PlayerEventEnum } from './type';\nimport { ControllerEventEnum } from './controller/constant';\nimport { loadContinuousPlayerComponent } from './register';\n\nloadContinuousPlayerComponent();\nexport class ContinuousPlayer extends BasePlayer<ContinuousPlayerAttributes> {\n declare attribute: ContinuousPlayerAttributes;\n\n private _activeIndex: number;\n\n protected _alternate: boolean;\n protected _interval: number;\n protected _totalDuration: number;\n\n private _isPlaying = false;\n private _startTime: number = Date.now();\n private _elapsed: number;\n private _rafId: number;\n\n constructor(attributes: ContinuousPlayerAttributes) {\n super(attributes);\n\n this._initAttributes();\n this._initDataIndex();\n this._initEvents();\n }\n\n /**\n * 初始化属性\n */\n _initAttributes = () => {\n super._initAttributes();\n // 新增一个占位数据\n this._maxIndex = this._data.length;\n this._slider.setAttribute('max', this._maxIndex);\n\n this._isPlaying = false;\n this._elapsed = 0;\n this._interval = this.attribute.interval ?? 1000;\n\n // 播放帧数(10条数据, 需要10个播放帧)\n const frames = this._data.length;\n\n // 若用户配置了总时长\n if (this.attribute.totalDuration && this._data.length) {\n this._totalDuration = this.attribute.totalDuration;\n // 避免除0\n this._interval = this._totalDuration / (frames ?? 1);\n }\n // 若未配置总时长, 则根据interval算出一个总时长, interval有默认值\n else {\n this._totalDuration = this._interval * frames;\n this._interval = this.attribute.interval;\n }\n };\n\n /**\n * 初始化dataIndex\n */\n _initDataIndex = () => {\n this._dataIndex = this.attribute.dataIndex ?? this._minIndex;\n };\n\n /**\n * 初始化事件\n */\n private _initEvents = () => {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n this._controller.addEventListener(ControllerEventEnum.OnPlay, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.play();\n });\n this._controller.addEventListener(ControllerEventEnum.OnPause, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.pause();\n });\n this._controller.addEventListener(ControllerEventEnum.OnForward, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.forward();\n });\n this._controller.addEventListener(ControllerEventEnum.OnBackward, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.backward();\n });\n\n this._slider.addEventListener('change', (e: FederatedPointerEvent) => {\n e.stopPropagation();\n /**\n * 根据value, 反推开始时间\n * 1. 计算进度\n * 2. 计算流逝时间\n * 3. 用现在的时间, 模拟一个开始时间\n */\n const value = (e.detail as unknown as { value: number; position: number })?.value;\n const progress = value / this._maxIndex;\n this._elapsed = progress * this._totalDuration;\n this._startTime = Date.now() - this._elapsed;\n\n this._dispatchChange(value);\n });\n };\n\n /**\n * 根据已流逝时间和总时长, 计算slider的值\n */\n private _getSliderValue = () => {\n const progress = this._elapsed / this._totalDuration;\n return Math.min(progress * this._maxIndex, this._maxIndex);\n };\n\n /**\n * 根据流逝时间, 更新Slider的值\n */\n private _updateSlider = () => {\n const value = this._getSliderValue();\n this._dataIndex = Math.floor(value);\n this._slider.setValue(Math.min(value, this._maxIndex));\n this._dispatchChange(Math.floor(value));\n };\n\n /**\n * 根据Slider的值, 判断是否要触发Change事件.\n */\n private _dispatchChange = (value: number) => {\n const index = Math.floor(value);\n if (index !== this._activeIndex) {\n this._dataIndex = index;\n this._activeIndex = index;\n\n if (index !== this._maxIndex) {\n this.dispatchCustomEvent(PlayerEventEnum.change);\n }\n }\n };\n\n /**\n * 派遣事件\n * @param eventType 事件类型\n */\n dispatchCustomEvent(eventType: PlayerEventEnum) {\n super.dispatchCustomEvent(eventType, this._dataIndex);\n }\n\n /**\n * 播放接口\n */\n play = async () => {\n if (this._isPlaying) {\n return;\n }\n // 切换按钮\n this._controller.togglePause();\n // 播放状态更新\n this._isPlaying = true;\n // 播放结束后再点击play, 此条件下生效.\n if (this._elapsed >= this._totalDuration) {\n this._elapsed = 0;\n }\n // 此时此刻减去已流逝的时间, 则为起点对应的时间戳.\n this._startTime = Date.now() - this._elapsed;\n // 事件\n this.dispatchCustomEvent(PlayerEventEnum.play);\n // 开始播放动画\n this._rafId = vglobal.getRequestAnimationFrame()(this._play.bind(this));\n };\n\n /**\n * 播放动画主要逻辑\n */\n private _play = () => {\n // 计算已流逝的时间, 但不需要保存\n this._elapsed = Date.now() - this._startTime;\n // 计算Slider的值.\n const value = this._getSliderValue();\n // 更新Slider的值.\n this._updateSlider();\n\n // 播放终止条件\n if (value >= this._maxIndex) {\n this._playEnd();\n return;\n }\n\n // 持续播放\n this._rafId = vglobal.getRequestAnimationFrame()(this._play.bind(this));\n };\n\n /**\n * 播放结束时触发\n */\n private _playEnd = () => {\n // 播放状态更新\n this._isPlaying = false;\n // 取消播放动画\n vglobal.getCancelAnimationFrame()(this._rafId);\n // 切换按钮\n this._controller.togglePlay();\n // 事件\n this.dispatchCustomEvent(PlayerEventEnum.end);\n };\n\n /**\n * 暂停接口\n */\n pause = () => {\n if (!this._isPlaying) {\n return;\n }\n this._isPlaying = false;\n // 计算已流逝的时间, 需要记录下来\n this._elapsed = Date.now() - this._startTime;\n vglobal.getCancelAnimationFrame()(this._rafId);\n this._controller.togglePlay();\n\n this.dispatchCustomEvent(PlayerEventEnum.pause);\n };\n\n /**\n * 前进接口\n */\n backward = () => {\n // 按下按钮的时间\n const now = Date.now();\n // 步长\n const interval = this._interval * 1;\n // 流逝时间 减去 interval\n const elapsed = this._elapsed - interval;\n\n // 若到达起点\n if (elapsed <= 0) {\n this._elapsed = 0;\n this._startTime = now;\n }\n // 若未到达起点\n else {\n this._elapsed = elapsed;\n this._startTime = this._startTime + this._interval;\n }\n // 更新slider\n this._updateSlider();\n\n this.dispatchCustomEvent(PlayerEventEnum.backward);\n };\n\n /**\n * 后退接口\n */\n forward = () => {\n // 按下按钮的时间\n const now = Date.now();\n // 步长\n const interval = this._interval * 1;\n // 流逝时间 加上 1个interval\n const elapsed = this._elapsed + interval;\n // 若超过终点\n if (elapsed >= this._totalDuration) {\n this._startTime = now - this._totalDuration;\n this._elapsed = this._totalDuration;\n }\n // 未超过终点\n else {\n this._startTime = this._startTime - interval;\n this._elapsed = elapsed;\n }\n // 更新slider\n this._updateSlider();\n\n this.dispatchCustomEvent(PlayerEventEnum.forward);\n };\n\n render() {\n super.render();\n }\n}\n"]}
|
|
@@ -2,13 +2,7 @@ import { BasePlayer } from './base-player';
|
|
|
2
2
|
import type { DiscretePlayerAttributes, PlayerAttributes } from './type';
|
|
3
3
|
import { PlayerEventEnum } from './type';
|
|
4
4
|
import type { ComponentOptions } from '../interface';
|
|
5
|
-
export
|
|
6
|
-
play: () => void;
|
|
7
|
-
pause: () => void;
|
|
8
|
-
backward: () => void;
|
|
9
|
-
forward: () => void;
|
|
10
|
-
}
|
|
11
|
-
export declare class DiscretePlayer extends BasePlayer<DiscretePlayerAttributes> implements IDiscretePlayer {
|
|
5
|
+
export declare class DiscretePlayer extends BasePlayer<DiscretePlayerAttributes> {
|
|
12
6
|
attribute: DiscretePlayerAttributes;
|
|
13
7
|
private _activeIndex;
|
|
14
8
|
protected _alternate: boolean;
|