-
Notifications
You must be signed in to change notification settings - Fork 14
/
property.js
51 lines (41 loc) · 966 Bytes
/
property.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
//a "Property" maintains a set of tweenable values
//for e.g.:
// position [x, y]
// color [r, g, b, a]
// alpha [a]
//It will also store application-level flags like
//whether or not your data is hidden, or what type
//of property you might be dealing with
var keyframes = require('keyframes')
var xtend = require('xtend')
function Property(data) {
if (!(this instanceof Property))
return new Property(data)
this.keyframes = keyframes()
this.value = null
this.name = ''
if (data)
this.load(data)
}
Property.prototype.dispose = function() {
this.keyframes.clear()
}
Property.prototype.export = function() {
return xtend(this, {
keyframes: this.keyframes.frames
})
}
Property.prototype.load = function(data) {
this.dispose()
if (!data)
return
for (var k in data) {
if (!data.hasOwnProperty(k))
continue
if (k === 'keyframes')
this.keyframes.frames = data.keyframes
else
this[k] = data[k]
}
}
module.exports = Property