@@ -76,6 +76,10 @@ class MagicMoveText extends Component {
7676 * @member {Object[]} chars=[]
7777 */
7878 chars = [ ]
79+ /**
80+ * @member {Object[]} charsVdom=[]
81+ */
82+ charsVdom = [ ]
7983 /**
8084 * @member {Number} currentIndex=0
8185 */
@@ -287,21 +291,26 @@ class MagicMoveText extends Component {
287291 async updateChars ( ) {
288292 let me = this ,
289293 { chars, previousChars} = me ,
290- charsContainer = me . vdom . cn [ 0 ] . cn ,
294+ charsContainer = me . vdom . cn [ 0 ] ,
291295 letters = chars . map ( char => char . name ) ,
292296 char , charNode , index ;
293297
298+ if ( me . charsVdom . length > 1 ) {
299+ charsContainer . cn = me . charsVdom ;
300+ await me . promiseUpdate ( )
301+ }
302+
294303 previousChars . forEach ( ( previousChar , previousIndex ) => {
295304 index = letters . indexOf ( previousChar . name ) ;
296305
297306 if ( index > - 1 ) {
298- charNode = charsContainer [ previousIndex ] ;
307+ charNode = charsContainer . cn [ previousIndex ] ;
299308
300309 charNode . style . color = me . colorMove ;
301310 charNode . style . left = chars [ index ] . left ;
302311 letters [ index ] = null
303312 } else {
304- charNode = charsContainer [ previousIndex ] ;
313+ charNode = charsContainer . cn [ previousIndex ] ;
305314
306315 charNode . flag = 'remove'
307316 }
@@ -311,7 +320,8 @@ class MagicMoveText extends Component {
311320 if ( letter !== null ) {
312321 char = chars [ index ] ;
313322
314- charsContainer . push ( {
323+ charsContainer . cn . push ( {
324+ cls : [ 'neo-char' ] ,
315325 html : char . name ,
316326 style : { color : me . colorFadeIn , left : char . left , opacity : 0 , top : char . top }
317327 } )
@@ -320,7 +330,7 @@ class MagicMoveText extends Component {
320330
321331 await me . promiseUpdate ( ) ;
322332
323- charsContainer . forEach ( charNode => {
333+ charsContainer . cn . forEach ( charNode => {
324334 if ( charNode . flag === 'remove' ) {
325335 charNode . style . color = me . colorFadeOut ;
326336 charNode . style . opacity = 0
@@ -332,21 +342,29 @@ class MagicMoveText extends Component {
332342 await me . promiseUpdate ( ) ;
333343 await me . timeout ( me . transitionTime ) ;
334344
335- charsContainer . sort ( ( a , b ) => parseFloat ( a . style . left ) - parseFloat ( b . style . left ) ) ;
345+ charsContainer . cn . sort ( ( a , b ) => parseFloat ( a . style . left ) - parseFloat ( b . style . left ) ) ;
336346
337- index = charsContainer . length - 1 ;
347+ index = charsContainer . cn . length - 1 ;
338348
339349 for ( ; index >= 0 ; index -- ) {
340- charNode = charsContainer [ index ] ;
350+ charNode = charsContainer . cn [ index ] ;
341351
342352 delete charNode . flag ;
343353 delete charNode . style . color ;
344354
345355 if ( charNode . style . opacity === 0 ) {
346- charsContainer . splice ( index , 1 )
356+ charsContainer . cn . splice ( index , 1 )
347357 }
348358 }
349359
360+ await me . promiseUpdate ( ) ;
361+
362+ me . charsVdom = [ ...charsContainer . cn ] ;
363+
364+ charsContainer . cn . length = 0 ;
365+
366+ charsContainer . cn . push ( { html : me . text } ) ;
367+
350368 await me . promiseUpdate ( )
351369 }
352370}
0 commit comments