-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
63 lines (50 loc) · 858 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* Module dependencies.
*/
var classes = require('classes');
var query = require('query');
/**
* Expose `Flipbox`.
*/
module.exports = Flipbox;
/**
* Initialize a new `Flipbox` with `el`.
*
* @param {Element} el
* @param {Element} back
* @api public
*/
function Flipbox(el) {
this.showing = 'front';
this.el = el;
this.classes = classes(el).add('flipbox');
}
/**
* Flip the box.
*
* @api public
*/
Flipbox.prototype.flip = function(){
if (this.classes.has('flipped')) {
this.front();
} else {
this.back();
}
if (this.onflip) this.onflip(this.showing);
};
/**
* Flip to the front face.
*
* @api public
*/
Flipbox.prototype.front = function(){
this.classes.remove('flipped');
};
/**
* Flip to the back face.
*
* @api public
*/
Flipbox.prototype.back = function(){
this.classes.add('flipped');
};