splitflap-display

Splitflap display canvas animation


Install
bower install splitflap-display

Documentation

Splitflap-display 0.0.9

Splitflap display canvas based animation.

Alt text

How to use

  1. Download the latest version

    Two ways to do it:

    • Download the dist folder.
    • Install with bower install splitflap-display.
  2. Import the library

    You don't use require.js

    Include splitflap-display.js in your page:

    <script type="text/javascript" src="js/libs/splitflap-display.js"></script>

    You already use require.js

    Edit your require config to load Splitflap module:

    requirejs.config({
    
        paths: {
            'Splitflap': 'js/libs/splitflap-display'
        }
    
    });
  3. In your script, simply require and instantiate Splitflap

    require(['Splitflap'], function (Splitflap) {
    
        var canvas = document.getElementById('viewport');
        var splitflap = new Splitflap(canvas);
        splitflap.set(data);
    
    });

    The display is now ready!

    Set new data

    You just need to pass data with set() (see below for more details):

    splitflap.set(data);

    Edit options

    If you need to edit the default options, you have to require Config:

    require(['Config', 'Splitflap'], function (Config, Splitflap) {
    
        // Edit Config here
        // e.g: Config.animation.speed = 100;
    
    });

    If you already use require.js, you also have to add the path to Config

    requirejs.config({
    
        paths: {
            'Splitflap': 'js/libs/splitflap-display',
            'Config': 'js/libs/splitflap-display'
        }
    
    });

Available options

Name Description Default
displaysNumber Number of rows (int) 3
display.slots Number of slots on a row (int) 20
display.first.top Top margin for the first display (int) 0
display.second.top Top margin for the second display (int) 0
display.third.top Top margin for the third display (int) 0
slot.size.width Width of a slot's part (Number) 65
slot.size.height Height of a slot's part (Number) 46
slot.margin.topBottom Top and bottom margin between the slots (Number) 5
slot.margin.leftRight Left and right margin between the slots (Number) 5
letters Array with all the supported letters (array)
images.path Relative path to the images (String) 'assets/img'
image.suffix.top Suffix for the top pictures (String) '_top.png'
image.suffix.bottom Suffix for the bottom pictures (String) '_bottom.png'
animation.steps Steps for each animation (Int) 6
animation.speed Speed for each animation (Int) 50
animation.delay Delay for the slot's animation start (Int) 50

Supported characters

[a-Z] [A-Z] [0-9] - * . : , ! ?

(note that all the letters are converted to uppercase)

About the data

The input data must be a json, with a payload and id fields.

{
    "payload": [
        {
            "id": 0,
            "messages": ['creating', 'testing', 'maintaining'],
            "duration": 60
        },
        {
            "id": 1,
            "messages": ['collection'],
            "duration": 126
        },
        {
            "id": 2,
            "messages": ['check out'],
            "duration": 60
        }
    ],
    "id": 2
}

In the payload, id reffers to the display's index.

To update only the second display you can then pass:

{
    "payload": [
        {
            "id": 1,
            "messages": ['formatted', '0.9999'],
            "duration": 60
        }
    ],
    "id": 3
}