• Stars
    star
    137
  • Rank 258,206 (Top 6 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created about 11 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🧊 Visualizes arrays as cube interfaces

HexaFlip

HexaFlip

Transform arrays of any length into cubes with infinite sides.

Featuring touch/mouse interaction, getter/setter methods, zero dependencies, and jQuery support.

Dan Motzenbecker, MIT License

@dcmotz

Take a look at the Codrops article for a guide through the process and some demos.

Basic Usage

Create an instance by passing a DOM element and a key-value set of arrays:

var cubeSet = new HexaFlip(document.getElementById('my-el'),
    {
        prince: ['For You', 'Prince', 'Dirty Mind', 'Controversy', '1999', 'Around the World in a Day'],
        curtis: ['Curtis', 'Roots', 'Super Fly', 'Back to the World', 'Got to Find a Way', 'Sweet Exorcist']
    }
);

// you can also pass a selector string and HexaFlip will take the first matching element:
var firstDiv = new HexaFlip('div');

If a value is a URL, HexaFlip will set that side to the image it points to, preloading it automatically.

You can also pass objects as values with style and value keys for some meticulous customization of different sides. Make the former an object literal of CSS properties to customize the styling of that cube face.

var colorCube = new HexaFlip('#color-cube',
    {
        chromaSet: [
          {
              value: 'orange',
              style: {
                  backgroundColor: '#e67e22',
                  fontWeight: 100
              }
          },
          {
              value: 'teal',
              style: {
                  backgroundColor: '#1abc9c',
                  fontFamily: 'Futura'
              }
          },
          {
              value: 'yellow',
              style: {
                  backgroundColor: '#f1c40f',
                  textDecoration: 'underline'
              }
          }
        ]
    }
);

To enable horizontal rotation (like the photos above), pass it in the options:

var horizontalCube = new HexaFlip('#my-el2',
    {
        letters: ['α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ',
                  'ν', 'ξ', 'ο', 'π', 'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω']
    },
    {
        horizontalFlip: true,
        size: 300
    }
);

To set and get the values of the cubes:

cubeSet.setValue({ prince: '1999', curtis: 'Roots' });
cubeSet.getValue();

To rotate the cubes to the next or previous sides:

cubeSet.flip();
cubeSet.flipBack();

Events

To add custom DOM events, simply pass a key value object called domEvents to the instance's options:

//...
    },
    {
        domEvents: {
            mouseover: function(e, face, cube) {
                face.style.backgroundColor = 'red';
            },
            mouseout: function(e, face, cube) {
                face.style.backgroundColor = 'blue';
            },
            click: function(e, face, cube) {
                console.log(face.innerHTML);
            }
        }
    }
);

Every callback is passed the event object, the face element that triggered the event, and the cube element the face belongs to. The callback is automatically bound to the HexaFlip instance so this works properly.

More Repositories

1

oriDomi

🪭 Fold up DOM elements like paper
CoffeeScript
2,406
star
2

thing-translator

📷 🗣 Point your camera at things to hear how to say them in a different language
JavaScript
1,315
star
3

trystero

🤝 Build instant multiplayer webapps, no server required — Magic WebRTC matchmaking over BitTorrent, Nostr, MQTT, IPFS, and Firebase
JavaScript
810
star
4

natal

📲 Bootstrap ClojureScript React Native apps
CoffeeScript
405
star
5

TuringType

⌨️ Simple human typing effect
CoffeeScript
144
star
6

maskew

▰ Add some diagonal rhythm to your elements
CoffeeScript
117
star
7

jade-html5-boilerplate

HTML5 Boilerplate ported to Jade. Great as a drop and go markup skeleton for Express apps.
Shell
112
star
8

emdash

📚🧙‍♂️ Wisdom indexer — use AI to organize text snippets so you can actually remember & learn from what you read
Elm
110
star
9

natal-shell

A thin ClojureScript wrapper around the React Native API
Clojure
38
star
10

soundscrape

SoundCloud command line downloader in Node.js
CoffeeScript
28
star
11

GildedGauge

💸 An experiment in visualizing relative wealth
Clojure
19
star
12

stream-snitch

👀 Event emitter for watching text streams with regex patterns
JavaScript
19
star
13

commune.js

Web workers lose their chains: Easy threads without separate function files.
CoffeeScript
18
star
14

ear-pipe

Pipe audio streams to your ears
JavaScript
16
star
15

ExifExodus

🕶 Remove GPS data from your photos before you upload them.
CoffeeScript
14
star
16

bashcoin

Bitcoin ticker tape for your terminal
JavaScript
10
star
17

express-spa-router

Express middleware for single page app routing
JavaScript
9
star
18

cellf

👁 Experiment / small game that reflects you and your surroundings
Clojure
9
star
19

statmap

Output recursive directory stats as JSON for visualization and analysis.
JavaScript
8
star
20

taxa

📐 A tiny language inside JavaScript to enforce type signatures.
CoffeeScript
8
star
21

dotfiles

$> (C)onfig (R)ules (E)verything (A)round (M)e
Shell
7
star
22

gimme

Simple command line utility that takes a name and shows domain and twitter availability.
JavaScript
7
star
23

cupboard-calc

🥦 Plan your pantry
Svelte
6
star
24

yearcal

📅 My loose grasp on time
JavaScript
5
star
25

monocat

Automated asset inlining
CoffeeScript
5
star
26

distilla

Distill a derived branch build with no mess. Designed for gh-pages.
JavaScript
4
star
27

oxen

DEPRECATED Create Github pull requests from the command line
JavaScript
4
star
28

ether-tontine

⚰️💰 On-chain mortality lottery
Solidity
3
star
29

holdTheLine

Tiny jQuery HTML5 placeholder polyfill for old browsers.
JavaScript
2
star
30

ptolemy

Serendipitous tome extractions
Haskell
1
star
31

dmotz.github.com

$HOME
JavaScript
1
star
32

tasseographer

Divine auspices from Git log hashes
Clojure
1
star