oncoprintjs 5.0.3 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +14746 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.js +14760 -0
- package/dist/index.js.map +1 -0
- package/dist/js/CachedProperty.d.ts +10 -10
- package/dist/js/binarysearch.d.ts +1 -1
- package/dist/js/bucketsort.d.ts +16 -16
- package/dist/js/clustering.d.ts +14 -14
- package/dist/js/extractrgba.d.ts +4 -4
- package/dist/js/haselementsininterval.d.ts +1 -1
- package/dist/js/heatmapcolors.d.ts +5 -4
- package/dist/js/makesvgelement.d.ts +1 -1
- package/dist/js/modelutils.d.ts +7 -7
- package/dist/js/oncoprint.d.ts +168 -170
- package/dist/js/oncoprintheaderview.d.ts +23 -22
- package/dist/js/oncoprintlabelview.d.ts +79 -78
- package/dist/js/oncoprintlegendrenderer.d.ts +32 -31
- package/dist/js/oncoprintminimapview.d.ts +69 -68
- package/dist/js/oncoprintmodel.d.ts +403 -398
- package/dist/js/oncoprintruleset.d.ts +176 -177
- package/dist/js/oncoprintshape.d.ts +67 -67
- package/dist/js/oncoprintshapetosvg.d.ts +2 -2
- package/dist/js/oncoprintshapetovertexes.d.ts +5 -5
- package/dist/js/oncoprinttooltip.d.ts +23 -22
- package/dist/js/oncoprinttrackinfoview.d.ts +40 -39
- package/dist/js/oncoprinttrackoptionsview.d.ts +58 -57
- package/dist/js/oncoprintwebglcellview.d.ts +168 -167
- package/dist/js/oncoprintzoomslider.d.ts +28 -27
- package/dist/js/polyfill.d.ts +4 -4
- package/dist/js/precomputedcomparator.d.ts +13 -13
- package/dist/js/shaders.d.ts +2 -2
- package/dist/js/svgfactory.d.ts +24 -23
- package/dist/js/utils.d.ts +16 -16
- package/dist/js/workers/clustering-worker.d.ts +19 -20
- package/dist/test/gradientCategoricalRuleset.spec.d.ts +1 -1
- package/dist/test/monolith.spec.d.ts +1 -1
- package/jest.config.ts +2 -0
- package/package.json +20 -26
- package/rollup.config.ts +14 -0
- package/rules/geneticrules.ts +344 -305
- package/server.js +11 -0
- package/src/img/menudots.svg +9 -9
- package/src/img/zoomtofit.svg +12 -12
- package/src/index.tsx +13 -0
- package/src/js/CachedProperty.ts +6 -7
- package/src/js/binarysearch.ts +8 -3
- package/src/js/bucketsort.ts +89 -47
- package/src/js/clustering.ts +22 -10
- package/src/js/extractrgba.ts +16 -12
- package/src/js/haselementsininterval.ts +8 -4
- package/src/js/heatmapcolors.ts +515 -515
- package/src/js/main.js +1 -1
- package/src/js/makesvgelement.ts +2 -2
- package/src/js/modelutils.ts +11 -8
- package/src/js/oncoprint.ts +706 -385
- package/src/js/oncoprintheaderview.ts +165 -125
- package/src/js/oncoprintlabelview.ts +388 -170
- package/src/js/oncoprintlegendrenderer.ts +203 -72
- package/src/js/oncoprintminimapview.ts +965 -423
- package/src/js/oncoprintmodel.ts +905 -532
- package/src/js/oncoprintruleset.ts +694 -379
- package/src/js/oncoprintshape.ts +240 -97
- package/src/js/oncoprintshapetosvg.ts +77 -26
- package/src/js/oncoprintshapetovertexes.ts +153 -48
- package/src/js/oncoprinttooltip.ts +58 -27
- package/src/js/oncoprinttrackinfoview.ts +115 -59
- package/src/js/oncoprinttrackoptionsview.ts +354 -187
- package/src/js/oncoprintwebglcellview.ts +951 -415
- package/src/js/oncoprintzoomslider.ts +172 -107
- package/src/js/polyfill.ts +7 -3
- package/src/js/precomputedcomparator.ts +133 -50
- package/src/js/shaders.ts +2 -4
- package/src/js/svgfactory.ts +128 -73
- package/src/js/utils.ts +51 -31
- package/src/js/workers/clustering-worker.ts +50 -42
- package/src/test/gradientCategoricalRuleset.spec.ts +55 -38
- package/src/test/monolith.spec.ts +718 -285
- package/test/generate_data.py +108 -0
- package/test/glyphmap-data.js +1041 -0
- package/test/heatmap-data.js +1027 -0
- package/test/index.html +21 -0
- package/test/oncoprint-glyphmap.js +79 -0
- package/test/oncoprint-heatmap.js +123 -0
- package/tsconfig.json +4 -10
- package/tsconfig.test.json +11 -0
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/oncoprintjs.iml +0 -12
- package/.idea/vcs.xml +0 -6
- package/.idea/workspace.xml +0 -105
- package/dist/.gitkeep +0 -0
- package/dist/js/minimaputils.d.ts +0 -0
- package/dist/oncoprint.bundle.js +0 -44313
- package/jest.config.js +0 -12
- package/src/js/minimaputils.ts +0 -0
- package/typings/custom.d.ts +0 -7
- package/typings/missing.d.ts +0 -7
- package/webpack.config.js +0 -43
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
import {ComputedShapeParams, Rectangle} from
|
|
2
|
-
import {RGBAColor} from
|
|
1
|
+
import { ComputedShapeParams, Rectangle } from './oncoprintshape';
|
|
2
|
+
import { RGBAColor } from './oncoprintruleset';
|
|
3
3
|
|
|
4
4
|
const halfsqrt2 = Math.sqrt(2) / 2;
|
|
5
5
|
|
|
6
|
-
function normalizeRGBA(color:RGBAColor):[number, number, number, number] {
|
|
7
|
-
return [
|
|
8
|
-
color[0],
|
|
9
|
-
color[1],
|
|
10
|
-
color[2],
|
|
11
|
-
color[3]*255
|
|
12
|
-
]
|
|
6
|
+
function normalizeRGBA(color: RGBAColor): [number, number, number, number] {
|
|
7
|
+
return [color[0], color[1], color[2], color[3] * 255];
|
|
13
8
|
}
|
|
14
9
|
|
|
15
|
-
type AddVertexCallback = (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
type AddVertexCallback = (
|
|
11
|
+
vertex: [number, number, number],
|
|
12
|
+
color: [number, number, number, number]
|
|
13
|
+
) => void;
|
|
14
|
+
|
|
15
|
+
function rectangleToVertexes(
|
|
16
|
+
params: ComputedShapeParams,
|
|
17
|
+
z_index: number,
|
|
18
|
+
addVertex: AddVertexCallback
|
|
19
|
+
) {
|
|
20
|
+
const x = params.x,
|
|
21
|
+
y = params.y,
|
|
22
|
+
height = params.height,
|
|
23
|
+
width = params.width;
|
|
19
24
|
|
|
20
25
|
// Fill
|
|
21
26
|
const fill_rgba = normalizeRGBA(params.fill);
|
|
22
|
-
addVertex([x,y,z_index], fill_rgba);
|
|
23
|
-
addVertex([x+width, y, z_index], fill_rgba);
|
|
24
|
-
addVertex([x+width, y+height, z_index], fill_rgba);
|
|
27
|
+
addVertex([x, y, z_index], fill_rgba);
|
|
28
|
+
addVertex([x + width, y, z_index], fill_rgba);
|
|
29
|
+
addVertex([x + width, y + height, z_index], fill_rgba);
|
|
25
30
|
|
|
26
|
-
addVertex([x,y,z_index], fill_rgba);
|
|
27
|
-
addVertex([x+width, y+height, z_index], fill_rgba);
|
|
28
|
-
addVertex([x,y+height,z_index],fill_rgba);
|
|
31
|
+
addVertex([x, y, z_index], fill_rgba);
|
|
32
|
+
addVertex([x + width, y + height, z_index], fill_rgba);
|
|
33
|
+
addVertex([x, y + height, z_index], fill_rgba);
|
|
29
34
|
|
|
30
35
|
// Stroke
|
|
31
36
|
const stroke_width = params['stroke-width'];
|
|
@@ -69,53 +74,124 @@ function rectangleToVertexes(params:ComputedShapeParams, z_index:number, addVert
|
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
76
|
|
|
72
|
-
function triangleToVertexes(
|
|
77
|
+
function triangleToVertexes(
|
|
78
|
+
params: ComputedShapeParams,
|
|
79
|
+
z_index: number,
|
|
80
|
+
addVertex: AddVertexCallback
|
|
81
|
+
) {
|
|
73
82
|
const fill_rgba = normalizeRGBA(params.fill);
|
|
74
83
|
addVertex([params.x1, params.y1, z_index], fill_rgba);
|
|
75
84
|
addVertex([params.x2, params.y2, z_index], fill_rgba);
|
|
76
85
|
addVertex([params.x3, params.y3, z_index], fill_rgba);
|
|
77
86
|
}
|
|
78
87
|
|
|
79
|
-
function ellipseToVertexes(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
function ellipseToVertexes(
|
|
89
|
+
params: ComputedShapeParams,
|
|
90
|
+
z_index: number,
|
|
91
|
+
addVertex: AddVertexCallback
|
|
92
|
+
) {
|
|
93
|
+
const center = {
|
|
94
|
+
x: params.x + params.width / 2,
|
|
95
|
+
y: params.y + params.height / 2,
|
|
96
|
+
};
|
|
97
|
+
const horzrad = params.width / 2;
|
|
98
|
+
const vertrad = params.height / 2;
|
|
83
99
|
|
|
84
100
|
const fill_rgba = normalizeRGBA(params.fill);
|
|
85
101
|
addVertex([center.x, center.y, z_index], fill_rgba);
|
|
86
102
|
addVertex([center.x + horzrad, center.y, z_index], fill_rgba);
|
|
87
|
-
addVertex(
|
|
103
|
+
addVertex(
|
|
104
|
+
[
|
|
105
|
+
center.x + halfsqrt2 * horzrad,
|
|
106
|
+
center.y + halfsqrt2 * vertrad,
|
|
107
|
+
z_index,
|
|
108
|
+
],
|
|
109
|
+
fill_rgba
|
|
110
|
+
);
|
|
88
111
|
|
|
89
112
|
addVertex([center.x, center.y, z_index], fill_rgba);
|
|
90
|
-
addVertex(
|
|
113
|
+
addVertex(
|
|
114
|
+
[
|
|
115
|
+
center.x + halfsqrt2 * horzrad,
|
|
116
|
+
center.y + halfsqrt2 * vertrad,
|
|
117
|
+
z_index,
|
|
118
|
+
],
|
|
119
|
+
fill_rgba
|
|
120
|
+
);
|
|
91
121
|
addVertex([center.x, center.y + vertrad, z_index], fill_rgba);
|
|
92
122
|
|
|
93
123
|
addVertex([center.x, center.y, z_index], fill_rgba);
|
|
94
124
|
addVertex([center.x, center.y + vertrad, z_index], fill_rgba);
|
|
95
|
-
addVertex(
|
|
125
|
+
addVertex(
|
|
126
|
+
[
|
|
127
|
+
center.x - halfsqrt2 * horzrad,
|
|
128
|
+
center.y + halfsqrt2 * vertrad,
|
|
129
|
+
z_index,
|
|
130
|
+
],
|
|
131
|
+
fill_rgba
|
|
132
|
+
);
|
|
96
133
|
|
|
97
134
|
addVertex([center.x, center.y, z_index], fill_rgba);
|
|
98
|
-
addVertex(
|
|
135
|
+
addVertex(
|
|
136
|
+
[
|
|
137
|
+
center.x - halfsqrt2 * horzrad,
|
|
138
|
+
center.y + halfsqrt2 * vertrad,
|
|
139
|
+
z_index,
|
|
140
|
+
],
|
|
141
|
+
fill_rgba
|
|
142
|
+
);
|
|
99
143
|
addVertex([center.x - horzrad, center.y, z_index], fill_rgba);
|
|
100
144
|
|
|
101
145
|
addVertex([center.x, center.y, z_index], fill_rgba);
|
|
102
146
|
addVertex([center.x - horzrad, center.y, z_index], fill_rgba);
|
|
103
|
-
addVertex(
|
|
147
|
+
addVertex(
|
|
148
|
+
[
|
|
149
|
+
center.x - halfsqrt2 * horzrad,
|
|
150
|
+
center.y - halfsqrt2 * vertrad,
|
|
151
|
+
z_index,
|
|
152
|
+
],
|
|
153
|
+
fill_rgba
|
|
154
|
+
);
|
|
104
155
|
|
|
105
156
|
addVertex([center.x, center.y, z_index], fill_rgba);
|
|
106
|
-
addVertex(
|
|
157
|
+
addVertex(
|
|
158
|
+
[
|
|
159
|
+
center.x - halfsqrt2 * horzrad,
|
|
160
|
+
center.y - halfsqrt2 * vertrad,
|
|
161
|
+
z_index,
|
|
162
|
+
],
|
|
163
|
+
fill_rgba
|
|
164
|
+
);
|
|
107
165
|
addVertex([center.x, center.y - vertrad, z_index], fill_rgba);
|
|
108
166
|
|
|
109
167
|
addVertex([center.x, center.y, z_index], fill_rgba);
|
|
110
168
|
addVertex([center.x, center.y - vertrad, z_index], fill_rgba);
|
|
111
|
-
addVertex(
|
|
169
|
+
addVertex(
|
|
170
|
+
[
|
|
171
|
+
center.x + halfsqrt2 * horzrad,
|
|
172
|
+
center.y - halfsqrt2 * vertrad,
|
|
173
|
+
z_index,
|
|
174
|
+
],
|
|
175
|
+
fill_rgba
|
|
176
|
+
);
|
|
112
177
|
|
|
113
178
|
addVertex([center.x, center.y, z_index], fill_rgba);
|
|
114
|
-
addVertex(
|
|
179
|
+
addVertex(
|
|
180
|
+
[
|
|
181
|
+
center.x + halfsqrt2 * horzrad,
|
|
182
|
+
center.y - halfsqrt2 * vertrad,
|
|
183
|
+
z_index,
|
|
184
|
+
],
|
|
185
|
+
fill_rgba
|
|
186
|
+
);
|
|
115
187
|
addVertex([center.x + horzrad, center.y, z_index], fill_rgba);
|
|
116
188
|
}
|
|
117
189
|
|
|
118
|
-
function lineToVertexes(
|
|
190
|
+
function lineToVertexes(
|
|
191
|
+
params: ComputedShapeParams,
|
|
192
|
+
z_index: number,
|
|
193
|
+
addVertex: AddVertexCallback
|
|
194
|
+
) {
|
|
119
195
|
// For simplicity of dealing with webGL we'll implement lines as thin triangle pairs
|
|
120
196
|
let x1 = params.x1;
|
|
121
197
|
let x2 = params.x2;
|
|
@@ -135,11 +211,20 @@ function lineToVertexes(params:ComputedShapeParams, z_index:number, addVertex:Ad
|
|
|
135
211
|
}
|
|
136
212
|
|
|
137
213
|
const perpendicular_vector = [y2 - y1, x1 - x2];
|
|
138
|
-
const perpendicular_vector_length = Math.sqrt(
|
|
139
|
-
|
|
214
|
+
const perpendicular_vector_length = Math.sqrt(
|
|
215
|
+
perpendicular_vector[0] * perpendicular_vector[0] +
|
|
216
|
+
perpendicular_vector[1] * perpendicular_vector[1]
|
|
217
|
+
);
|
|
218
|
+
const unit_perp_vector = [
|
|
219
|
+
perpendicular_vector[0] / perpendicular_vector_length,
|
|
220
|
+
perpendicular_vector[1] / perpendicular_vector_length,
|
|
221
|
+
];
|
|
140
222
|
|
|
141
223
|
const half_stroke_width = params['stroke-width'] / 2;
|
|
142
|
-
const direction1 = [
|
|
224
|
+
const direction1 = [
|
|
225
|
+
unit_perp_vector[0] * half_stroke_width,
|
|
226
|
+
unit_perp_vector[1] * half_stroke_width,
|
|
227
|
+
];
|
|
143
228
|
const direction2 = [direction1[0] * -1, direction1[1] * -1];
|
|
144
229
|
const A = [x1 + direction1[0], y1 + direction1[1]];
|
|
145
230
|
const B = [x1 + direction2[0], y1 + direction2[1]];
|
|
@@ -156,25 +241,45 @@ function lineToVertexes(params:ComputedShapeParams, z_index:number, addVertex:Ad
|
|
|
156
241
|
addVertex([B[0], B[1], z_index], stroke_rgba);
|
|
157
242
|
}
|
|
158
243
|
|
|
159
|
-
export default function(
|
|
244
|
+
export default function(
|
|
245
|
+
oncoprint_shape_computed_params: ComputedShapeParams,
|
|
246
|
+
z_index: number,
|
|
247
|
+
addVertex: AddVertexCallback
|
|
248
|
+
) {
|
|
160
249
|
// target_position_array is an array with 3-d float vertexes
|
|
161
250
|
// target_color_array is an array with rgba values in [0,1]
|
|
162
251
|
// We pass them in to save on concatenation costs
|
|
163
252
|
|
|
164
253
|
const type = oncoprint_shape_computed_params.type;
|
|
165
|
-
if (type ===
|
|
166
|
-
return rectangleToVertexes(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
} else if (type ===
|
|
172
|
-
return
|
|
254
|
+
if (type === 'rectangle') {
|
|
255
|
+
return rectangleToVertexes(
|
|
256
|
+
oncoprint_shape_computed_params,
|
|
257
|
+
z_index,
|
|
258
|
+
addVertex
|
|
259
|
+
);
|
|
260
|
+
} else if (type === 'triangle') {
|
|
261
|
+
return triangleToVertexes(
|
|
262
|
+
oncoprint_shape_computed_params,
|
|
263
|
+
z_index,
|
|
264
|
+
addVertex
|
|
265
|
+
);
|
|
266
|
+
} else if (type === 'ellipse') {
|
|
267
|
+
return ellipseToVertexes(
|
|
268
|
+
oncoprint_shape_computed_params,
|
|
269
|
+
z_index,
|
|
270
|
+
addVertex
|
|
271
|
+
);
|
|
272
|
+
} else if (type === 'line') {
|
|
273
|
+
return lineToVertexes(
|
|
274
|
+
oncoprint_shape_computed_params,
|
|
275
|
+
z_index,
|
|
276
|
+
addVertex
|
|
277
|
+
);
|
|
173
278
|
}
|
|
174
279
|
}
|
|
175
280
|
|
|
176
|
-
export function getNumWebGLVertexes(shape:ComputedShapeParams) {
|
|
177
|
-
let ret:number;
|
|
281
|
+
export function getNumWebGLVertexes(shape: ComputedShapeParams) {
|
|
282
|
+
let ret: number;
|
|
178
283
|
switch (shape.type) {
|
|
179
284
|
case 'rectangle':
|
|
180
285
|
if (shape['stroke-width'] > 0) {
|
|
@@ -194,4 +299,4 @@ export function getNumWebGLVertexes(shape:ComputedShapeParams) {
|
|
|
194
299
|
break;
|
|
195
300
|
}
|
|
196
301
|
return ret;
|
|
197
|
-
}
|
|
302
|
+
}
|
|
@@ -1,22 +1,32 @@
|
|
|
1
|
-
import $ from
|
|
1
|
+
import $ from 'jquery';
|
|
2
2
|
|
|
3
|
-
const TOOLTIP_CLASS =
|
|
3
|
+
const TOOLTIP_CLASS = 'oncoprintjs__tooltip';
|
|
4
4
|
|
|
5
|
-
export type OncoprintTooltipParams = { noselect?:boolean };
|
|
5
|
+
export type OncoprintTooltipParams = { noselect?: boolean };
|
|
6
6
|
|
|
7
7
|
export default class OncoprintToolTip {
|
|
8
|
-
private $div:JQuery;
|
|
9
|
-
private hide_timeout_id:number|undefined;
|
|
10
|
-
private show_timeout_id:number|undefined;
|
|
11
|
-
public center:boolean;
|
|
12
|
-
private shown:boolean;
|
|
8
|
+
private $div: JQuery;
|
|
9
|
+
private hide_timeout_id: number | undefined;
|
|
10
|
+
private show_timeout_id: number | undefined;
|
|
11
|
+
public center: boolean;
|
|
12
|
+
private shown: boolean;
|
|
13
13
|
|
|
14
|
-
constructor(private $container:JQuery, params?:OncoprintTooltipParams) {
|
|
14
|
+
constructor(private $container: JQuery, params?: OncoprintTooltipParams) {
|
|
15
15
|
params = params || {};
|
|
16
16
|
|
|
17
|
-
this.$div = $('<div></div>')
|
|
17
|
+
this.$div = $('<div></div>')
|
|
18
|
+
.addClass(TOOLTIP_CLASS)
|
|
19
|
+
.appendTo($container)
|
|
20
|
+
.css({
|
|
21
|
+
'background-color': 'rgba(255,255,255,1)',
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
display: 'none',
|
|
24
|
+
border: '1px solid black',
|
|
25
|
+
'max-width': 300,
|
|
26
|
+
'min-width': 150,
|
|
27
|
+
});
|
|
18
28
|
if (params.noselect) {
|
|
19
|
-
this.$div.addClass(
|
|
29
|
+
this.$div.addClass('noselect');
|
|
20
30
|
}
|
|
21
31
|
this.hide_timeout_id = undefined;
|
|
22
32
|
this.show_timeout_id = undefined;
|
|
@@ -25,16 +35,22 @@ export default class OncoprintToolTip {
|
|
|
25
35
|
this.shown = false;
|
|
26
36
|
|
|
27
37
|
const self = this;
|
|
28
|
-
this.$div.on(
|
|
38
|
+
this.$div.on('mousemove', function(evt) {
|
|
29
39
|
evt.stopPropagation();
|
|
30
40
|
self.cancelScheduledHide();
|
|
31
41
|
});
|
|
32
|
-
this.$div.on(
|
|
42
|
+
this.$div.on('mouseleave', function(evt) {
|
|
33
43
|
evt.stopPropagation();
|
|
34
44
|
self.hide();
|
|
35
45
|
});
|
|
36
46
|
}
|
|
37
|
-
public show(
|
|
47
|
+
public show(
|
|
48
|
+
wait: number | undefined,
|
|
49
|
+
viewport_x: number,
|
|
50
|
+
viewport_y: number,
|
|
51
|
+
$contents: JQuery,
|
|
52
|
+
fade?: boolean
|
|
53
|
+
) {
|
|
38
54
|
this.cancelScheduledHide();
|
|
39
55
|
|
|
40
56
|
if (typeof wait !== 'undefined' && !this.shown) {
|
|
@@ -42,16 +58,21 @@ export default class OncoprintToolTip {
|
|
|
42
58
|
this.cancelScheduledShow();
|
|
43
59
|
this.show_timeout_id = setTimeout(function() {
|
|
44
60
|
self.doShow(viewport_x, viewport_y, $contents, fade);
|
|
45
|
-
}, wait);
|
|
61
|
+
}, wait) as any;
|
|
46
62
|
} else {
|
|
47
63
|
this.doShow(viewport_x, viewport_y, $contents, fade);
|
|
48
64
|
}
|
|
49
65
|
}
|
|
50
|
-
private doShow(
|
|
66
|
+
private doShow(
|
|
67
|
+
viewport_x: number,
|
|
68
|
+
viewport_y: number,
|
|
69
|
+
$contents: JQuery,
|
|
70
|
+
fade?: boolean
|
|
71
|
+
) {
|
|
51
72
|
this.cancelScheduledShow();
|
|
52
73
|
this.show_timeout_id = undefined;
|
|
53
74
|
this.$div.empty();
|
|
54
|
-
this.$div.css({
|
|
75
|
+
this.$div.css({ top: 0, left: 0, 'z-index': 9999 }); // put up top left so that it doesnt cause any page expansion, before the position calculation which depends on page size
|
|
55
76
|
this.$div.append($contents);
|
|
56
77
|
if (!fade) {
|
|
57
78
|
this.$div.show();
|
|
@@ -59,7 +80,7 @@ export default class OncoprintToolTip {
|
|
|
59
80
|
this.$div.stop().fadeIn('fast');
|
|
60
81
|
}
|
|
61
82
|
// adjust tooltip position based on size of contents
|
|
62
|
-
let x = viewport_x - (this.center ? this.$div.width()/2 : 0);
|
|
83
|
+
let x = viewport_x - (this.center ? this.$div.width() / 2 : 0);
|
|
63
84
|
let y = viewport_y - this.$div.height();
|
|
64
85
|
// clamp to visible area
|
|
65
86
|
const min_padding = 20;
|
|
@@ -68,10 +89,10 @@ export default class OncoprintToolTip {
|
|
|
68
89
|
x = Math.max(x, min_padding); // make sure not too left
|
|
69
90
|
x = Math.min(x, $(window).width() - this.$div.width() - min_padding); // make sure not too right
|
|
70
91
|
|
|
71
|
-
this.$div.css({
|
|
92
|
+
this.$div.css({ top: y, left: x, 'z-index': 9999 });
|
|
72
93
|
this.shown = true;
|
|
73
94
|
}
|
|
74
|
-
private doHide(fade?:boolean) {
|
|
95
|
+
private doHide(fade?: boolean) {
|
|
75
96
|
this.cancelScheduledHide();
|
|
76
97
|
this.hide_timeout_id = undefined;
|
|
77
98
|
if (!fade) {
|
|
@@ -80,7 +101,7 @@ export default class OncoprintToolTip {
|
|
|
80
101
|
this.$div.fadeOut();
|
|
81
102
|
}
|
|
82
103
|
this.shown = false;
|
|
83
|
-
}
|
|
104
|
+
}
|
|
84
105
|
private cancelScheduledShow() {
|
|
85
106
|
clearTimeout(this.show_timeout_id);
|
|
86
107
|
this.show_timeout_id = undefined;
|
|
@@ -89,17 +110,22 @@ export default class OncoprintToolTip {
|
|
|
89
110
|
clearTimeout(this.hide_timeout_id);
|
|
90
111
|
this.hide_timeout_id = undefined;
|
|
91
112
|
}
|
|
92
|
-
public showIfNotAlreadyGoingTo(
|
|
113
|
+
public showIfNotAlreadyGoingTo(
|
|
114
|
+
wait: number | undefined,
|
|
115
|
+
viewport_x: number,
|
|
116
|
+
viewport_y: number,
|
|
117
|
+
$contents: JQuery
|
|
118
|
+
) {
|
|
93
119
|
if (typeof this.show_timeout_id === 'undefined') {
|
|
94
120
|
this.show(wait, viewport_x, viewport_y, $contents);
|
|
95
121
|
}
|
|
96
122
|
}
|
|
97
|
-
public hideIfNotAlreadyGoingTo(wait?:number) {
|
|
123
|
+
public hideIfNotAlreadyGoingTo(wait?: number) {
|
|
98
124
|
if (typeof this.hide_timeout_id === 'undefined') {
|
|
99
125
|
this.hide(wait);
|
|
100
126
|
}
|
|
101
127
|
}
|
|
102
|
-
public hide(wait?:number) {
|
|
128
|
+
public hide(wait?: number) {
|
|
103
129
|
this.cancelScheduledShow();
|
|
104
130
|
|
|
105
131
|
if (!this.shown) {
|
|
@@ -111,12 +137,17 @@ export default class OncoprintToolTip {
|
|
|
111
137
|
this.cancelScheduledHide();
|
|
112
138
|
this.hide_timeout_id = setTimeout(function() {
|
|
113
139
|
self.doHide();
|
|
114
|
-
}, wait);
|
|
140
|
+
}, wait) as any;
|
|
115
141
|
} else {
|
|
116
142
|
this.doHide();
|
|
117
143
|
}
|
|
118
144
|
}
|
|
119
|
-
public fadeIn(
|
|
145
|
+
public fadeIn(
|
|
146
|
+
wait: number | undefined,
|
|
147
|
+
viewport_x: number,
|
|
148
|
+
viewport_y: number,
|
|
149
|
+
$contents: JQuery
|
|
150
|
+
) {
|
|
120
151
|
this.show(wait, viewport_x, viewport_y, $contents, true);
|
|
121
152
|
}
|
|
122
|
-
}
|
|
153
|
+
}
|