diff --git a/README.md b/README.md index 69a9e7b..6352703 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,16 @@ cesium 军事标绘插件,支持绘制多边形、曲线、箭头等图形 -![image](https://ethan-zf.github.io/cesium-plot-js/examples/plot.png) +![image](https://ethan-zf.github.io/cesium-plot-js/examples/banner.png) -[在线示例:demo](https://ethan-zf.github.io/cesium-plot-js/examples/index.html) +淡入淡出效果: + +![image](https://ethan-zf.github.io/cesium-plot-js/examples/show-hide-animation.gif) + +生长动画: +![image](https://ethan-zf.github.io/cesium-plot-js/examples/attack-arrow-growth.gif) + +在线示例: [demo](https://ethan-zf.github.io/cesium-plot-js/examples/index.html) ### CDN @@ -107,23 +114,22 @@ const geometry = new CesiumPlot.FineArrow(Cesium, viewer, { ### 类的实例方法 -| 方法名 | 参数 | 描述 | -| ------ | --------------------------------------------------------------------- | ---------------------------------------------------- | -| hide | options?: [VisibleAnimationOpts](#VisibleAnimationOpts) | 隐藏,options 可配置过度动画,参数缺省时,不显示动画 | -| show | options?: [VisibleAnimationOpts](#VisibleAnimationOpts) | 显示,options 可配置过度动画,参数缺省时,不显示动画 | -| remove | | 删除 | -| on | (event: [EventType](#EventType), listener: (eventData?: any) => void) | 绑定事件 | -| off | (event: [EventType](#EventType)) | 解绑事件 | +| 方法名 | 参数 | 描述 | +| -------------------- | --------------------------------------------------------------------- | ---------------------------------------------------- | +| hide | options?: [AnimationOpts](#AnimationOpts) | 隐藏,options 可配置动画参数,参数缺省时,不显示动画 | +| show | options?: [AnimationOpts](#AnimationOpts) | 显示,options 可配置动画参数,参数缺省时,不显示动画 | +| startGrowthAnimation | options?: [AnimationOpts](#AnimationOpts) | 生长动画,options 可配置动画参数 | +| remove | | 删除 | +| on | (event: [EventType](#EventType), listener: (eventData?: any) => void) | 绑定事件 | +| off | (event: [EventType](#EventType)) | 解绑事件 | -
VisibleAnimationOpts类型
+
AnimationOpts类型
-``` -{ - duration?: number; // 动画持续时间(ms),默认1000 - delay?: number; // 动画延迟启动时间(ms),默认0 - callback?: (() => void) // 动画结束回调 -}; -``` +| 参数 | 类型 | 默认值 | 描述 | +| -------- | ---------- | ------ | ---------------------- | +| duration | number | 2000 | 动画持续时间(ms) | +| delay | number | 0 | 动画延迟启动时间(ms) | +| callback | () => void | - | 动画结束回调 | ``` // 隐藏图形 diff --git a/src/base.ts b/src/base.ts index 9f107db..2355f3a 100644 --- a/src/base.ts +++ b/src/base.ts @@ -491,7 +491,7 @@ export default class Base { } } - showWithAnimation(duration: number = 1000, delay: number = 0, callback?: () => void) { + showWithAnimation(duration: number = 2000, delay: number = 0, callback?: () => void) { if (this.state != 'static' || this.isHidden === false) { //If not in a static state or already displayed, do not process. return; @@ -531,7 +531,7 @@ export default class Base { } } - hideWithAnimation(duration: number = 1000, delay: number = 0, callback?: () => void) { + hideWithAnimation(duration: number = 2000, delay: number = 0, callback?: () => void) { if (this.state != 'static' || this.isHidden === true) { return; } @@ -645,7 +645,7 @@ export default class Base { } startGrowthAnimation(opts: GrowthAnimationOpts) { - const { duration = 3000, delay = 0, callback } = opts || {}; + const { duration = 2000, delay = 0, callback } = opts || {}; if (this.state !== 'static') { return; } @@ -716,7 +716,7 @@ export default class Base { }, delay); } - private doubleArrowGrowthAnimation(duration: number = 3000, delay: number = 0, callback?: Function) { + private doubleArrowGrowthAnimation(duration: number = 2000, delay: number = 0, callback?: Function) { setTimeout(() => { this.viewer.entities.remove(this.polygonEntity); this.viewer.entities.remove(this.outlineEntity);