@visactor/vrender-components 0.21.1-alpha.1 → 0.21.2-vstory.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/core/base.d.ts +1 -0
- package/cjs/core/base.js +3 -3
- package/cjs/core/base.js.map +1 -1
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +2 -2
- package/cjs/index.js.map +1 -1
- package/cjs/interface.d.ts +2 -1
- package/cjs/interface.js.map +1 -1
- package/cjs/label/base.d.ts +1 -0
- package/cjs/label/base.js +26 -19
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/overlap/place.d.ts +1 -1
- package/cjs/label/overlap/place.js +7 -6
- package/cjs/label/overlap/place.js.map +1 -1
- package/cjs/label/overlap/shiftY.js +3 -3
- package/cjs/label/overlap/shiftY.js.map +1 -1
- package/cjs/label/type.d.ts +2 -0
- package/cjs/label/type.js.map +1 -1
- package/cjs/marker/config.js +32 -0
- package/cjs/marker/config.js.map +1 -1
- package/cjs/marker/type.d.ts +9 -1
- package/cjs/marker/type.js +6 -2
- package/cjs/marker/type.js.map +1 -1
- package/cjs/scrollbar/scrollbar-plugin.js +24 -19
- package/cjs/scrollbar/scrollbar-plugin.js.map +1 -1
- package/cjs/weather/index.d.ts +1 -0
- package/cjs/weather/index.js +21 -0
- package/cjs/weather/index.js.map +1 -0
- package/cjs/weather/register.d.ts +1 -0
- package/cjs/weather/register.js +14 -0
- package/cjs/weather/register.js.map +1 -0
- package/cjs/weather/type.d.ts +24 -0
- package/cjs/weather/type.js +6 -0
- package/cjs/weather/type.js.map +1 -0
- package/cjs/weather/weather-box.d.ts +13 -0
- package/cjs/weather/weather-box.js +129 -0
- package/cjs/weather/weather-box.js.map +1 -0
- package/dist/index.es.js +5538 -5020
- package/es/core/base.d.ts +1 -0
- package/es/core/base.js +4 -3
- package/es/core/base.js.map +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/index.js.map +1 -1
- package/es/interface.d.ts +2 -1
- package/es/interface.js.map +1 -1
- package/es/label/base.d.ts +1 -0
- package/es/label/base.js +26 -19
- package/es/label/base.js.map +1 -1
- package/es/label/overlap/place.d.ts +1 -1
- package/es/label/overlap/place.js +6 -5
- package/es/label/overlap/place.js.map +1 -1
- package/es/label/overlap/shiftY.js +3 -3
- package/es/label/overlap/shiftY.js.map +1 -1
- package/es/label/type.d.ts +2 -0
- package/es/label/type.js.map +1 -1
- package/es/marker/config.js +32 -0
- package/es/marker/config.js.map +1 -1
- package/es/marker/type.d.ts +9 -1
- package/es/marker/type.js +6 -2
- package/es/marker/type.js.map +1 -1
- package/es/scrollbar/scrollbar-plugin.js +24 -19
- package/es/scrollbar/scrollbar-plugin.js.map +1 -1
- package/es/weather/index.d.ts +1 -0
- package/es/weather/index.js +2 -0
- package/es/weather/index.js.map +1 -0
- package/es/weather/register.d.ts +1 -0
- package/es/weather/register.js +6 -0
- package/es/weather/register.js.map +1 -0
- package/es/weather/type.d.ts +24 -0
- package/es/weather/type.js +2 -0
- package/es/weather/type.js.map +1 -0
- package/es/weather/weather-box.d.ts +13 -0
- package/es/weather/weather-box.js +127 -0
- package/es/weather/weather-box.js.map +1 -0
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/scrollbar/scrollbar-plugin.ts"],"names":[],"mappings":";;;;;;;;;;AACA,yDAA+D;AAC/D,2CAAwC;AAExC,6CAA2D;AAC3D,0CAA8C;AAYvC,IAAM,eAAe,uBAArB,MAAM,eAAe;IAArB;QACL,SAAI,GAAgB,WAAW,CAAC;QAChC,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,wBAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAmBpC,WAAM,GAAG,CAAC,CAAuD,EAAE,EAAE;;YACnE,MAAM,OAAO,GAAG,CAAC,CAAC,MAAa,CAA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AM,GAAG,GAAG,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;YAE1C,IAAI,GAAG,EAAE;gBACP,OAAO,GAAG,CAAC;aACZ;YACD,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,UAAU,CAAC,OAAuB;QAChC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC;QACrC,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAa,CAAC,CAAC;IACzD,CAAC;;AA9SM,6BAAa,GAAY;IAC9B,OAAO,EAAE,GAAG;CACb,CAAC;AAZS,eAAe;IAD3B,IAAA,yBAAU,GAAE;GACA,eAAe,CAyT3B;AAzTY,0CAAe","file":"scrollbar-plugin.js","sourcesContent":["import type { IGraphic, IGroup, IPlugin, IPluginService } from '@visactor/vrender-core';\nimport { Generator, injectable } from '@visactor/vrender-core';\nimport { ScrollBar } from './scrollbar';\nimport type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds, abs, Bounds } from '@visactor/vutils';\nimport { SCROLLBAR_EVENT } from '../constant';\nimport type { ScrollBarAttributes } from './type';\n\n// _showPoptip: 0-没有,1-添加,2-删除\n\ntype IParams = {\n timeout?: number; // 消失的timeout\n bufferV?: number; // 判定是否出现滚动条的buffer\n bufferH?: number; // 判定是否出现滚动条的buffer\n};\n\n@injectable()\nexport class ScrollBarPlugin implements IPlugin {\n name: 'scrollbar' = 'scrollbar';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n scrollContainer?: { g: IGroup; showH: boolean; showV: boolean };\n scrollContainerBounds: IAABBBounds;\n childrenBounds: IAABBBounds;\n\n static defaultParams: IParams = {\n timeout: 500\n };\n\n params: IParams;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n const { stage } = this.pluginService;\n\n this.childrenBounds = new AABBBounds();\n stage.addEventListener('wheel', this.scroll as any);\n this.params = ScrollBarPlugin.defaultParams;\n }\n scroll = (e: { deltaX: number; deltaY: number; target: IGraphic }) => {\n const graphic = e.target as any;\n const data = this.getScrollContainer(graphic);\n\n if (!data && !this.scrollContainer) {\n return;\n }\n\n if (!data && this.scrollContainer) {\n if (!this.scrollContainer.g.stage || this.scrollContainer.g.stage !== graphic.stage) {\n return;\n }\n const newScrollContainer = this.formatScrollContainer(this.scrollContainer.g);\n\n if (!newScrollContainer) {\n this.clearScrollbar(this.scrollContainer.g, 'all');\n // 删除老的scrollbar\n return;\n }\n if (this.scrollContainer.showH && !newScrollContainer.showH) {\n this.clearScrollbar(this.scrollContainer.g, 'horizontal');\n }\n\n if (this.scrollContainer.showV && !newScrollContainer.showV) {\n this.clearScrollbar(this.scrollContainer.g, 'vertical');\n }\n\n this.scrollContainer = newScrollContainer;\n } else if (data && this.scrollContainer && data.g !== this.scrollContainer.g) {\n this.clearScrollbar(this.scrollContainer.g, 'all');\n }\n\n this.scrollContainer = data ?? this.scrollContainer;\n\n const scrollContainer = data.g;\n const { width, height, scrollX = 0, scrollY = 0 } = scrollContainer.attribute;\n let newScrollX = scrollX;\n let newScrollY = scrollY;\n let { showH, showV } = data;\n this.scrollContainerBounds = new Bounds().set(\n 0,\n 0,\n scrollContainer.attribute.width,\n scrollContainer.attribute.height\n );\n if (showH && showH) {\n if (abs(e.deltaX) > abs(e.deltaY)) {\n showH = showH && true;\n showV = showV && false;\n } else {\n showH = showH && false;\n showV = showV && true;\n }\n }\n\n // 计算子元素的bounds\n const childrenBounds = this.childrenBounds;\n\n childrenBounds.clear();\n childrenBounds.set(0, 0, scrollContainer.AABBBounds.width(), scrollContainer.AABBBounds.height());\n\n const scrollWidth = childrenBounds.width();\n const scrollHeight = childrenBounds.height();\n\n if (showH) {\n newScrollX = Math.max(Math.min((e.deltaX ?? 0) - scrollX, scrollWidth - width), 0);\n } else {\n newScrollX = -scrollX;\n }\n\n if (showV) {\n newScrollY = Math.max(Math.min((e.deltaY ?? 0) - scrollY, scrollHeight - height), 0);\n } else {\n newScrollY = -scrollY;\n }\n\n childrenBounds.translate(-newScrollX, -newScrollY);\n\n this.addOrUpdateScroll(showH, showV, scrollContainer.parent, scrollContainer);\n scrollContainer.setAttributes({\n scrollX: -newScrollX,\n scrollY: -newScrollY\n });\n };\n\n handleScrollBarChange = (params: any) => {\n if (\n !this.scrollContainer ||\n !this.scrollContainerBounds ||\n !this.childrenBounds ||\n !params ||\n !params.target ||\n !params.detail ||\n !params.detail.value\n ) {\n return;\n }\n const scrollbar = params.target;\n const newRange = params.detail.value;\n\n if (scrollbar.attribute.direction === 'horizontal') {\n const scrollWidth = this.childrenBounds.width();\n\n this.scrollContainer.g.setAttributes({ scrollX: -newRange[0] * scrollWidth });\n } else {\n const scrollHeight = this.childrenBounds.height();\n\n this.scrollContainer.g.setAttributes({ scrollY: -newRange[0] * scrollHeight });\n }\n };\n\n initEventOfScrollbar(scrollContainer: IGroup, scrollbar: IGroup, isHorozntal?: boolean) {\n scrollContainer.addEventListener('pointerover', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n scrollContainer.addEventListener('pointermove', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n scrollContainer.addEventListener('pointerout', () => {\n scrollbar.setAttribute('visibleAll', false);\n });\n scrollbar.addEventListener('pointerover', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n scrollbar.addEventListener('pointerout', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n\n scrollbar.addEventListener('scrollUp', this.handleScrollBarChange);\n scrollbar.addEventListener(SCROLLBAR_EVENT, this.handleScrollBarChange);\n }\n\n addOrUpdateScroll(showH: boolean, showV: boolean, container: IGroup, scrollContainer: IGroup) {\n if (showH) {\n const { scrollBar: hScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, true);\n\n if (!isUpdate) {\n this.initEventOfScrollbar(scrollContainer, hScrollbar, true);\n }\n } else {\n this.clearScrollbar(scrollContainer, 'horizontal');\n }\n if (showV) {\n const { scrollBar: vScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, false);\n\n if (!isUpdate) {\n this.initEventOfScrollbar(scrollContainer, vScrollbar, false);\n }\n } else {\n this.clearScrollbar(scrollContainer, 'vertical');\n }\n }\n\n getDirection(isHorozntal?: boolean) {\n return isHorozntal ? 'horizontal' : 'vertical';\n }\n\n addOrUpdateHScroll(scrollContainer: IGroup, container: IGroup, isHorozntal?: boolean) {\n const direction = this.getDirection(isHorozntal);\n const name = `${scrollContainer.name ?? scrollContainer._uid}_${this.getDirection(isHorozntal)}_${this.name}`;\n const scrollbars = container.children.filter((g: ScrollBar) => g.name === name);\n let isUpdate = true;\n let scrollBar = scrollbars[0] as ScrollBar;\n\n const { y = 0, dy = 0, x = 0, dx = 0, height, width, zIndex = 0 } = this.scrollContainer.g.attribute;\n const attrs: Partial<ScrollBarAttributes> = {\n x: 0,\n y: 0,\n direction,\n zIndex: zIndex + 1,\n visibleAll: true,\n padding: [2, 0],\n railStyle: {\n fill: 'rgba(0, 0, 0, .1)'\n },\n range: [0, 0.05]\n };\n\n if (isHorozntal) {\n attrs.width = this.scrollContainerBounds.width();\n attrs.height = 12;\n } else {\n attrs.height = this.scrollContainerBounds.height();\n attrs.width = 12;\n }\n\n if (!scrollBar) {\n isUpdate = false;\n\n scrollBar = new ScrollBar(attrs as ScrollBarAttributes);\n scrollBar.name = name;\n container.add(scrollBar);\n (scrollBar as any).isScrollBar = true;\n } else if (scrollbars.length > 1) {\n scrollbars.forEach((child: IGraphic, index: number) => {\n if (index) {\n child.parent?.removeChild(child);\n }\n });\n }\n const childrenBounds = this.childrenBounds;\n\n if (isHorozntal) {\n const ratio = Math.min(this.scrollContainerBounds.width() / childrenBounds.width(), 1);\n const start = Math.max(Math.min(this.childrenBounds.x1 / this.childrenBounds.width(), 0), ratio - 1);\n attrs.x = x + dx;\n attrs.y = y + dy + height - this.scrollContainerBounds.height();\n attrs.range = [-start, -start + ratio];\n } else {\n const ratio = Math.min(this.scrollContainerBounds.height() / childrenBounds.height(), 1);\n const start = Math.max(Math.min(this.childrenBounds.y1 / this.childrenBounds.height(), 0), ratio - 1);\n attrs.x = x + dx + width - this.scrollContainerBounds.width();\n attrs.y = y + dy;\n attrs.range = [-start, -start + ratio];\n }\n\n scrollBar.setAttributes(attrs);\n return {\n scrollBar,\n isUpdate\n };\n }\n\n clearScrollbar(scrollContainer: IGroup, type: 'horizontal' | 'vertical' | 'all') {\n if (!scrollContainer.parent) {\n return;\n }\n const scrollbarBars = scrollContainer.parent.children.filter((child: IGroup) => {\n return (child as any).isScrollBar && (type === 'all' || (child.attribute as any).direction === type);\n });\n\n scrollbarBars.forEach((child: IGraphic) => {\n child.parent.removeChild(child);\n });\n }\n\n formatScrollContainer(g: IGraphic) {\n if (!g || g.type !== 'group' || !g.attribute) {\n return null;\n }\n\n const { overflow, width, height } = (g as IGroup).attribute;\n\n if (!overflow || overflow === 'hidden') {\n return null;\n }\n\n let showH = false;\n let showV = false;\n\n if (overflow === 'scroll') {\n showH = true;\n showV = true;\n } else {\n showH = overflow === 'scroll-x';\n showV = !showH;\n }\n\n if (!g.AABBBounds.empty()) {\n if (showH) {\n showH = width < g.AABBBounds.width();\n }\n\n if (showV) {\n showV = height < g.AABBBounds.height();\n }\n }\n\n return showH || showV ? { g: g as IGroup, showH, showV } : null;\n }\n\n // 获取响应滚动的元素\n getScrollContainer(graphic: IGraphic): { g: IGroup; showH: boolean; showV: boolean } | null {\n let g = graphic;\n while (g) {\n const res = this.formatScrollContainer(g);\n\n if (res) {\n return res;\n }\n g = g.parent;\n }\n return null;\n }\n\n deactivate(context: IPluginService): void {\n const { stage } = this.pluginService;\n stage.removeEventListener('wheel', this.scroll as any);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/scrollbar/scrollbar-plugin.ts"],"names":[],"mappings":";;;;;;;;;;AACA,yDAA+D;AAC/D,2CAAwC;AAExC,6CAA2D;AAC3D,0CAA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IAAI,KAAK,EAAE;gBACT,KAAK,GAAG,KAAK,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC;aACxC;YAED,IAAI,KAAK,EAAE;gBACT,KAAK,GAAG,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;aAC1C;SACF;QAED,OAAO,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAW,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAClE,CAAC;IAGD,kBAAkB,CAAC,OAAiB;QAClC,IAAI,CAAC,GAAG,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE;YACR,MAAM,GAAG,GAAG,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;YAE1C,IAAI,GAAG,EAAE;gBACP,OAAO,GAAG,CAAC;aACZ;YACD,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,UAAU,CAAC,OAAuB;QAChC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC;QACrC,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAa,CAAC,CAAC;IACzD,CAAC;;AA5TM,6BAAa,GAAY;IAC9B,OAAO,EAAE,GAAG;CACb,CAAC;AAZS,eAAe;IAD3B,IAAA,yBAAU,GAAE;GACA,eAAe,CAuU3B;AAvUY,0CAAe","file":"scrollbar-plugin.js","sourcesContent":["import type { IGraphic, IGroup, IPlugin, IPluginService } from '@visactor/vrender-core';\nimport { Generator, injectable } from '@visactor/vrender-core';\nimport { ScrollBar } from './scrollbar';\nimport type { IAABBBounds } from '@visactor/vutils';\nimport { AABBBounds, abs, Bounds } from '@visactor/vutils';\nimport { SCROLLBAR_EVENT } from '../constant';\nimport type { ScrollBarAttributes } from './type';\n\n// _showPoptip: 0-没有,1-添加,2-删除\n\ntype IParams = {\n timeout?: number; // 消失的timeout\n bufferV?: number; // 判定是否出现滚动条的buffer\n bufferH?: number; // 判定是否出现滚动条的buffer\n};\n\n@injectable()\nexport class ScrollBarPlugin implements IPlugin {\n name: 'scrollbar' = 'scrollbar';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n scrollContainer?: { g: IGroup; showH: boolean; showV: boolean };\n scrollContainerBounds: IAABBBounds;\n childrenBounds: IAABBBounds;\n\n static defaultParams: IParams = {\n timeout: 500\n };\n\n params: IParams;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n const { stage } = this.pluginService;\n\n this.childrenBounds = new AABBBounds();\n stage.addEventListener('wheel', this.scroll as any);\n this.params = ScrollBarPlugin.defaultParams;\n }\n scroll = (e: { deltaX: number; deltaY: number; target: IGraphic }) => {\n // 计算子元素的bounds\n const graphic = e.target as any;\n // childrenBounds.set(0, 0, scrollContainer.AABBBounds.width(), scrollContainer.AABBBounds.height());\n\n const data = this.getScrollContainer(graphic);\n\n if (!data && !this.scrollContainer) {\n return;\n }\n\n if (!data && this.scrollContainer) {\n if (!this.scrollContainer.g.stage || this.scrollContainer.g.stage !== graphic.stage) {\n return;\n }\n const newScrollContainer = this.formatScrollContainer(this.scrollContainer.g);\n\n if (!newScrollContainer) {\n this.clearScrollbar(this.scrollContainer.g, 'all');\n // 删除老的scrollbar\n return;\n }\n if (this.scrollContainer.showH && !newScrollContainer.showH) {\n this.clearScrollbar(this.scrollContainer.g, 'horizontal');\n }\n\n if (this.scrollContainer.showV && !newScrollContainer.showV) {\n this.clearScrollbar(this.scrollContainer.g, 'vertical');\n }\n\n this.scrollContainer = newScrollContainer;\n } else if (data && this.scrollContainer && data.g !== this.scrollContainer.g) {\n this.clearScrollbar(this.scrollContainer.g, 'all');\n }\n\n this.scrollContainer = data ?? this.scrollContainer;\n if (!data) {\n return;\n }\n const scrollContainer = data.g;\n if (!scrollContainer) {\n return;\n }\n const { width, height, scrollX = 0, scrollY = 0 } = scrollContainer.attribute;\n let newScrollX = scrollX;\n let newScrollY = scrollY;\n let { showH, showV } = data;\n this.scrollContainerBounds = new Bounds().set(\n 0,\n 0,\n scrollContainer.attribute.width,\n scrollContainer.attribute.height\n );\n if (showH && showH) {\n if (abs(e.deltaX) > abs(e.deltaY)) {\n showH = showH && true;\n showV = showV && false;\n } else {\n showH = showH && false;\n showV = showV && true;\n }\n }\n\n const scrollWidth = this.childrenBounds.width();\n const scrollHeight = this.childrenBounds.height();\n\n if (showH) {\n newScrollX = scrollX - (e.deltaX ?? 0);\n if (newScrollX > 0) {\n newScrollX = 0;\n } else if (newScrollX < width - scrollWidth) {\n newScrollX = width - scrollWidth;\n }\n }\n\n if (showV) {\n newScrollY = scrollY - (e.deltaY ?? 0);\n if (newScrollY > 0) {\n newScrollY = 0;\n } else if (newScrollY < height - scrollHeight) {\n newScrollY = height - scrollHeight;\n }\n }\n\n scrollContainer.setAttributes({\n scrollX: newScrollX,\n scrollY: newScrollY\n });\n this.addOrUpdateScroll(showH, showV, scrollContainer.parent, scrollContainer);\n };\n\n handleScrollBarChange = (params: any) => {\n if (\n !this.scrollContainer ||\n !this.scrollContainerBounds ||\n !this.childrenBounds ||\n !params ||\n !params.target ||\n !params.detail ||\n !params.detail.value\n ) {\n return;\n }\n const scrollbar = params.target;\n const newRange = params.detail.value;\n\n if (scrollbar.attribute.direction === 'horizontal') {\n const scrollWidth = this.childrenBounds.width();\n\n this.scrollContainer.g.setAttributes({ scrollX: -newRange[0] * scrollWidth });\n } else {\n const scrollHeight = this.childrenBounds.height();\n\n this.scrollContainer.g.setAttributes({ scrollY: -newRange[0] * scrollHeight });\n }\n };\n\n initEventOfScrollbar(scrollContainer: IGroup, scrollbar: IGroup, isHorozntal?: boolean) {\n scrollContainer.addEventListener('pointerover', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n scrollContainer.addEventListener('pointermove', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n scrollContainer.addEventListener('pointerout', () => {\n scrollbar.setAttribute('visibleAll', false);\n });\n scrollbar.addEventListener('pointerover', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n scrollbar.addEventListener('pointerout', () => {\n scrollbar.setAttribute('visibleAll', true);\n });\n\n scrollbar.addEventListener('scrollUp', this.handleScrollBarChange);\n scrollbar.addEventListener(SCROLLBAR_EVENT, this.handleScrollBarChange);\n }\n\n addOrUpdateScroll(showH: boolean, showV: boolean, container: IGroup, scrollContainer: IGroup) {\n if (showH) {\n const { scrollBar: hScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, true);\n\n if (!isUpdate) {\n this.initEventOfScrollbar(scrollContainer, hScrollbar, true);\n }\n } else {\n this.clearScrollbar(scrollContainer, 'horizontal');\n }\n if (showV) {\n const { scrollBar: vScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, false);\n\n if (!isUpdate) {\n this.initEventOfScrollbar(scrollContainer, vScrollbar, false);\n }\n } else {\n this.clearScrollbar(scrollContainer, 'vertical');\n }\n }\n\n getDirection(isHorozntal?: boolean) {\n return isHorozntal ? 'horizontal' : 'vertical';\n }\n\n addOrUpdateHScroll(scrollContainer: IGroup, container: IGroup, isHorozntal?: boolean) {\n const direction = this.getDirection(isHorozntal);\n const name = `${scrollContainer.name ?? scrollContainer._uid}_${this.getDirection(isHorozntal)}_${this.name}`;\n const scrollbars = container.children.filter((g: ScrollBar) => g.name === name);\n let isUpdate = true;\n let scrollBar = scrollbars[0] as ScrollBar;\n\n const { y = 0, dy = 0, x = 0, dx = 0, height, width, zIndex = 0 } = this.scrollContainer.g.attribute;\n const attrs: Partial<ScrollBarAttributes> = {\n x: 0,\n y: 0,\n direction,\n zIndex: zIndex + 1,\n visibleAll: true,\n padding: [2, 0],\n railStyle: {\n fill: 'rgba(0, 0, 0, .1)'\n },\n range: [0, 0.05]\n };\n\n if (isHorozntal) {\n attrs.width = this.scrollContainerBounds.width();\n attrs.height = 12;\n } else {\n attrs.height = this.scrollContainerBounds.height();\n attrs.width = 12;\n }\n\n if (!scrollBar) {\n isUpdate = false;\n\n scrollBar = new ScrollBar(attrs as ScrollBarAttributes);\n scrollBar.name = name;\n container.add(scrollBar);\n (scrollBar as any).isScrollBar = true;\n } else if (scrollbars.length > 1) {\n scrollbars.forEach((child: IGraphic, index: number) => {\n if (index) {\n child.parent?.removeChild(child);\n }\n });\n }\n const childrenBounds = this.childrenBounds;\n\n const { scrollX, scrollY } = scrollContainer.attribute;\n if (isHorozntal) {\n const ratio = Math.min(this.scrollContainerBounds.width() / childrenBounds.width(), 1);\n const start = Math.max(Math.min(scrollX / this.childrenBounds.width(), 0), ratio - 1);\n attrs.x = x + dx;\n attrs.y = y + dy + height - (attrs.height ?? 0);\n attrs.range = [-start, -start + ratio];\n } else {\n const ratio = Math.min(this.scrollContainerBounds.height() / childrenBounds.height(), 1);\n const start = Math.max(Math.min(scrollY / this.childrenBounds.height(), 0), ratio - 1);\n attrs.x = x + dx + width - this.scrollContainerBounds.width();\n attrs.y = y + dy;\n attrs.range = [-start, -start + ratio];\n }\n\n scrollBar.setAttributes(attrs);\n return {\n scrollBar,\n isUpdate\n };\n }\n\n clearScrollbar(scrollContainer: IGroup, type: 'horizontal' | 'vertical' | 'all') {\n if (!scrollContainer.parent) {\n return;\n }\n const scrollbarBars = scrollContainer.parent.children.filter((child: IGroup) => {\n return (child as any).isScrollBar && (type === 'all' || (child.attribute as any).direction === type);\n });\n\n scrollbarBars.forEach((child: IGraphic) => {\n child.parent.removeChild(child);\n });\n }\n\n formatScrollContainer(g: IGraphic) {\n if (!g || g.type !== 'group' || !g.attribute) {\n return null;\n }\n\n const { overflow, width, height } = (g as IGroup).attribute;\n\n if (!overflow || overflow === 'hidden') {\n return null;\n }\n\n let showH = false;\n let showV = false;\n\n if (overflow === 'scroll') {\n showH = true;\n showV = true;\n } else {\n showH = overflow === 'scroll-x';\n showV = !showH;\n }\n\n const childrenBounds = this.childrenBounds;\n\n childrenBounds.clear();\n g.forEachChildren((g: IGraphic) => {\n childrenBounds.union(g.AABBBounds);\n });\n\n if (!g.AABBBounds.empty()) {\n if (showH) {\n showH = width < childrenBounds.width();\n }\n\n if (showV) {\n showV = height < childrenBounds.height();\n }\n }\n\n return showH || showV ? { g: g as IGroup, showH, showV } : null;\n }\n\n // 获取响应滚动的元素\n getScrollContainer(graphic: IGraphic): { g: IGroup; showH: boolean; showV: boolean } | null {\n let g = graphic;\n while (g) {\n const res = this.formatScrollContainer(g);\n\n if (res) {\n return res;\n }\n g = g.parent;\n }\n return null;\n }\n\n deactivate(context: IPluginService): void {\n const { stage } = this.pluginService;\n stage.removeEventListener('wheel', this.scroll as any);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './weather-box';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4
|
+
void 0 === k2 && (k2 = k);
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
get: function() {
|
|
9
|
+
return m[k];
|
|
10
|
+
}
|
|
11
|
+
}), Object.defineProperty(o, k2, desc);
|
|
12
|
+
} : function(o, m, k, k2) {
|
|
13
|
+
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
14
|
+
}), __exportStar = this && this.__exportStar || function(m, exports) {
|
|
15
|
+
for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(exports, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), __exportStar(require("./weather-box"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/weather/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B","file":"index.js","sourcesContent":["export * from './weather-box';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadWeatherComponent(): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.loadWeatherComponent = void 0;
|
|
6
|
+
|
|
7
|
+
const vrender_kits_1 = require("@visactor/vrender-kits");
|
|
8
|
+
|
|
9
|
+
function loadWeatherComponent() {
|
|
10
|
+
(0, vrender_kits_1.registerGroup)(), (0, vrender_kits_1.registerSymbol)();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.loadWeatherComponent = loadWeatherComponent;
|
|
14
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/weather/register.ts"],"names":[],"mappings":";;;AAAA,yDAAuE;AAEvE,SAAgB,oBAAoB;IAClC,IAAA,4BAAa,GAAE,CAAC;IAChB,IAAA,6BAAc,GAAE,CAAC;AACnB,CAAC;AAHD,oDAGC","file":"register.js","sourcesContent":["import { registerGroup, registerSymbol } from '@visactor/vrender-kits';\n\nexport function loadWeatherComponent() {\n registerGroup();\n registerSymbol();\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IGroupGraphicAttribute, ISymbolGraphicAttribute } from '@visactor/vrender-core';
|
|
2
|
+
export interface IWeatherBoxAttrs extends IGroupGraphicAttribute {
|
|
3
|
+
rainIconPath?: string;
|
|
4
|
+
snowIconPath?: string;
|
|
5
|
+
windIconPath?: string;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
rainSizeRange?: [number, number];
|
|
9
|
+
snowSizeRange?: [number, number];
|
|
10
|
+
windSize?: number;
|
|
11
|
+
rainSpeed?: number;
|
|
12
|
+
snowSpeed?: number;
|
|
13
|
+
windSpeed?: number;
|
|
14
|
+
snowRainBottomPadding?: number;
|
|
15
|
+
rainRatio?: number;
|
|
16
|
+
rainCountThreshold?: number;
|
|
17
|
+
snowRatio?: number;
|
|
18
|
+
snowCountThreshold?: number;
|
|
19
|
+
windRatio?: number;
|
|
20
|
+
windAnimateEffect?: 'fade' | 'clipRange';
|
|
21
|
+
rainStyle?: ISymbolGraphicAttribute;
|
|
22
|
+
snowStyle?: ISymbolGraphicAttribute;
|
|
23
|
+
windStyle?: ISymbolGraphicAttribute;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/weather/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { IGroupGraphicAttribute, IRectGraphicAttribute, ISymbolGraphicAttribute } from '@visactor/vrender-core';\n\nexport interface IWeatherBoxAttrs extends IGroupGraphicAttribute {\n rainIconPath?: string;\n snowIconPath?: string;\n windIconPath?: string;\n width: number;\n height: number;\n rainSizeRange?: [number, number];\n snowSizeRange?: [number, number];\n windSize?: number;\n rainSpeed?: number;\n snowSpeed?: number;\n windSpeed?: number;\n\n snowRainBottomPadding?: number;\n\n rainRatio?: number;\n rainCountThreshold?: number;\n snowRatio?: number;\n snowCountThreshold?: number;\n windRatio?: number;\n\n windAnimateEffect?: 'fade' | 'clipRange';\n\n rainStyle?: ISymbolGraphicAttribute;\n snowStyle?: ISymbolGraphicAttribute;\n windStyle?: ISymbolGraphicAttribute;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AbstractComponent } from '../core/base';
|
|
2
|
+
import type { IWeatherBoxAttrs } from './type';
|
|
3
|
+
import type { ComponentOptions } from '../interface';
|
|
4
|
+
import { type IGroup, type ITimeline } from '@visactor/vrender-core';
|
|
5
|
+
export declare class WeatherBox extends AbstractComponent<Required<IWeatherBoxAttrs>> {
|
|
6
|
+
name: string;
|
|
7
|
+
static defaultAttributes: Partial<IWeatherBoxAttrs>;
|
|
8
|
+
timeline: ITimeline;
|
|
9
|
+
constructor(attributes: IWeatherBoxAttrs, options?: ComponentOptions);
|
|
10
|
+
protected render(): void;
|
|
11
|
+
protected generateWind(windRatio: number, windIconPath: string, group: IGroup, size: number, speed: number): void;
|
|
12
|
+
protected generateRainOrSnow(type: string, ratio: number, threshold: number, windRatio: number, group: IGroup, path: string, windAngle: number, sizeRange: [number, number], speed: number): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.WeatherBox = void 0;
|
|
6
|
+
|
|
7
|
+
const base_1 = require("../core/base"), vutils_1 = require("@visactor/vutils"), vrender_core_1 = require("@visactor/vrender-core");
|
|
8
|
+
|
|
9
|
+
function random() {
|
|
10
|
+
return Math.random();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function createUniformRandom(count) {
|
|
14
|
+
const result = [], step = 1 / count;
|
|
15
|
+
for (let i = 0; i < count; i++) result.push((random() - .5) * step / 2 + step * i);
|
|
16
|
+
result.sort((() => Math.random() - .5));
|
|
17
|
+
let idx = 0;
|
|
18
|
+
return function(i) {
|
|
19
|
+
return idx > count - 1 && (idx = 0), void 0 === i && (i = idx, idx++), result[i];
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class WeatherBox extends base_1.AbstractComponent {
|
|
24
|
+
constructor(attributes, options) {
|
|
25
|
+
var _a;
|
|
26
|
+
super((null == options ? void 0 : options.skipDefault) ? attributes : (0, vutils_1.merge)({}, WeatherBox.defaultAttributes, attributes)),
|
|
27
|
+
this.name = "weatherBox", this.timeline = null !== (_a = null == options ? void 0 : options.timeline) && void 0 !== _a ? _a : new vrender_core_1.DefaultTimeline;
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
const {rainRatio: rainRatio, rainIconPath: rainIconPath, snowRatio: snowRatio, snowIconPath: snowIconPath, rainCountThreshold: rainCountThreshold, snowCountThreshold: snowCountThreshold, windRatio: windRatio, rainSizeRange: rainSizeRange, snowSizeRange: snowSizeRange, rainSpeed: rainSpeed, snowSpeed: snowSpeed, width: width, height: height, windIconPath: windIconPath, windSize: windSize, windSpeed: windSpeed} = this.attribute;
|
|
31
|
+
this.attribute.clip = !0;
|
|
32
|
+
const windAngle = -windRatio * Math.PI / 4, rainGroup = this.createOrUpdateChild("rain-container", {
|
|
33
|
+
zIndex: 1,
|
|
34
|
+
width: width,
|
|
35
|
+
height: height
|
|
36
|
+
}, "group");
|
|
37
|
+
rainRatio > 0 && this.generateRainOrSnow("rain", rainRatio, rainCountThreshold, windRatio, rainGroup, rainIconPath, windAngle, rainSizeRange, rainSpeed);
|
|
38
|
+
const snowGroup = this.createOrUpdateChild("snow-container", {
|
|
39
|
+
zIndex: 1,
|
|
40
|
+
width: width,
|
|
41
|
+
height: height
|
|
42
|
+
}, "group");
|
|
43
|
+
snowRatio > 0 && this.generateRainOrSnow("snow", snowRatio, snowCountThreshold, windRatio, snowGroup, snowIconPath, windAngle, snowSizeRange, snowSpeed);
|
|
44
|
+
const windGroup = this.createOrUpdateChild("wind-container", {
|
|
45
|
+
zIndex: 0,
|
|
46
|
+
width: width,
|
|
47
|
+
height: height
|
|
48
|
+
}, "group");
|
|
49
|
+
windRatio > 0 && this.generateWind(windRatio, windIconPath, windGroup, windSize, windSpeed);
|
|
50
|
+
}
|
|
51
|
+
generateWind(windRatio, windIconPath, group, size, speed) {
|
|
52
|
+
const {width: width, height: height} = group.attribute, {windAnimateEffect: windAnimateEffect, windStyle: windStyle = {}} = this.attribute;
|
|
53
|
+
let fromAttribute = {
|
|
54
|
+
opacity: 0,
|
|
55
|
+
clipRange: 1
|
|
56
|
+
}, toAttribute = {
|
|
57
|
+
opacity: 1,
|
|
58
|
+
clipRange: 1
|
|
59
|
+
};
|
|
60
|
+
"clipRange" === windAnimateEffect && (fromAttribute = {
|
|
61
|
+
clipRange: 0,
|
|
62
|
+
opacity: 1
|
|
63
|
+
}, toAttribute = {
|
|
64
|
+
clipRange: 1,
|
|
65
|
+
opacity: 1
|
|
66
|
+
});
|
|
67
|
+
const wind = group.createOrUpdateChild("wind", Object.assign(Object.assign({
|
|
68
|
+
x: (width - size) / 2,
|
|
69
|
+
y: (height - size) / 2,
|
|
70
|
+
symbolType: windIconPath,
|
|
71
|
+
size: size,
|
|
72
|
+
stroke: "white",
|
|
73
|
+
lineWidth: 2,
|
|
74
|
+
dx: -size / 2,
|
|
75
|
+
dy: -size / 2
|
|
76
|
+
}, windStyle), fromAttribute), "symbol"), duration = speed / 4 * 1e3;
|
|
77
|
+
new vrender_core_1.Animate(void 0, this.timeline).bind(wind).to(fromAttribute, duration, "linear").to(toAttribute, duration, "linear").wait(duration / 2).loop(1 / 0);
|
|
78
|
+
}
|
|
79
|
+
generateRainOrSnow(type, ratio, threshold, windRatio, group, path, windAngle, sizeRange, speed) {
|
|
80
|
+
let {width: width} = group.attribute;
|
|
81
|
+
const {height: height} = group.attribute, {snowRainBottomPadding: snowRainBottomPadding, rainStyle: rainStyle = {}, snowStyle: snowStyle = {}} = this.attribute;
|
|
82
|
+
let maxCount = Math.round(ratio * threshold);
|
|
83
|
+
windRatio > 0 && (maxCount *= Math.round(1 + windRatio)), width *= Math.round(1 + windRatio);
|
|
84
|
+
const uniformRandomX = createUniformRandom(maxCount), uniformRandomY = createUniformRandom(maxCount);
|
|
85
|
+
for (let i = 0; i < maxCount; i++) {
|
|
86
|
+
const x = uniformRandomX(), y = uniformRandomY(), size = sizeRange[0] + random() * (sizeRange[1] - sizeRange[0]), startX = x * width - (windAngle ? height * Math.tan(Math.abs(windAngle)) : 0), startY = -y * height, particle = group.createOrUpdateChild(`${type}-${i}`, Object.assign({
|
|
87
|
+
x: startX,
|
|
88
|
+
y: startY,
|
|
89
|
+
symbolType: path,
|
|
90
|
+
size: size,
|
|
91
|
+
fill: "white",
|
|
92
|
+
angle: windAngle
|
|
93
|
+
}, "rain" === type ? rainStyle : snowStyle), "symbol"), duration = 1 / speed / 2 * (1 + y) * 1e3;
|
|
94
|
+
let endX = x * width;
|
|
95
|
+
"rain" === type && windAngle && (endX = startX + (1 + y) * height * Math.tan(Math.abs(windAngle))),
|
|
96
|
+
new vrender_core_1.Animate(void 0, this.timeline).bind(particle).to({
|
|
97
|
+
x: endX,
|
|
98
|
+
y: height - snowRainBottomPadding
|
|
99
|
+
}, duration, "linear").loop(1 / 0), new vrender_core_1.Animate(void 0, this.timeline).bind(particle).to({
|
|
100
|
+
opacity: 0
|
|
101
|
+
}, duration, "quintIn").loop(1 / 0);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
exports.WeatherBox = WeatherBox, WeatherBox.defaultAttributes = {
|
|
107
|
+
snowIconPath: "M512 64c24.7 0 44.8 20.1 44.8 44.8v43.1l29.3-15.5c21.9-11.6 49-3.2 60.5 18.7s3.2 49-18.7 60.5l-71.2 37.6v85.2c32 8.2 60.6 25.1 83.1 48l73.8-42.6-3-80.4c-0.9-24.7 18.4-45.5 43.1-46.4 24.7-0.9 45.5 18.4 46.4 43.1l1.2 33.1 37.3-21.5c21.4-12.4 48.8-5 61.2 16.4 12.4 21.4 5 48.8-16.4 61.2l-37.3 21.5 28.1 17.6c21 13.2 27.3 40.8 14.1 61.8-13.2 20.9-40.8 27.3-61.8 14.1l-68.2-42.8-73.6 42.5c4.2 15.3 6.5 31.4 6.5 48s-2.3 32.7-6.5 48l73.8 42.6 68.2-42.8c20.9-13.2 48.6-6.8 61.8 14.1 13.2 21 6.8 48.6-14.1 61.8l-28.1 17.6 37.3 21.5c21.4 12.4 28.8 39.8 16.4 61.2-12.4 21.4-39.8 28.8-61.2 16.4l-37.3-21.5-1.2 33.1c-0.9 24.7-21.7 44-46.4 43.1-24.7-0.9-44-21.7-43.1-46.4l3-80.4-73.8-42.6c-22.5 22.9-51 39.8-83.1 48v85.2l71.2 37.6c21.9 11.6 30.2 38.7 18.7 60.5-11.6 21.9-38.7 30.2-60.5 18.7L557 872.2v43.1c0 24.7-20.1 44.8-44.8 44.8-24.7 0-44.8-20.1-44.8-44.8v-43.1l-29.3 15.5c-21.9 11.6-49 3.2-60.5-18.7-11.6-21.9-3.2-49 18.7-60.5l71.2-37.6v-85.2c-32-8.2-60.6-25.1-83.1-48l-73.8 42.6 3 80.4c0.9 24.7-18.4 45.5-43.1 46.4-24.7 0.9-45.5-18.4-46.4-43.1l-1.2-33.1-37.3 21.5c-21.4 12.4-48.8 5-61.2-16.4s-5-48.8 16.4-61.2l37.3-21.5-28.1-17.6c-21-13.2-27.3-40.8-14.1-61.8 13.2-20.9 40.8-27.3 61.8-14.1l68.2 42.8 73.8-42.6c-4.2-15.3-6.5-31.4-6.5-48s2.3-32.7 6.5-48l-73.8-42.6-68.2 42.8c-21 13.2-48.6 6.8-61.8-14.1-13.2-21-6.8-48.6 14.1-61.8l28.1-17.6-37.3-21.5C119 336.8 111.7 309.4 124 288c12.4-21.4 39.8-28.8 61.2-16.4l37.3 21.5 1.2-33.1c0.9-24.7 21.7-44 46.4-43.1 24.7 0.9 44 21.7 43.1 46.4l-3 80.4 73.8 42.6c22.5-22.9 51-39.8 83.1-48v-85.2L396 215.6c-21.9-11.6-30.2-38.7-18.7-60.5 11.6-21.9 38.7-30.2 60.5-18.7l29.3 15.5v-43.1C467.2 84.1 487.3 64 512 64z m0 537.6c49.5 0 89.6-40.1 89.6-89.6s-40.1-89.6-89.6-89.6-89.6 40.1-89.6 89.6 40.1 89.6 89.6 89.6z",
|
|
108
|
+
rainIconPath: "M802.94208 583.04c19.328 38.016 29.056 78.336 29.056 120.96a313.216 313.216 0 0 1-44.032 161.536 324.48 324.48 0 0 1-114.56 114.944c-23.552 13.696-49.024 24.32-76.416 32-27.264 7.68-55.68 11.52-84.992 11.52-29.44 0-57.6-3.84-84.992-11.52a331.136 331.136 0 0 1-76.544-32 337.536 337.536 0 0 1-65.024-49.92 337.536 337.536 0 0 1-49.92-65.024 331.136 331.136 0 0 1-32-76.544A313.216 313.216 0 0 1 191.99808 704c0-42.24 9.344-82.56 28.032-120.448L509.43808 0l293.504 583.04z",
|
|
109
|
+
windIconPath: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M 4.0003 14.0002 L 12.0003 14.0008 M 12.0003 14.0008 C 13.1049 14.0009 14.0003 14.8964 14.0002 16.001 C 14.0001 17.1055 13.1046 18.0009 12 18.0008 L 10.5 18.0007" stroke-linecap="round" stroke-linejoin="round"/>\n <path d="M 7 10.0002 L 14.5 10.0008 C 15.6046 10.0009 16.5001 9.1055 16.5002 8.001 C 16.5003 6.8964 15.6049 6.0009 14.5003 6.0008 L 13.0003 6.0007" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>',
|
|
110
|
+
windRatio: 0,
|
|
111
|
+
rainRatio: 0,
|
|
112
|
+
snowRatio: 0,
|
|
113
|
+
rainCountThreshold: 10,
|
|
114
|
+
snowCountThreshold: 10,
|
|
115
|
+
rainSizeRange: [ 5, 10 ],
|
|
116
|
+
snowSizeRange: [ 5, 13 ],
|
|
117
|
+
windSize: 30,
|
|
118
|
+
rainSpeed: 1,
|
|
119
|
+
snowSpeed: .5,
|
|
120
|
+
windSpeed: 1,
|
|
121
|
+
windAnimateEffect: "fade",
|
|
122
|
+
rainStyle: {},
|
|
123
|
+
snowStyle: {},
|
|
124
|
+
windStyle: {
|
|
125
|
+
opacity: .8
|
|
126
|
+
},
|
|
127
|
+
snowRainBottomPadding: 0
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=weather-box.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/weather/weather-box.ts"],"names":[],"mappings":";;;AAAA,uCAAiD;AAGjD,6CAAyC;AACzC,yDAA6G;AAG7G,SAAS,MAAM;IACb,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;AACvB,CAAC;AAED,SA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IAAI,CAAC,QAAQ,CAAC,CAAC;YAClB,IAAI,sBAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC1G;IACH,CAAC;;AA9LH,gCA+LC;AA5LQ,4BAAiB,GAA8B;IACpD,YAAY,EACV,wsDAAwsD;IAC1sD,YAAY,EACV,wdAAwd;IAC1d,YAAY,EAAE;;;WAGP;IACP,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC;IACZ,kBAAkB,EAAE,EAAE;IACtB,kBAAkB,EAAE,EAAE;IACtB,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;IACtB,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;IACtB,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,CAAC;IACZ,iBAAiB,EAAE,MAAM;IACzB,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,EAAE;IACb,SAAS,EAAE;QACT,OAAO,EAAE,GAAG;KACb;IACD,qBAAqB,EAAE,CAAC;CACzB,CAAC","file":"weather-box.js","sourcesContent":["import { AbstractComponent } from '../core/base';\nimport type { IWeatherBoxAttrs } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { merge } from '@visactor/vutils';\nimport { Animate, DefaultTimeline, type IGroup, type ISymbol, type ITimeline } from '@visactor/vrender-core';\n\n// todo 后续可能做成有随机数种子的伪随机,这样可以保证每次都生成一样的随机数\nfunction random() {\n return Math.random();\n}\n\nfunction createUniformRandom(count: number) {\n const result: number[] = [];\n const step = 1 / count;\n for (let i = 0; i < count; i++) {\n result.push(((random() - 0.5) * step) / 2 + step * i);\n }\n result.sort(() => Math.random() - 0.5);\n let idx = 0;\n return function (i?: number) {\n if (idx > count - 1) {\n idx = 0;\n }\n if (i === void 0) {\n i = idx;\n idx++;\n }\n return result[i];\n };\n}\n\nexport class WeatherBox extends AbstractComponent<Required<IWeatherBoxAttrs>> {\n name: string = 'weatherBox';\n\n static defaultAttributes: Partial<IWeatherBoxAttrs> = {\n snowIconPath:\n 'M512 64c24.7 0 44.8 20.1 44.8 44.8v43.1l29.3-15.5c21.9-11.6 49-3.2 60.5 18.7s3.2 49-18.7 60.5l-71.2 37.6v85.2c32 8.2 60.6 25.1 83.1 48l73.8-42.6-3-80.4c-0.9-24.7 18.4-45.5 43.1-46.4 24.7-0.9 45.5 18.4 46.4 43.1l1.2 33.1 37.3-21.5c21.4-12.4 48.8-5 61.2 16.4 12.4 21.4 5 48.8-16.4 61.2l-37.3 21.5 28.1 17.6c21 13.2 27.3 40.8 14.1 61.8-13.2 20.9-40.8 27.3-61.8 14.1l-68.2-42.8-73.6 42.5c4.2 15.3 6.5 31.4 6.5 48s-2.3 32.7-6.5 48l73.8 42.6 68.2-42.8c20.9-13.2 48.6-6.8 61.8 14.1 13.2 21 6.8 48.6-14.1 61.8l-28.1 17.6 37.3 21.5c21.4 12.4 28.8 39.8 16.4 61.2-12.4 21.4-39.8 28.8-61.2 16.4l-37.3-21.5-1.2 33.1c-0.9 24.7-21.7 44-46.4 43.1-24.7-0.9-44-21.7-43.1-46.4l3-80.4-73.8-42.6c-22.5 22.9-51 39.8-83.1 48v85.2l71.2 37.6c21.9 11.6 30.2 38.7 18.7 60.5-11.6 21.9-38.7 30.2-60.5 18.7L557 872.2v43.1c0 24.7-20.1 44.8-44.8 44.8-24.7 0-44.8-20.1-44.8-44.8v-43.1l-29.3 15.5c-21.9 11.6-49 3.2-60.5-18.7-11.6-21.9-3.2-49 18.7-60.5l71.2-37.6v-85.2c-32-8.2-60.6-25.1-83.1-48l-73.8 42.6 3 80.4c0.9 24.7-18.4 45.5-43.1 46.4-24.7 0.9-45.5-18.4-46.4-43.1l-1.2-33.1-37.3 21.5c-21.4 12.4-48.8 5-61.2-16.4s-5-48.8 16.4-61.2l37.3-21.5-28.1-17.6c-21-13.2-27.3-40.8-14.1-61.8 13.2-20.9 40.8-27.3 61.8-14.1l68.2 42.8 73.8-42.6c-4.2-15.3-6.5-31.4-6.5-48s2.3-32.7 6.5-48l-73.8-42.6-68.2 42.8c-21 13.2-48.6 6.8-61.8-14.1-13.2-21-6.8-48.6 14.1-61.8l28.1-17.6-37.3-21.5C119 336.8 111.7 309.4 124 288c12.4-21.4 39.8-28.8 61.2-16.4l37.3 21.5 1.2-33.1c0.9-24.7 21.7-44 46.4-43.1 24.7 0.9 44 21.7 43.1 46.4l-3 80.4 73.8 42.6c22.5-22.9 51-39.8 83.1-48v-85.2L396 215.6c-21.9-11.6-30.2-38.7-18.7-60.5 11.6-21.9 38.7-30.2 60.5-18.7l29.3 15.5v-43.1C467.2 84.1 487.3 64 512 64z m0 537.6c49.5 0 89.6-40.1 89.6-89.6s-40.1-89.6-89.6-89.6-89.6 40.1-89.6 89.6 40.1 89.6 89.6 89.6z',\n rainIconPath:\n 'M802.94208 583.04c19.328 38.016 29.056 78.336 29.056 120.96a313.216 313.216 0 0 1-44.032 161.536 324.48 324.48 0 0 1-114.56 114.944c-23.552 13.696-49.024 24.32-76.416 32-27.264 7.68-55.68 11.52-84.992 11.52-29.44 0-57.6-3.84-84.992-11.52a331.136 331.136 0 0 1-76.544-32 337.536 337.536 0 0 1-65.024-49.92 337.536 337.536 0 0 1-49.92-65.024 331.136 331.136 0 0 1-32-76.544A313.216 313.216 0 0 1 191.99808 704c0-42.24 9.344-82.56 28.032-120.448L509.43808 0l293.504 583.04z',\n windIconPath: `<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M 4.0003 14.0002 L 12.0003 14.0008 M 12.0003 14.0008 C 13.1049 14.0009 14.0003 14.8964 14.0002 16.001 C 14.0001 17.1055 13.1046 18.0009 12 18.0008 L 10.5 18.0007\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n <path d=\"M 7 10.0002 L 14.5 10.0008 C 15.6046 10.0009 16.5001 9.1055 16.5002 8.001 C 16.5003 6.8964 15.6049 6.0009 14.5003 6.0008 L 13.0003 6.0007\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>`,\n windRatio: 0,\n rainRatio: 0,\n snowRatio: 0,\n rainCountThreshold: 10,\n snowCountThreshold: 10,\n rainSizeRange: [5, 10],\n snowSizeRange: [5, 13],\n windSize: 30,\n rainSpeed: 1,\n snowSpeed: 0.5,\n windSpeed: 1,\n windAnimateEffect: 'fade',\n rainStyle: {},\n snowStyle: {},\n windStyle: {\n opacity: 0.8\n },\n snowRainBottomPadding: 0\n };\n\n timeline: ITimeline;\n\n constructor(attributes: IWeatherBoxAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, WeatherBox.defaultAttributes, attributes));\n this.timeline = options?.timeline ?? new DefaultTimeline();\n }\n\n protected render(): void {\n const {\n rainRatio,\n rainIconPath,\n snowRatio,\n snowIconPath,\n rainCountThreshold,\n snowCountThreshold,\n windRatio,\n rainSizeRange,\n snowSizeRange,\n rainSpeed,\n snowSpeed,\n width,\n height,\n windIconPath,\n windSize,\n windSpeed\n } = this.attribute as IWeatherBoxAttrs;\n\n this.attribute.clip = true;\n\n // 计算风速导致的偏转角度\n const windAngle = (-windRatio * Math.PI) / 4;\n\n const rainGroup = this.createOrUpdateChild('rain-container', { zIndex: 1, width, height }, 'group') as IGroup;\n if (rainRatio > 0) {\n this.generateRainOrSnow(\n 'rain',\n rainRatio,\n rainCountThreshold,\n windRatio,\n rainGroup,\n rainIconPath,\n windAngle,\n rainSizeRange,\n rainSpeed\n );\n }\n const snowGroup = this.createOrUpdateChild('snow-container', { zIndex: 1, width, height }, 'group') as IGroup;\n if (snowRatio > 0) {\n this.generateRainOrSnow(\n 'snow',\n snowRatio,\n snowCountThreshold,\n windRatio,\n snowGroup,\n snowIconPath,\n windAngle,\n snowSizeRange,\n snowSpeed\n );\n }\n\n const windGroup = this.createOrUpdateChild('wind-container', { zIndex: 0, width, height }, 'group') as IGroup;\n if (windRatio > 0) {\n this.generateWind(windRatio, windIconPath, windGroup, windSize, windSpeed);\n }\n }\n\n protected generateWind(windRatio: number, windIconPath: string, group: IGroup, size: number, speed: number) {\n const { width, height } = group.attribute;\n const { windAnimateEffect, windStyle = {} } = this.attribute;\n\n let fromAttribute = { opacity: 0, clipRange: 1 };\n let toAttribute = { opacity: 1, clipRange: 1 };\n if (windAnimateEffect === 'clipRange') {\n fromAttribute = { clipRange: 0, opacity: 1 };\n toAttribute = { clipRange: 1, opacity: 1 };\n }\n const wind = group.createOrUpdateChild(\n `wind`,\n {\n x: (width - size) / 2,\n y: (height - size) / 2,\n symbolType: windIconPath,\n size,\n stroke: 'white',\n lineWidth: 2,\n dx: -size / 2,\n dy: -size / 2,\n ...windStyle,\n ...fromAttribute\n },\n 'symbol'\n ) as ISymbol;\n\n const duration = (speed / 4) * 1000;\n\n new Animate(void 0, this.timeline)\n .bind(wind)\n .to(fromAttribute, duration, 'linear')\n .to(toAttribute, duration, 'linear')\n .wait(duration / 2)\n .loop(Infinity);\n }\n\n protected generateRainOrSnow(\n type: string,\n ratio: number,\n threshold: number,\n windRatio: number,\n group: IGroup,\n path: string,\n windAngle: number,\n sizeRange: [number, number],\n speed: number\n ) {\n let { width } = group.attribute;\n const { height } = group.attribute;\n const { snowRainBottomPadding, rainStyle = {}, snowStyle = {} } = this.attribute;\n let maxCount = Math.round(ratio * threshold);\n // 由于风速,雨雪粒子会偏转,所以需要增加粒子数量\n if (windRatio > 0) {\n maxCount = maxCount * Math.round(1 + windRatio);\n }\n width = width * Math.round(1 + windRatio);\n const uniformRandomX = createUniformRandom(maxCount);\n const uniformRandomY = createUniformRandom(maxCount);\n for (let i = 0; i < maxCount; i++) {\n const x = uniformRandomX();\n const y = uniformRandomY();\n const size = sizeRange[0] + random() * (sizeRange[1] - sizeRange[0]);\n\n const deltaX = windAngle ? height * Math.tan(Math.abs(windAngle)) : 0;\n const startX = x * width - deltaX;\n const startY = -y * height;\n const particle = group.createOrUpdateChild(\n `${type}-${i}`,\n {\n x: startX,\n y: startY,\n symbolType: path,\n size,\n fill: 'white',\n angle: windAngle,\n ...(type === 'rain' ? rainStyle : snowStyle)\n },\n 'symbol'\n ) as ISymbol;\n const duration = (1 / speed / 2) * (1 + y) * 1000;\n let endX = x * width;\n if (type === 'rain' && windAngle) {\n endX = startX + (1 + y) * height * Math.tan(Math.abs(windAngle));\n }\n new Animate(void 0, this.timeline)\n .bind(particle)\n .to({ x: endX, y: height - snowRainBottomPadding }, duration, 'linear')\n .loop(Infinity);\n new Animate(void 0, this.timeline).bind(particle).to({ opacity: 0 }, duration, 'quintIn').loop(Infinity);\n }\n }\n}\n"]}
|