forked from jabbany/CommentCoreLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoreComment.js
More file actions
46 lines (40 loc) · 1.12 KB
/
CoreComment.js
File metadata and controls
46 lines (40 loc) · 1.12 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
/** This is the element for a comment **/
function CoreComment(data, motion, parent){
/** Parent designates the comment's type, if supplied = a dom comment **/
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;
// Initialize the cached object
this.getBounds();
}
CoreComment.prototype.set = function(styleParam, value){
switch(styleParam){
case "top":
case "left":
case "right":
case "bottom":{
this.parent.style[styleParam] = value ? (value + "px") : "";
}break;
}
}
CoreComment.prototype.getTTL = function(){
return this.motion ? this.motion.ttl : this.data.dur;
}
CoreComment.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;
};
CoreComment.prototype.estimateBounds = function(){
};
CoreComment.prototype.setMotion = function(m){
this.motion = m;
};