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
|
// Moveable item
enyo.kind({
name: "Abcd.Item",
kind: enyo.Control,
published: { x: -1, y: -1, z: -1 },
// Constructor
create: function() {
this.inherited(arguments);
this.xChanged();
this.yChanged();
this.zChanged();
},
// Localization changed, update
setLocale: function() {
this.render();
},
// Coordinate setup
xChanged: function() {
if (this.x != -1) this.applyStyle("margin-left", this.x+"px");
},
// Coordinate setup
yChanged: function() {
if (this.y != -1) this.applyStyle("margin-top", this.y+"px");
},
// Coordinate setup
zChanged: function() {
if (this.z != -1) this.applyStyle("z-index", this.z);
},
// Change position
moveTo: function(x, y) {
this.x = x;
this.xChanged();
this.y = y;
this.yChanged();
}
});
|