mirror of
https://github.com/ethan-zf/cesium-plot-js.git
synced 2025-06-24 03:27:29 +00:00
Adjust the display and hide invocation method to support parameter-configured animations.
This commit is contained in:
parent
a3dec9df66
commit
1ce9d9ab5c
20
src/base.ts
20
src/base.ts
@ -1,7 +1,7 @@
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
// import * as CesiumTypeOnly from 'cesium';
|
// import * as CesiumTypeOnly from 'cesium';
|
||||||
import * as CesiumTypeOnly from 'cesium';
|
import * as CesiumTypeOnly from 'cesium';
|
||||||
import { State, GeometryStyle, PolygonStyle, LineStyle, EventType, EventListener } from './interface';
|
import { State, GeometryStyle, PolygonStyle, LineStyle, EventType, EventListener, VisibleAnimationOpts } from './interface';
|
||||||
import EventDispatcher from './events';
|
import EventDispatcher from './events';
|
||||||
import cloneDeep from 'lodash.clonedeep';
|
import cloneDeep from 'lodash.clonedeep';
|
||||||
import merge from 'lodash.merge';
|
import merge from 'lodash.merge';
|
||||||
@ -466,7 +466,12 @@ export default class Base {
|
|||||||
* center at a precision-less position. Thus, when toggling the visibility state, adjust the 'clampToGround'
|
* center at a precision-less position. Thus, when toggling the visibility state, adjust the 'clampToGround'
|
||||||
* status first to avoid this issue.
|
* status first to avoid this issue.
|
||||||
*/
|
*/
|
||||||
show() {
|
show(opts: VisibleAnimationOpts) {
|
||||||
|
if (opts) {
|
||||||
|
const { duration, delay, callback } = opts;
|
||||||
|
this.showWithAnimation(duration, delay, callback);
|
||||||
|
return
|
||||||
|
}
|
||||||
if (this.type === 'polygon') {
|
if (this.type === 'polygon') {
|
||||||
this.polygonEntity.show = true;
|
this.polygonEntity.show = true;
|
||||||
this.outlineEntity.polyline.clampToGround = true;
|
this.outlineEntity.polyline.clampToGround = true;
|
||||||
@ -478,7 +483,12 @@ export default class Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hide() {
|
hide(opts: VisibleAnimationOpts) {
|
||||||
|
if (opts) {
|
||||||
|
const { duration, delay, callback } = opts;
|
||||||
|
this.hideWithAnimation(duration, delay, callback);
|
||||||
|
return
|
||||||
|
}
|
||||||
if (this.type === 'polygon') {
|
if (this.type === 'polygon') {
|
||||||
this.polygonEntity.show = false;
|
this.polygonEntity.show = false;
|
||||||
this.outlineEntity.polyline.clampToGround = false;
|
this.outlineEntity.polyline.clampToGround = false;
|
||||||
@ -490,7 +500,7 @@ export default class Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showAnimation(duration: number = 1000, delay: number = 0, callback: (() => void) | undefined) {
|
showWithAnimation(duration: number = 1000, delay: number = 0, callback?: (() => void)) {
|
||||||
if (this.state != 'static' || this.isHidden === false) {
|
if (this.state != 'static' || this.isHidden === false) {
|
||||||
//If not in a static state or already displayed, do not process.
|
//If not in a static state or already displayed, do not process.
|
||||||
return;
|
return;
|
||||||
@ -537,7 +547,7 @@ export default class Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hideAnimation(duration: number = 1000, delay: number = 0, callback: (() => void) | undefined) {
|
hideWithAnimation(duration: number = 1000, delay: number = 0, callback?: (() => void)) {
|
||||||
if (this.state != 'static' || this.isHidden === true) {
|
if (this.state != 'static' || this.isHidden === true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -17,3 +17,9 @@ export type GeometryStyle = PolygonStyle | LineStyle;
|
|||||||
|
|
||||||
export type EventType = 'drawStart' | 'drawUpdate' | 'drawEnd' | 'editEnd' | 'editStart';
|
export type EventType = 'drawStart' | 'drawUpdate' | 'drawEnd' | 'editEnd' | 'editStart';
|
||||||
export type EventListener = (eventData?: any) => void;
|
export type EventListener = (eventData?: any) => void;
|
||||||
|
|
||||||
|
export type VisibleOpts = {
|
||||||
|
duration?: number;
|
||||||
|
delay?: number;
|
||||||
|
callback?: (() => void)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user