MCPcopy Create free account
hub / github.com/neomjs/neo / afterSetText

Method afterSetText

src/component/MagicMoveText.mjs:321–362  ·  view source on GitHub ↗

* This is the main entry point for the animation when the `text` config is changed. * It orchestrates the measurement and animation phases. It also contains a `try/catch` * block to handle potential errors during the complex animation logic, with a single-retry * mechanism to recover

(value, oldValue)

Source from the content-addressed store, hash-verified

319 * @protected
320 */
321 async afterSetText(value, oldValue) {
322 let me = this,
323 {measureElement} = me;
324
325 if (oldValue) {
326 me.previousChars = me.chars
327 }
328
329 if (value) {
330 try {
331 me.chars = [];
332 measureElement.cn = [];
333
334 value?.split('').forEach(char => {
335 me.chars.push({name: char});
336 measureElement.cn.push({tag: 'span', text: char})
337 });
338
339 if (me.mounted) {
340 await me.measureChars()
341 }
342
343 if (me.isDestroyed) return;
344
345 await me.updateChars()
346 } catch (e) {
347 if (e === Neo.isDestroyed) return;
348
349 if (!me.isRetrying) {
350 me.isRetrying = true;
351 me.previousChars = [];
352
353 // Reset a transitioning state
354 me.visualWrapper.cn.length = 0;
355
356 await me.afterSetText(value, oldValue)
357 }
358 }
359
360 me.isRetrying = false
361 }
362 }
363
364 /**
365 * Updates the VDOM to include or remove the SEO-friendly list.

Callers

nothing calls this directly

Calls 5

splitMethod · 0.80
measureCharsMethod · 0.80
updateCharsMethod · 0.80
forEachMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected