(entries)
| 38 | |
| 39 | // Function to handle the entry of the expanding box |
| 40 | function handleBoxIntersection(entries) { |
| 41 | entries.forEach(entry => { |
| 42 | if (entry.isIntersecting) { |
| 43 | var box = entry.target; |
| 44 | boxObserver.unobserve(box); // Stop observing once the animation has triggered |
| 45 | |
| 46 | // Add a wait time (e.g., 500ms) before opening the box |
| 47 | setTimeout(() => { |
| 48 | const width = box.dataset.width; // Assuming it's a string (like '400px' or '50%') |
| 49 | box.style.width = width |
| 50 | box.classList.add('open'); // Add class to trigger the expansion |
| 51 | if (width) { |
| 52 | box.style.width = width; // Set the width dynamically |
| 53 | } |
| 54 | |
| 55 | function handleTextBox(query) { |
| 56 | var textBox = box.querySelector(query); |
| 57 | const text = textBox.dataset.text; // Store the original text |
| 58 | textBox.textContent = ""; // Clear the box for typing effect |
| 59 | let index = 0; |
| 60 | |
| 61 | // Function to type text slowly |
| 62 | function type() { |
| 63 | if (index < text.length) { |
| 64 | textBox.textContent += text.charAt(index); // Append the current character |
| 65 | index++; |
| 66 | setTimeout(type, 50); // Schedule the next character typing |
| 67 | } else { |
| 68 | isTyping = false; // Reset flag when typing is done |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | type(); // Start typing the text |
| 73 | } |
| 74 | for (let i = 0; i <= box.children.length; i++) { |
| 75 | handleTextBox("#expandText"+i.toString()); |
| 76 | } |
| 77 | |
| 78 | }, 200); // Adjust this value to set the wait time (in milliseconds) |
| 79 | |
| 80 | } |
| 81 | }); |
| 82 | } |
| 83 | |
| 84 | // Create an Intersection Observer instance for the expanding box |
| 85 | const boxObserver = new IntersectionObserver(handleBoxIntersection, { |
nothing calls this directly
no test coverage detected