All Projects → camwiegert → Baffle

camwiegert / Baffle

Licence: mit
A tiny javascript library for obfuscating and revealing text in DOM elements. 😲

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Baffle

React Spectrum
Generate colorful text placeholders 🎨
Stars: ✭ 289 (-83.21%)
Mutual labels:  library, text
Spannabletextview
SpannableTextView is a custom TextView which lets you customize the styling of slice of your text or statment via Spannables, but without the hassle of having to deal directly with Spannable themselves.
Stars: ✭ 177 (-89.72%)
Mutual labels:  library, text
Finalcut
A text-based widget toolkit
Stars: ✭ 244 (-85.82%)
Mutual labels:  library, text
Csconsoleformat
.NET C# library for advanced formatting of console output [Apache]
Stars: ✭ 296 (-82.8%)
Mutual labels:  library, text
Text Minimap
Generate text minimap/preview using Braille Patterns
Stars: ✭ 21 (-98.78%)
Mutual labels:  library, text
Completely
Java autocomplete library.
Stars: ✭ 90 (-94.77%)
Mutual labels:  library, text
Art
🎨 ASCII art library for Python
Stars: ✭ 1,026 (-40.38%)
Mutual labels:  library, text
Dynamic Toasts
Custom toasts with color and icon for Android.
Stars: ✭ 132 (-92.33%)
Mutual labels:  library, text
Amqp
AMQP 1.0 client library for Go.
Stars: ✭ 135 (-92.16%)
Mutual labels:  library
Org Java
Org mode files Java parser
Stars: ✭ 138 (-91.98%)
Mutual labels:  library
Animated Tab Bar
RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion
Stars: ✭ 10,904 (+533.59%)
Mutual labels:  library
Borealis
Hardware accelerated, controller and TV oriented UI library for PC and Nintendo Switch (libnx).
Stars: ✭ 135 (-92.16%)
Mutual labels:  library
Zmi Nerd
😃 Simple transform tool
Stars: ✭ 139 (-91.92%)
Mutual labels:  library
Gsm v5
gsm module library for STM32 LL
Stars: ✭ 135 (-92.16%)
Mutual labels:  library
Pipedrive
Complete Pipedrive API client for PHP
Stars: ✭ 138 (-91.98%)
Mutual labels:  library
Easydeviceinfo
📱 [Android Library] Get device information in a super easy way.
Stars: ✭ 1,698 (-1.34%)
Mutual labels:  library
Simplecli
Command Line Interface Library for Arduino
Stars: ✭ 135 (-92.16%)
Mutual labels:  library
Lc kicad lib
kicad production symbol and footprint library auto convert from JLC's integrate Altium Designer library
Stars: ✭ 140 (-91.87%)
Mutual labels:  library
Hledger
A reliable, user-friendly Plain Text Accounting tool with command line, terminal and web interfaces.
Stars: ✭ 1,887 (+9.65%)
Mutual labels:  library
Wabbit
Golang AMQP mocking library
Stars: ✭ 137 (-92.04%)
Mutual labels:  library

baffle.js

A tiny javascript library for obfuscating and revealing text in DOM elements.

camwiegert.github.io/baffle

baffle.js
  • ~1.8kb gzipped
  • Dependency-free 🎉
  • IE9+ ✔️
// Select elements and start.
const b = baffle('.someSelector').start();

// Do something else.
someAsyncFunction(result => {
    // Change the text and reveal over 1500ms.
    b.text(text => result.text).reveal(1500);
});

Getting Started

Step 0: Install

Download the latest release or install with npm.

npm install --save baffle

Step 1: Reference

If you linked baffle directly in your HTML, you can use window.baffle. If you're using a module bundler, you'll need to import baffle.

// CommonJS
const baffle = require('baffle');

// ES6
import baffle from 'baffle';

Step 2: Initialize

To initialize baffle, all you need to do is call it with some elements. You can pass a NodeList, Node, or CSS selector.

// With a selector.
const b = baffle('.baffle');

// With a NodeList
const b = baffle(document.querySelectorAll('.baffle'));

// With a Node
const b = baffle(document.querySelector('.baffle'));

Step 3: Use It

Once you have a baffle instance, you have access to all of the baffle methods. Usually, you'll want to b.start() and, eventually, b.reveal().

// Start obfuscating...
b.start();

// Or stop obfuscating...
b.stop();

// Obfuscate once...
b.once();

// You can set options after initializing...
b.set({...options});

// Or change the text at any time...
b.text(text => 'Hi Mom!');

// Eventually, you'll want to reveal your text...
b.reveal(1000);

// And they're all chainable...
b.start()
    .set({ speed: 100 })
    .text(text => 'Hi dad!')
    .reveal(1000);

Options

You can set options on baffle during initialization or anytime afterward with baffle.set().

// During initialize
baffle('.baffle', {
    characters: '+#-•=~*',
    speed: 75
});

// Any time with set()
b.set({
    characters: '¯\_(ツ)_/¯',
    speed: 25
});

options.characters

The characters baffle uses to obfuscate your text. It can be a string or an array of characters.

Default: 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz~!@#$%^&*()-+=[]{}|;:,./<>?'

options.exclude

These are the characters that baffle ignores in your text when obfuscating it. You can pass in an array of characters.

Default: [' ']

options.speed

This is the frequency (in milliseconds) at which baffle updates your text when running.

Default: 50

Methods

An instance of baffle has six methods, all of which are chainable.

baffle.once()

Obfuscates each element once, using options.characters.

baffle.start()

Starts obfuscating your elements, updating every options.speed milliseconds.

baffle.stop()

Stops obfuscating your elements. This won't reveal your text. It will only stop updating it. To reveal it, use reveal().

baffle.reveal([duration], [delay])

Reveals your text over duration milliseconds (default: 0), with the option to delay by delay milliseconds.

baffle.set([options])

Updates instance options using the passed options object. You can set any number of keys, even while running.

baffle.text(fn)

Updates the text in each element of your instance using function fn, which receives the current text as it's only parameter. The value returned from fn will be used as the new text.


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].