Logo

0x3d.Site

is designed for aggregating information.
Welcome
check repository here

typical

Animated typing in ~400 bytes :blowfish: of JavaScript.

  • Zero dependencies
  • MIT licensed
  • Emoji support
  • Smart delete: only delete what needs deleting
  • Pausing: pause between steps
  • Looping: easily loop from any point
  • Waiting: wait on arbitrary Promises
  • Humanity: slightly varied typing speed

Demo →


Install

npm install @camwiegert/typical
More install options

Instead of using a package manager, you can download typical.js from GitHub and import it locally or import it directly from a CDN like unpkg.

API

type(target: HTMLElement, ...steps: any[]) => Promise<void>;

The module exports a single function, type, which takes a target element as its first argument, and any number of additional arguments as the steps to perform. Additional arguments perform actions based on their type:

TypeAction
stringType text
numberPause (milliseconds)
functionCall with target element
PromiseWait for resolution

Usage

The most basic usage of type is providing a target element and a string to type.

import { type } from '@camwiegert/typical';

type(element, 'text');

Pausing

In order to pause typing at any point, pass a number of milliseconds to pause.

type(element, 'Hello', 1000, 'Hello world!');

Looping

In order to loop, pass type as a parameter to itself at the point at which you'd like to start looping. It can be helpful to alias type as loop to be explicit.

import {
    type,
    type as loop
};

const steps = [1000, 'Ready', 1000, 'Set', 1000, 'Go'];

type(element, ...steps, loop);

To loop a finite amount, pass your steps multiple times.

type(element, ...steps, ...steps, ...steps);

Waiting

When passed a Promise, type will wait for it to resolve before continuing. Because type itself returns a Promise, that means you can wait on a set of steps to complete before starting another.

const init = type(target, 'In a moment...', 500);

type(target, init, 'start', 500, 'looping', loop);

Functions

Function arguments are passed the target element, and can be useful for operating on the target element between steps. If you return a Promise, type will wait for it to resolve.

const toggle = (element) =>
    element.classList.toggle('is-typing');

type(target, toggle, 'Type me', toggle);

Support

  • Chrome
  • Edge
  • Firefox
  • Safari
  • Internet Explorer

Related

JavaScript
JavaScript
JavaScript is a dynamic scripting language used to create interactive web experiences. It's an essential tool for front-end development, enabling features like dynamic content, animations, and event handling. JavaScript is supported by all major browsers.
GitHub - dalekjs/dalek: [unmaintained] DalekJS Base framework
GitHub - dalekjs/dalek: [unmaintained] DalekJS Base framework
Tabulator - Interactive JavaScript Tables
Tabulator - Interactive JavaScript Tables
GitHub - totorojs/totoro: A simple and stable cross-browser testing tool. 简单稳定的跨浏览器测试工具。
GitHub - totorojs/totoro: A simple and stable cross-browser testing tool. 简单稳定的跨浏览器测试工具。
GitHub - duojs/duo: A next-generation package manager for the front-end
GitHub - duojs/duo: A next-generation package manager for the front-end
GitHub - hakimel/reveal.js: The HTML Presentation Framework
GitHub - hakimel/reveal.js: The HTML Presentation Framework
PixiJS | The HTML5 Creation Engine | PixiJS
PixiJS | The HTML5 Creation Engine | PixiJS
GitHub - adonisjs/core: AdonisJS is a TypeScript-first web framework for building web apps and API servers. It comes with support for testing, modern tooling, an ecosystem of official packages, and more.
GitHub - adonisjs/core: AdonisJS is a TypeScript-first web framework for building web apps and API servers. It comes with support for testing, modern tooling, an ecosystem of official packages, and more.
GitHub - os-js/OS.js: OS.js - JavaScript Web Desktop Platform
GitHub - os-js/OS.js: OS.js - JavaScript Web Desktop Platform
GitHub - alpinejs/alpine: A rugged, minimal framework for composing JavaScript behavior in your markup.
GitHub - alpinejs/alpine: A rugged, minimal framework for composing JavaScript behavior in your markup.
Phaser - A fast, fun and free open source HTML5 game framework
Phaser - A fast, fun and free open source HTML5 game framework
GitHub - chaijs/chai: BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
GitHub - chaijs/chai: BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
GitHub - simplegeo/polymaps: Polymaps is a free JavaScript library for making dynamic, interactive maps in modern web browsers.
GitHub - simplegeo/polymaps: Polymaps is a free JavaScript library for making dynamic, interactive maps in modern web browsers.
List.js
List.js
GitHub - pchen66/panolens.js: Javascript panorama viewer based on Three.js
GitHub - pchen66/panolens.js: Javascript panorama viewer based on Three.js
GitHub - Fooidge/PleaseJS: JavaScript Library for creating random pleasing colors and color schemes
GitHub - Fooidge/PleaseJS: JavaScript Library for creating random pleasing colors and color schemes
GitHub - canjs/canjs: Build CRUD apps in fewer lines of code.
GitHub - canjs/canjs: Build CRUD apps in fewer lines of code.
GitHub - blueimp/jQuery-File-Upload: File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads.
GitHub - blueimp/jQuery-File-Upload: File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads.
GitHub - peachananr/onepage-scroll: Create an Apple-like one page scroller website (iPhone 5S website) with One Page Scroll plugin
GitHub - peachananr/onepage-scroll: Create an Apple-like one page scroller website (iPhone 5S website) with One Page Scroll plugin
FoalTS
FoalTS
GitHub - whatsup/whatsup: A frontend framework for chillout-mode development 🥤 JSX components on generators*, fast mobx-like state management and exclusive cssx style system
GitHub - whatsup/whatsup: A frontend framework for chillout-mode development 🥤 JSX components on generators*, fast mobx-like state management and exclusive cssx style system
GitHub - gka/chroma.js: JavaScript library for all kinds of color manipulations
GitHub - gka/chroma.js: JavaScript library for all kinds of color manipulations
Matter.js
Matter.js
GitHub - guillaumepotier/Parsley.js: Validate your forms, frontend, without writing a single line of javascript
GitHub - guillaumepotier/Parsley.js: Validate your forms, frontend, without writing a single line of javascript
GitHub - pegjs/pegjs: PEG.js: Parser generator for JavaScript
GitHub - pegjs/pegjs: PEG.js: Parser generator for JavaScript
GitHub - qTip2/qTip2: qTip2 - Pretty powerful tooltips
GitHub - qTip2/qTip2: qTip2 - Pretty powerful tooltips
GitHub - nightwatchjs/nightwatch: Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
GitHub - nightwatchjs/nightwatch: Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
GitHub - chartjs/Chart.js: Simple HTML5 Charts using the <canvas> tag
GitHub - chartjs/Chart.js: Simple HTML5 Charts using the <canvas> tag
GitHub - ariya/phantomjs: Scriptable Headless Browser
GitHub - ariya/phantomjs: Scriptable Headless Browser
GitHub - keystonejs/keystone: The superpowered headless CMS for Node.js — built with GraphQL and React
GitHub - keystonejs/keystone: The superpowered headless CMS for Node.js — built with GraphQL and React
AnyChart is a lightweight and robust JavaScript charting library
AnyChart is a lightweight and robust JavaScript charting library
JavaScript
More on JavaScript

Programming Tips & Tricks

Code smarter, not harder—insider tips and tricks for developers.

Error Solutions

Turn frustration into progress—fix errors faster than ever.

Shortcuts

The art of speed—shortcuts to supercharge your workflow.
  1. Collections 😎
  2. Frequently Asked Question's 🤯

Tools

available to use.

Made with ❤️

to provide resources in various ares.