@goodpie/html-typer
Version:
Types out HTML into a view, supporting vanilla JS
22 lines (21 loc) • 886 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HtmlTyper = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const index_1 = require("./index");
/**
* AnimatedText is a React component that renders HTML with a typewriter effect.
*/
const HtmlTyper = ({ html, speed = 50, className, style, }) => {
const containerRef = (0, react_1.useRef)(null);
(0, react_1.useEffect)(() => {
if (containerRef.current) {
// Call the animate function when the component mounts or when html/speed changes.
(0, index_1.animateHtmlRendering)(containerRef.current, html, speed);
}
}, [html, speed]);
return (0, jsx_runtime_1.jsx)("div", { ref: containerRef, className: className, style: style });
};
exports.HtmlTyper = HtmlTyper;
exports.default = exports.HtmlTyper;