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

text-typers

v1.0.4

Published

Module for text typing with cursor effect

Downloads

2

Readme

⌨️ Text Typer ⌨️

Demonstration of TextTyper in gif format

Links

Usage

Simply put the script tag into your HTML document. Module will be loaded via CDN

<script src='https://unpkg.com/text-typers@latest/build/bundle.js'></script>

Example

const tt = new TextTyper( document.getElementById('test') );

tt.eventQueue()
    .typeText('Hello World!')
    .standby(1000)
    .deleteChar()
    .standby(500)
    .typeText('Text Typer! ✏')
    .start();

Non-Chainable Methods

Those methods upon called, will perform the event immediately, asynchronously. Usually, you would want to use Chainable Methods instead.

| Method | Parameters | Description | Example | |-|-|-|-| | constructor | textBox - Targeted HTML element to type text in. TextBoxSettings (optional) - See more in TextBoxSettings. | Constructor. Initializes a Text Typer on the target HTML element to be the text box (The HTML element that text will be typed in | const tt = new TextTyper(document.getElementById('my-box') ); | | typeText | string - The text to be typed one by one into text box | Types the string provided into the text box | tt.typeText('Hello World'); | | putText | string - The text to be put into text box | Put the string immediately into the text box. | tt.putText('Hello World'); | | deleteChar | count (optional) - Number of characters to be deleted. If exceeds the number of existing characters, it will simply stop after all characters are deleted. If no argument given, it will delete everything inside the text box one by one | Deletes the specified number of characters from the text box. | tt.deleteChar(); tt.deletecChar(10); | | clearText | - | Clears the textbox immediately | tt.clearText(); | | settings | TextBoxSettings | Change the settings of the Text typer | See Settings | | presetTheme | theme - The theme to be applied to the textbox. See Settings | Applies a Preset Theme to the text box. | See Settings | | eventQueue | - | Initializes and returns the Event Queue to obtain the ability to chain events | const eq = tt.eventQueue(); |

Chainable Methods

With eventQueue() called, it will return a CursorEventQueue object which you can chain events and have them execute one after another synchronously.

Most of the methods mentioned above in Non-Chainable Methods are also chainable for CursorEventQueue.

| Method | Parameters | Description | Example | |-|-|-|-| | start | - | Starts the event queue, in one pass | eq.typeText("Hello World!").start(); | | loop | count (optional) - Number of times to loop. If no arguments specified, will loop for infinite times. | Adds a loop event to the event queue. It will loop everything currently in the event queue for specified number of times. Note that after loop, the events are cleared. | eq.typeText("a").loop(3).start(); // This will cause 'aaaa' to be typed | | standby | time - Time in milliseconds for the stand by duration | Hold for specified milliseconds before execution of next event in the queue | eq.standby(3000) | | clearHistory | - | Clears the current history queue, so previously queued events won't be executed in the upcoming loop | eq.typeText('a').clearHistory().loop().start() // Only single 'a' will be typed | | typeText | string - The text to be typed one by one into text box | Types the string provided into the text box | eq.typeText('Hello World') | | putText | string - The text to be put into text box | Put the string immediately into the text box. | eq.putText('Hello World') | | deleteChar | count (optional) - Number of characters to be deleted. If exceeds the number of existing characters, it will simply stop after all characters are deleted. If no argument given, it will delete everything inside the text box one by one | Deletes the specified number of characters from the text box. | eq.deleteChar(); eq.deleteChar(10) | | clearText | - | Clears the textbox immediately | tt.clearText(); | | settings | TextBoxSettings | Change the settings of the Text typer | See Settings | | presetTheme | theme - The theme to be applied to the textbox. See Setting Constants | Applies a Preset Theme to the text box. | See Setting Constants | | eventQueue | - | Initializes and returns the Event Queue to obtain the ability to chain events | const eq = tt.eventQueue(); |

Settings

This module comes with several settings that you can set to customize the behavior and look of the cursor.

First, familiarize yourself with format of the settings javascript object:

  • CursorSettings

{ blinkMode, blinkPeriod, cursorStyling }

| Property | Description | |-|-| | blinkMode | A string constant. Will determine the cursor blinking behavior. Explained in Setting Constants | | blinkPeriod | Time taken to complete one cycle of blinking (dissapear and reappear of Cursor), in milliseconds. | | cursorStyling | A string constant. Will style the cursor. Explained in Setting Constants |

  • TextBoxSettings

{ typeCPS, deleteCPS, cursorSettings }

| Property | Description | |-|-| | typeCPS | Number. Characters per second for typing | | deleteCPS | Number. Characters per second for deleting | | cursorSettings | CursorSettings Object |

Setting Constants

Constants to be used in settings. Accessed via static class property - TextTyper.YOUR_CONSTANT_HERE

  1. blinkMode constants
    • TextTyper.CURSOR_BLINK_FLASH - Cursor dissapears suddenly, then reappears. Very commonly seen
    • TextTyper.CURSOR_BLINK_LINEAR - Cursor transitions to opacity 0 then transition to opacity 1
    • TextTyper.CURSOR_BLINK_NONE - Cursor will not blink at all
  2. cursorStyling constants
    • TextTyper.CURSOR_STYLE_BLOCK - Cursor appear as a rectangular, filled block
    • TextTyper.CURSOR_STYLE_I - Cursor appear capital i shaped
    • TextTyper.CURSOR_STYLE_LEFTARR - Cursor appear as <
    • TextTyper.CURSOR_STYLE_NONE - Cursor becomes invisible
    • TextTyper.CURSOR_STYLE_VERT - Cursor appear | shaped
    • TextTyper.CURSOR_STYLE_Y - Cursor appear capital i shaped, but top and buttom is curved
    • TextTyper.CURSOR_STYLE__ - Cursor appear as underscore shaped, _
  3. presetTheme constants
    • TextTyper.TBOX_THEME_DARK - Dark background green text
    • TextTyper.TBOX_THEME_DEFAULT - Default theme

Extensions

You can extend the functionality of this module through extensions!

  1. Sound Extension