forked from jabbany/CommentCoreLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCCLComment.js
More file actions
53 lines (47 loc) · 1.2 KB
/
CCLComment.js
File metadata and controls
53 lines (47 loc) · 1.2 KB
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
/** This is the element for the comment **/
function CCLComment(data, motion, parent){
/** Parent designates the comment's type **/
this.render = parent ? "DOM" : "CANVAS";
this.mode = data.mode;
this.parent = parent;
this.data = data;
//Motion is a motion factory or the manager
this.motion = motion;
this.width = -1;
this.height = -1;
this.x = 0;
this.y = 0;
}
CCLComment.prototype.set = function(styleParam, value){
switch(styleParam){
case "top":
case "left":
case "right":
case "bottom":{
this.parent.style[styleParam] = value ? (value + "px") : "";
}break;
}
}
CCLComment.prototype.getTTL = function(){
return this.motion ? this.motion.ttl : this.data.dur;
}
CCLComment.prototype.getBounds = function(){
this.width = this.parent.offsetWidth;
this.height = this.parent.offsetHeight;
this.x = this.parent.offsetLeft;
this.y = this.parent.offsetTop;
this.top = this.y;
this.bottom = this.y + this.height;
this.left = this.x;
this.right = this.x + this.width;
};
CCLComment.prototype.setMotion = function(m){
this.motion = m;
}
CCLComment.prototype.destroy = function(){
//Destroys references to aid gc?
delete this.parent;
delete this.motion;
this.render = "NONE";
this.type = -1;
}