33 * @Author : zk
44 * @Date : 2022-03-23 10:02:49
55 * @LastEditors : zk
6- * @LastEditTime : 2022-06-15 20:47:28
6+ * @LastEditTime : 2022-06-16 11:37:25
77 */
88import Point from '../../../../../PlotUtilBase/Geometry/Point' ;
99import Spline from '../../../../../PlotUtilBase/Geometry/Spline' ;
@@ -14,8 +14,8 @@ export default class PlotGrowAnimation extends PlotCoordsAnimation {
1414 constructor ( options ) {
1515 super ( options ) ;
1616 }
17- _initBaseAttributes ( options ) {
18- super . _initBaseAttributes ( options )
17+ _initBaseAttributes ( options ) {
18+ super . _initBaseAttributes ( options ) ;
1919 // animation type
2020 this . animationType = 'grow-animation' ;
2121 // init options
@@ -31,7 +31,11 @@ export default class PlotGrowAnimation extends PlotCoordsAnimation {
3131 // 1.spline
3232 if ( mode === 'spline' ) {
3333 this . splines = polysArr . map ( ( s ) => {
34- return new Spline ( s , { } ) ;
34+ if ( s . length >= 2 ) {
35+ return new Spline ( s , { } ) ;
36+ } else {
37+ return null ;
38+ }
3539 } ) ;
3640 } else if ( mode === 'center' ) {
3741 this . modeFunArr = [ ] ;
@@ -40,6 +44,10 @@ export default class PlotGrowAnimation extends PlotCoordsAnimation {
4044 const len = polys . length ;
4145 const v = [ ] ;
4246 let center ;
47+ if ( len <= 1 ) {
48+ v . push ( null ) ;
49+ continue ;
50+ }
4351 if ( len === 2 ) {
4452 center = [ ( polys [ 1 ] . x - polys [ 0 ] . x ) / 2 + polys [ 0 ] . x , ( polys [ 1 ] . y - polys [ 0 ] . y ) / 2 + polys [ 0 ] . y ] ;
4553 } else {
@@ -69,6 +77,7 @@ export default class PlotGrowAnimation extends PlotCoordsAnimation {
6977 const splines = this . splines ;
7078 const trueRate = this . _calcTrueRate ( rate ) ;
7179 splines . forEach ( ( t , index ) => {
80+ if ( ! t ) return ;
7281 const animationPoly = this . _animationPolys [ index ] ;
7382 const animationObject = this . _plotObjects [ index ] ;
7483 if ( animationPoly . length > 0 ) {
@@ -92,25 +101,25 @@ export default class PlotGrowAnimation extends PlotCoordsAnimation {
92101 _centerAction ( rate ) {
93102 const trueRate = this . _calcTrueRate ( rate ) ;
94103 this . _plotObjects . forEach ( ( plotObject , i ) => {
95- const tPolys = this . modeFunArr [ i ] . map ( ( s ) => {
104+ if ( ! this . modeFunArr || ! this . modeFunArr [ i ] ) return ;
105+ const tPolys = this . modeFunArr [ i ] . map ( ( s ) => {
96106 const p = s ( trueRate ) ;
97-
107+
98108 return new Point ( p [ 0 ] , p [ 1 ] ) ;
99109 } ) ;
100110 this . _setPnts ( plotObject , tPolys ) ;
101111 } ) ;
102112 }
103113
104- exportOption ( ) {
105- const object = super . exportOption ( )
106- const propertys = PlotGrowAnimation . cacheProperty . split ( ',' )
107- propertys . forEach ( ( s ) => {
108- object [ s ] = this [ s ]
109- } )
110- return object
114+ exportOption ( ) {
115+ const object = super . exportOption ( ) ;
116+ const propertys = PlotGrowAnimation . cacheProperty . split ( ',' ) ;
117+ propertys . forEach ( ( s ) => {
118+ object [ s ] = this [ s ] ;
119+ } ) ;
120+ return object ;
111121 }
112122
113-
114123 _render ( rate ) {
115124 const mode = this . growMode ;
116125 if ( mode === 'spline' ) {
@@ -124,4 +133,4 @@ export default class PlotGrowAnimation extends PlotCoordsAnimation {
124133 }
125134}
126135
127- PlotGrowAnimation . cacheProperty = 'startRate,endRate,growMode'
136+ PlotGrowAnimation . cacheProperty = 'startRate,endRate,growMode' ;
0 commit comments