npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

crawling-typer

v1.1.1

Published

Transform your text with dynamic typing animations! crawling-typer lets you display an array of strings one at a time, each with its own color. Customize typing speed, delete speed, and pauses between strings. Enjoy full control with loop counts, post-loo

Downloads

10

Readme

Documentation

NPM crawling-typer is a js node package made to easily implement the stylish effect of typing an array of words one character at the time. Quickly customize settings such as typing speed, delete speed, pause time between one word and the next, number of times the effect should loop and effect behavior after said number (if finite) of loops has concluded.

Index

  1. Add crawling-typer to your project
  2. Type Words Function
  3. Secondary Functions
    i. Pause Effect
    ii. Resume Effect
    iii. Reset Effect
    iv. Set Cursor
  4. Examples

To use crawling typer in your project just import the npm package in the JavaScript File you want to use the effect in by adding the following import statement at the top of your page:

import TypeWords from 'https://cdn.jsdelivr.net/npm/[email protected]/typer.js';
function TypeWords(words, target, typeSpeed, deleteSpeed, pauseTime, loops, state, bhvr)

Words $\rightarrow$ is the array of words that you want to display, each word has to paramaters:

text: is the string that you want to type
color: the color of the this string

Target $\rightarrow$ is the target element where the words should be typed

Type Speed $\rightarrow$ is the time in miliseconds (ms) that should be waited after a char is displayed until the next one is typed

By default its' value is set to 250ms

Delete Speed $\rightarrow$ is the time in miliseconds (ms) that should be waited after a char is removed until the next one is deleted

By default its' value is set to 75ms

Pause Time $\rightarrow$ is the time in miliseconds (ms) that should be waited after a word has been fully typed to when it starts getting deleted, also used for the time since a word has been fully deleted to when the next one starts being typed

By default its' value is set to 1000ms

Loops $\rightarrow$ The number of times the array should loop before the effect stops, if this number is set to 0 then the effect will loop endlessly

By default its' value is set to 0

State $\rightarrow$ The starting state of the effect, this paramater takes only two values:

By default its' value is set to play

BHVR (Behaviour) $\rightarrow$ This defines how the effect should behave after the effect has looped a finite amount of times.It takes two paramagters:

Name: name of the behaviour case that should be applied.
      Name takes the following values: 

By default its' value is set to none

Index: Index of the word at which the chosen behaviour should be applied

By default its' value is set to 0

    TypeWords.pause();
Pauses the effect at the current typed/deleted character
    TypeWords.resume(); 
Resumes the effect at the current typed/deleted character
    TypeWords.reset(); 
Restarts the effect from the start

NOTE: The effect can be reset only if the effect is paused

    TypeWords.cursor(visible, blinkSpeed, symbol)
Adds a cursor to the head of the typed word.
Takes the following parameters:

Visible $\rightarrow$ makes the cursor visible, it takes only takes two values:

By default its' value is set to false

Blink Speed $\rightarrow$ sets the speed at which the cursor should be blink, if it's set to 0 the cursor will remain still and not blink

NOTE: It is worth noteing that every time a character is typed this timer resets

By default its' value is set to 0

Symbol $\rightarrow$ sets the symbol that should be used as a cursor icon

By default this is set to an underscore ("_")

EX 1

This creates a basic typing effect cycling endlessly between the words "Hello" and "Everybody" using default values and adding a cursor to the effect

HTML

<body>
    <p>(✿◠‿◠) <span class="generated"></span></p>
    
    <script type="module" src="index.js"></script>
</body>

JAVA SCRIPT

import TypeWords from 'https://cdn.jsdelivr.net/npm/[email protected]/typer.js';

console.log("TypeWords: ", TypeWords);

let target = document.getElementsByClassName("generated")[0]; 

const typingEffect = TypeWords([{text:"Hello", color:"#000000"}, {text:"Everybody", color:"#CA8311FF"}], target);

typingEffect.cursor(true); 

EX 2

This plays the childish game "She Loves Me, She Loves Me Not" by looping the words a random amount of times and stopping on one of the two random outcomes. Starts the effect in the pause state, so the user needs to start it by clicking the resume of reset buttons, adds a pause button so he can pause the effect and removes the cursor, adds custom typeSpeed, deleteSpeed and pauseTime between words

HTML

<body>
    <p>(✿◠‿◠) <span class="generated"></span></p>

    <div>
        <span><button id="pause" class="def-btn">Pause</button></span>
        <span><button id="resume" class="def-btn">Resume</button></span>
        <span><button id="reset" class="def-btn">Reset</button></span>
    </div>
    
    <script type="module" src="index.js"></script>
</body>

JAVA SCRIPT

import TypeWords from 'https://cdn.jsdelivr.net/npm/[email protected]/typer.js';

const numberOfLoops = Math.floor(Math.random() * 10) + 1;
const randIndex = Math.floor(Math.random() * 2);

console.info(`number of loops ${numberOfLoops}\nrandom index ${randIndex}`);

let target = document.getElementsByClassName("generated")[0]; 
let resetBtn = document.getElementById("reset"); 
let pauseBtn = document.getElementById("pause"); 
let playBtn = document.getElementById("resume"); 

const typingEffect = TypeWords([{text:"She Loves Me", color:"#319507FF"}, {text:"She Loves Me Not", color:"#A91818FF"}], target, 150, 100, 1500, numberOfLoops, "pause", {name:"forwards", index: randIndex});


resetBtn.addEventListener('click', () => { typingEffect.reset(); });
pauseBtn.addEventListener('click', () => { typingEffect.pause(); });
playBtn.addEventListener('click', () => { typingEffect.resume(); });