-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintervalEdge.js
64 lines (56 loc) · 1.59 KB
/
intervalEdge.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
64
class IntervalEdge {
constructor(type, position, interval) {
this.type = type;
this.position = position;
this.interval = interval;
}
static compare(a, b) {
if (a.position - b.position >= Number.EPSILON) return 1;
if (Math.abs(a.position - b.position) < Number.EPSILON) {
if (a.type === 'start' && b.type === 'end') return -1; // start je manji od kraja, prvo obradjujemo start
if (a.type === 'end' && b.type === 'start') return 1; // kraj je veci od pocetka
//oba starta ili oba enda
if (a.type === 'start') {
//oba start i jednaki su
var x_deviation = a.interval.getParent().getTopx() - b.interval.getParent().getTopx();
var x_deviation_end = a.interval.getParent().getBottomx() - b.interval.getParent().getBottomx();
var pomres1 = 1;
var pomres0 = -1;
if (a.interval.getProjection() === 'left')
{
pomres1 = -1;
pomres0 = 1;
}
if (Math.abs(x_deviation) < Number.EPSILON){
//pocetci su jednaki, uporedi krajeve
if (x_deviation_end < 0){
return pomres0;
} else {
return pomres1;
}
} else {
if (x_deviation < 0){
return pomres0;
} else {
return pomres1;
}
}
}
//oba enda
return IntervalEdge.compare(a.interval.getStart(), b.interval.getStart()) * (-1);
}
return -1;
}
getPosition() {
return this.position;
}
setPosition(position) {
this.position = position;
}
getType() {
return this.type;
}
getInterval() {
return this.interval;
}
}