Untitled
unknown
plain_text
a year ago
872 B
19
Indexable
const text = document.getElementById('type-element').innerHTML;
const hiddenElement = document.getElementById('type-hidden-element');
hiddenElement.innerHTML = text;
const fullHeight = hiddenElement.offsetHeight;
new TypeIt("#type-element", {
speed: 5,
waitUntilVisible: true,
cursor: false,
html: true,
loop: false,
afterComplete: async (instance) => {
updateElementHeight();
},
beforeStep: async (instance) => {
updateElementHeight();
},
}).go();
function updateElementHeight() {
const updatedFullHeight = hiddenElement.offsetHeight;
document.getElementById('type-element').style.height = updatedFullHeight + 'px';
}
window.addEventListener('resize', function() {
updateElementHeight();
});Editor is loading...
Leave a Comment