This package allows you to create a typewriter than starts when observed hasslefree!
npm i sveltescrolltypewriter
import SvelteScrollTypewriter from SvelteScrollTypewriter
A requirements are two variables in the script tag being:
let furthestScrolled = 0;
let scroll = 0;
$: if (scroll > furthestScrolled) {
furthestScrolled = scroll;
}
The following tag somewhere in the file:
<svelte:window bind:scrollY={scroll} />
and for each typewriter, specific variables for binding, such as:
let typewriter1;
let height1;
In your onMount function, place the following:
onMount(() => {
height1 = typewriter1.getBoundingClientRect().top - 300;
// do this for every height, eg height2, height3 etc.
});
Then, place the following wherever desired. HEIGHT is a placeholder for the height variable, and PHRASE is a placeholder for your custom phrase:
<div bind:this={typewriter1}>
<Typewriter
height={height1}
{furthestScrolled}
phrase="PHRASE"
/>
</div>
auto: boolean
height: integer
furthestScrolled: integer
phrase: string
fontSize: integer
I apologise for the bloat, but the package works.
There is no stylign attatched to the typewriter, just plain text
Thank you for using my package :)