Untitled
unknown
javascript
2 years ago
943 B
7
Indexable
monogatari.on('ShowLine', () => {
// Extract the line from html
const textContainer = document.querySelector('[data-ui="say"]');
if (!textContainer) return;
// Hide the original text container
textContainer.style.display = 'none';
// Create a new <p> element
const newTextContainer = document.createElement('p');
newTextContainer.setAttribute('data-ui', 'say-new'); // Set a new data-ui attribute to distinguish
// Fetch and process the text from the original container
const text = textContainer.innerText;
const letters = text.split('').map((char, index) => {
const span = `<span class="letter" style="animation-delay: ${index * 0.05}s;">${char}</span>`;
return char === ' ' ? ' ' : span; // Handle spaces correctly
}).join('');
newTextContainer.innerHTML = letters;
// Append the new <p> element to the DOM
textContainer.parentNode.insertBefore(newTextContainer, textContainer.nextSibling);
});Editor is loading...
Leave a Comment