A jQuery number display

Overview

For a React version see react-split-flap-effect

Flapper

Project Homepage Live Demo

A jQuery number display

Flapper is a jQuery plugin that replicates the split-flap (or "Solari") displays that used to be common in train stations and airports, and your dad's alarm clock in the 70s.

To use, just attach Flapper to any input on your page. Whenever the input's change event is fired, Flapper will update the display.

<script type="text/javascript"> $('#display').flapper().val('1234').change(); </script>

For best results, you should load jquery.transform and jquery.numberformatter.

Options

Flapper accepts a hash of options:

var options = {
  width: 6,             // number of digits
  format: null,         // options for jquery.numberformatter, if loaded
  align: 'right',       // aligns values to the left or right of display
  padding: '&nbsp;',    // value to use for padding
  chars: null,          // array of characters that Flapper can display
  chars_preset: 'num',  // 'num', 'hexnum', 'alpha' or 'alphanum'
  timing: 250,          // the maximum timing for digit animation
  min_timing: 10,       // the minimum timing for digit animation
  threshhold: 100,      // the point at which Flapper will switch from
                        // simple to detailed animations
  transform: true       // Flapper automatically detects the jquery.transform
                        // plugin. Set this to false if you want to force
                        // transform to off
  on_anim_start: null   // Callback for start of animation
  on_anim_end: null     // Callback for end of animation
}

Generally, the only options you will care about are width and chars_preset. If you want to use a custom set of characters, specify chars instead of chars_preset. Flapper will use the first character in your array as the default glyph, so you'll usually want this to be either &nbsp; or 0.

Character presets are:

  • num: &nbsp;, 1-9, 0, dollar sign, decimal point, comma, colon
  • hexnum: &nbsp;, 1-9, A-F, 0
  • alpha: &nbsp;, A-Z
  • alphanum: All of alpha and num

The timing params timing, min_timing and threshhold control how fast the glyphs flash by as the display changes. You can set timing to a higher number if you'd like a slower, more obvious transform effect. You can set min_timing higher if you'd like the glyphs to flash by more slowly. You generally don't need to set threshhold.

If you'd like to add commas to numbers, use money symbols, control the number of decimal points, and other fun things, you can load jquery.numberformatter and pass its options in format. You can also set padding to 0 if you'd like to zero-pad numbers, and you're not using jquery.numberformatter.

Theming

You can control Flapper's built-in themes by adding classes to your inputs.

The classes XS, S, M, L, XL and XXL choose Flapper's six size presets. The default is M.

The classes light and dark choose Flapper's two color themes. The default is dark.

If you'd like to change Flapper's look, you can define your own theme in CSS. Just give your inputs a class mytheme and define two extra CSS selectors. Each Flapper digit consists of an outer div with four inner divs. The inner divs are positioned in two layers, a back layer with upper and lower halves, and a front layer with upper and lower halves.

Define .flapper.mytheme .digit to change the outer divs. In the default themes, this controls the border color and the stripe running horizontally through each digit (the background of this div shows through the space between the inner divs.)

Define .flapper.light .digit div to change the inner divs. In the default themes, this controls the background color of the digits.

The different size presets have font sizes and line heights that are specific to the font I've chosen as the default (Roboto Condensed.) If you're using your own font, you'll need to set your own metrics for the size(s). So, for example:

Define .flapper.mytheme to change the font that Flapper uses.

Define .flapper.mytheme.S to set font-size and line-height so that your digits are nicely centered in Flapper's display (in this case, for the small size.)

To change the border radius of Flapper's digits, change .flapper.mytheme.S .digit and .flapper.mytheme.S .digit div.

Flapper's size presets work like this:

.flapper.S sets the height of each digit.

.flapper.S .digit div sets the height (again!) and width of each digit.

.flapper.S .digit div.top clips the top half of each digit.

.flapper.S .digit div.bottom clips the bottom half of each digit, minus one pixel at the top (the horizontal stripe.)

Defining new sizes is a little tricky, but if you look a the src code you'll get the hang of it.

Comments
  • IE8 Compatibility [Solved with workaround]

    IE8 Compatibility [Solved with workaround]

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf

    adding the compatibility code at the beginning of jquery.flapper.js and deactivating transformations will make the code work also in IE8

    opened by elettronelibero 4
  • Performance issues in Chrome and Edge, no issues in Firefox

    Performance issues in Chrome and Edge, no issues in Firefox

    Hello.

    We are using flapper to implement a departures / arrival traffic board in our virtual airline.

    I've noticed there are performance issues when using Chrome or Edge compared to Firefox. Flapper seems to be at least 10 times faster in Firefox than Chrome/Edge and it gets worse as displayed data gets increased.

    You can see the implementation at https://www.oav.gr/who-is-online

    opened by NickPapa01 2
  • border-box-sizing issues

    border-box-sizing issues

    box-sizing set to border-box breaks the display -

    • { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }

    See - http://jsfiddle.net/dXL3G/

    opened by gnatih 2
  • Numbers change direction

    Numbers change direction

    I use flapper for change number of users online. When it rising it's ok, but when it decreasing, for example from 2 to 1 flapper starts change from 9 to 1. Is it possible to change direction of flapping?

    opened by akudryav 1
  • Add in methods for adding and removing flapper digits on the fly

    Add in methods for adding and removing flapper digits on the fly

    @jayKayEss - I found myself needing to add/remove digits to the flapper on the fly. So I've modified the original code to allow for adding/removing digits.

    Notable Changes:

    • existing flappers are stored in a flappers object
    • ids are added to flapper elements (so that the existing flapper object can be recovered).
    • the .flapper() jQuery method now supports passing in a string or an object. (so that the specified action will be performed)
    • the following methods were added to the prototype: addDigit, removeDigit, performAction

    Let me know what you think!

    opened by jeremysawesome 1
  • Remove Trailing Commas in object literals to fix parse error.

    Remove Trailing Commas in object literals to fix parse error.

    IE8 (and below) will parse trailing commas in array and object literals incorrectly. So I've removed the trailing commas from these object literals.

    /cc @jayKayEss

    opened by jeremysawesome 1
  • Really needs to be updated.

    Really needs to be updated.

    I've tried to use this for a university project, but I couldn't. I'm presuming it's incompatible with the latest versions of jQuery because it's so old. Please consider updating it.

    EDIT: It turns out I'd only misunderstood how to use it. I'm sorry!

    opened by Arcrammer 1
  • Bower package

    Bower package

    This is my attempt at creating a bower package for Flapper.

    Disclaimer: I've never created a bower package before.

    I believe that after this pull request is merged, someone needs to run bower register flapper git://github.com/jayKayEss/Flapper.git to register the package in the bower repository.

    opened by ammojamo 1
  • Click a button to show word out of arrary

    Click a button to show word out of arrary

    Hi,

    I want to use this script to show random words that users can submit (moderated by our staff).

    I want to put the user generated words in an array, then a user can click a button which would generate a new word from said array.

    I was wondering how to go about this.

    opened by JordanSayner 1
  • Reserved word char error

    Reserved word char error

    Attempting to minify with Google Closure Compiler results in an error due to using char as a variable name in the goToChar function.

    JSC_PARSE_ERROR: Parse error. identifier is a reserved word

    further reading http://stackoverflow.com/questions/10046439/what-is-the-char-keyword-used-for

    opened by alexrogers 1
  • Assigning multiple values, or an array to the flapper

    Assigning multiple values, or an array to the flapper

    I have the code below which has 2 fields, a year with 4 characters and a position with 2 characters. It's working so far and currently 'flaps' to show 2014 02 then clears the letters and then re-flaps to show 2014 02.

    How would you go about assigning multiple values to this script so I could 'flap' from 2014 02 to 2013 01 to 2012 04 etc...

    var $demos = $('#animation_demo input'); setTimeout(function(){ $year.val('2014').change();
    $position.val('02').change(); var toggle = true;
    setInterval(function(){
    if (toggle) { $year.val('2014').change(); $position.val('02').change(); } else { $year.val('').change(); $position.val('').change(); }
    toggle = !toggle; }, 3000);

                }, 1000);
    
    opened by jantsdesign 0
Releases(v1.1.6)
  • v1.1.6(May 10, 2021)

  • 1.1.4(Mar 11, 2021)

    • Update bower package name
    • Remove Trailing Commas in object literals to fix parse error.
    • Add in methods for adding and removing flapper digits on the fly
    • Changed font url protocol to use https
    • Various changes to demo page
    Source code(tar.gz)
    Source code(zip)
  • 1.1.3(Feb 13, 2014)

Owner
Justin Kerr Sheckler
Justin Kerr Sheckler
Multiplies a number by zero. Useful for when you need to multiply a number by zero

multiply-by-zero Multiplies a number by zero. Useful for when you need to multiply a number by zero Please consider checking out the links of this pro

Dheirya Tyagi 2 Jul 3, 2022
this is a single-page web application. we built a book website where the user can add , remove and display books. we used modules to implement these functionalities. also, we used the Date class to display the date and time.

Awsome Books In this Project, we have built A Books websites. Built With ?? HTML CSS javascript Git & Github Live Demo Here you can find the live Demo

Nedjwa Bouraiou 10 Aug 3, 2022
A public board for all the Computer Society and Students to display their profile. An online year-book for you to display your profile in the most creative manner

Student's Yearbook by IEEE Computer Society Student's yearbook is an open-source project which intends to dispaly the students who will be graduating

IEEE Computer Society 11 Dec 18, 2022
jquery plugin to convert number inputs into knobs that can be adjusted by dragging with mouse or fingers

jquery-knobby is a jquery plugin to convert number input elements into turnable knobs that can be adjusted by cyclic dragging with mouse or fingers -

null 4 Oct 2, 2020
Plain JavaScript version of jQuery's slideToggle(), slideDown(), & slideUp(), but does not use display: none.

dom-slider It works like jQuery's slideToggle(), slideDown(), & slideUp(), but does not use display: none. Uses CSS3 transitions and element.scrollHei

Brenton Cozby 56 Dec 27, 2022
Display an image in a responsive imagebox without jQuery.

Documentation ImageBox latest version 1.3.0 Include this files: <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/tobiasroeder/[email protected]/d

Tobias Röder 5 Aug 31, 2021
Displaying actual age in percentage with 9 signs after dot (floating number)

Actual Age Chrome Extension Displaying actual age in percentage with 9 signs after dot (floating number) Features Popup You can select your Birth date

Igor Makeenko 22 Nov 2, 2022
A very simple tool that generates multiple spellings of a phone number (to effectively search for it using the OR operator and quotes)

phonenumberqueryconstructor A very simple tool that generates multiple writings of a phone number (to effectively search for it using the OR operator

Cyb_detective 10 Dec 7, 2022
🎡 Generate a random number, a list of them, or a generator with optional configuration

random_number Generate a random number, a list of them, or a generator with optional configuration Usage import randomNumber from "https://deno.land/x

Eliaz Bobadilla 7 Aug 7, 2022
Calculating Pi number without limitation until 10k digits or more in your browser powered by JS without any third party library!

PI Calculator Web JS (Online) Calculating Pi number without limitation until 10k digits or more in your browser powered by JS without any third party

Max Base 6 Jul 27, 2022
A website for detecting name of bank from card number, supported all Iranian banks

Detect Iranian Bank Web A website for detecting name of bank from card number, supported all Iranian banks. This package contains SVG logo and brand c

Max Base 12 Oct 2, 2022
🚀 Transition number values using easing functions

react-transition-value Transition / Animate number values using easing functions See Demos ⚡️ Getting started npm i react-transition-value import {

Björn 46 Dec 15, 2022
In Your Face shows you Doom 'Ouch Faces' that correlate to the number of errors in your code!

In Your Face Watch how I made this extension on YouTube here In Your Face is a VS Code extension that shows you Doom 'Ouch Faces' that correlate to th

Virej Dasani 125 Dec 25, 2022
🧩 TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types such as number or boolean (not Value Objects)

?? TypeScript Primitives type TypeScript utility type in order to ensure to return only properties (not methods) containing values in primitive types

CodelyTV 82 Dec 7, 2022
An online library for adding and removing a different number of books from a user collection, keeping track of the books you've read and the one's you are yet to read

Awesmoe Books A Website demo for our project of book store, The website has ability of adding and removing you books from yor library, Thats reflects

zieeco 11 Jul 8, 2022
Tasty is a website that displays a number of recipes and allows users to leave likes and comments on their favourite meals.

Tasty Tasty is a website that displays a number of recipes and allows users to leave likes and comments on their favourite meals. Requirements Build a

Manel Hammouche 5 Aug 3, 2022
Verify your E-Mail and Phone Number using link sent over mail and sms.

Phone-and-Mail-Verification-With-Link Verify your E-Mail and Phone Number using link sent over mail and sms. Endpoints POST /user/create Body { "n

Prasoon Soni 5 Sep 14, 2022
A minimal seeded random number generator.

gnrng A minimal seeded random number generator that generates numbers between -1 and 1. Adapted from the more full-featured seedrandom (and using xors

Steve Ruiz 11 Nov 23, 2022
sum-safe rounding for number arrays

saferound About saferound is a simplified typescript adaption of the python library Iteround, a sum-safe rounding library. The library solves the prob

Jonas Strassel 6 Oct 31, 2022