@checksub_team/peaks_timeline 1.5.7 → 1.5.8
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/package.json +1 -1
- package/peaks.js +61 -31
- package/src/line-indicator.js +66 -32
- package/src/main.js +29 -3
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -14296,8 +14296,16 @@ module.exports = function (Konva, Utils, SVGs) {
|
|
|
14296
14296
|
this._container = container;
|
|
14297
14297
|
this._width = this._peaks.options.lineIndicatorWidth;
|
|
14298
14298
|
this._height = this._view.getHeight();
|
|
14299
|
-
this.
|
|
14300
|
-
|
|
14299
|
+
this._sizes = {
|
|
14300
|
+
font: this._peaks.options.lineIndicatorFontSize,
|
|
14301
|
+
icon: {
|
|
14302
|
+
default: this._peaks.options.lineIndicatorDefaultIconSize,
|
|
14303
|
+
volume: this._peaks.options.lineIndicatorVolumeIconSize,
|
|
14304
|
+
noVolume: this._peaks.options.lineIndicatorNoVolumeIconSize,
|
|
14305
|
+
visibility: this._peaks.options.lineIndicatorVisibilityIconSize,
|
|
14306
|
+
noVisibility: this._peaks.options.lineIndicatorNoVisibilityIconSize
|
|
14307
|
+
}
|
|
14308
|
+
};
|
|
14301
14309
|
this._defaultPadding = 5;
|
|
14302
14310
|
this._types = ['default'].concat(Object.keys(SVGs));
|
|
14303
14311
|
this._stage = new Konva.Stage({
|
|
@@ -14325,6 +14333,7 @@ module.exports = function (Konva, Utils, SVGs) {
|
|
|
14325
14333
|
this._createContextMenu();
|
|
14326
14334
|
}
|
|
14327
14335
|
this._peaks.on('lineIndicator.setType', this._onSetType.bind(this));
|
|
14336
|
+
this._peaks.on('lineIndicator.setText', this._onSetText.bind(this));
|
|
14328
14337
|
}
|
|
14329
14338
|
LineIndicator.prototype.fitToView = function () {
|
|
14330
14339
|
this._height = this._view.getHeight();
|
|
@@ -14339,55 +14348,71 @@ module.exports = function (Konva, Utils, SVGs) {
|
|
|
14339
14348
|
LineIndicator.prototype._onSetType = function (lineId, type) {
|
|
14340
14349
|
this.removeIndicator(lineId, true);
|
|
14341
14350
|
type = this._types.includes(type) ? type : 'default';
|
|
14342
|
-
var indicator = this._createIndicator(this._indicators[lineId].line, type);
|
|
14351
|
+
var indicator = this._createIndicator(this._indicators[lineId].line, type, this._indicators[lineId].text);
|
|
14343
14352
|
this._layer.add(indicator);
|
|
14344
14353
|
this._indicators[lineId].indicator = indicator;
|
|
14345
14354
|
this._indicators[lineId].type = type;
|
|
14346
14355
|
this.draw();
|
|
14347
14356
|
};
|
|
14357
|
+
LineIndicator.prototype._onSetText = function (lineId, text) {
|
|
14358
|
+
this.removeIndicator(lineId, true);
|
|
14359
|
+
var indicator = this._createIndicator(this._indicators[lineId].line, this._indicators[lineId].type, text);
|
|
14360
|
+
this._layer.add(indicator);
|
|
14361
|
+
this._indicators[lineId].indicator = indicator;
|
|
14362
|
+
this._indicators[lineId].text = text;
|
|
14363
|
+
this.draw();
|
|
14364
|
+
};
|
|
14348
14365
|
LineIndicator.prototype._showMenu = function (menu) {
|
|
14349
14366
|
menu.style.display = 'block';
|
|
14350
14367
|
var containerRect = this._stage.container().getBoundingClientRect();
|
|
14351
14368
|
menu.style.top = containerRect.top + this._stage.getPointerPosition().y - menu.offsetHeight + 'px';
|
|
14352
14369
|
menu.style.left = containerRect.left + this._stage.getPointerPosition().x + 6 + 'px';
|
|
14353
14370
|
};
|
|
14354
|
-
LineIndicator.prototype._createIndicator = function (line, type) {
|
|
14371
|
+
LineIndicator.prototype._createIndicator = function (line, type, text) {
|
|
14355
14372
|
var indicator = new Konva.Group();
|
|
14356
|
-
var
|
|
14357
|
-
|
|
14358
|
-
|
|
14359
|
-
|
|
14360
|
-
|
|
14361
|
-
|
|
14362
|
-
|
|
14363
|
-
|
|
14373
|
+
var indicatorHeight = 0;
|
|
14374
|
+
if (text) {
|
|
14375
|
+
var textNode = new Konva.Text({
|
|
14376
|
+
text: text,
|
|
14377
|
+
fontSize: this._sizes.font,
|
|
14378
|
+
fontFamily: 'Arial',
|
|
14379
|
+
fill: this._peaks.options.lineIndicatorColor,
|
|
14380
|
+
align: 'center',
|
|
14381
|
+
width: this._width
|
|
14382
|
+
});
|
|
14383
|
+
indicator.add(textNode);
|
|
14384
|
+
indicatorHeight += this._sizes.font;
|
|
14385
|
+
}
|
|
14364
14386
|
type = this._types.includes(type) ? type : 'default';
|
|
14365
|
-
var
|
|
14387
|
+
var iconNode;
|
|
14366
14388
|
if (type === 'default') {
|
|
14367
|
-
|
|
14389
|
+
var padding = text ? this._defaultPadding : 0;
|
|
14390
|
+
iconNode = new Konva.Circle({
|
|
14368
14391
|
x: this._width / 2,
|
|
14369
|
-
y:
|
|
14370
|
-
radius: this.
|
|
14392
|
+
y: indicatorHeight + this._sizes.icon.default / 2 + padding,
|
|
14393
|
+
radius: this._sizes.icon.default / 2,
|
|
14371
14394
|
fill: this._peaks.options.lineIndicatorColor,
|
|
14372
14395
|
strokeWidth: 0,
|
|
14373
14396
|
lineId: line.getId()
|
|
14374
14397
|
});
|
|
14398
|
+
indicatorHeight += padding;
|
|
14375
14399
|
} else {
|
|
14376
|
-
|
|
14377
|
-
x: (this._width - this.
|
|
14378
|
-
y:
|
|
14400
|
+
iconNode = new Konva.Path({
|
|
14401
|
+
x: (this._width - this._sizes.icon[type]) / 2,
|
|
14402
|
+
y: indicatorHeight,
|
|
14379
14403
|
data: SVGs[type].path,
|
|
14380
14404
|
fill: this._peaks.options.lineIndicatorColor,
|
|
14381
14405
|
scale: {
|
|
14382
|
-
x: this.
|
|
14383
|
-
y: this.
|
|
14406
|
+
x: this._sizes.icon[type] / SVGs[type].width,
|
|
14407
|
+
y: this._sizes.icon[type] / SVGs[type].height
|
|
14384
14408
|
},
|
|
14385
14409
|
lineId: line.getId()
|
|
14386
14410
|
});
|
|
14387
14411
|
}
|
|
14388
|
-
indicator.add(
|
|
14389
|
-
|
|
14390
|
-
indicator.
|
|
14412
|
+
indicator.add(iconNode);
|
|
14413
|
+
indicatorHeight += this._sizes.icon[type];
|
|
14414
|
+
indicator.setAttr('trueHeight', indicatorHeight);
|
|
14415
|
+
indicator.y(line.getY() + (line.lineHeight() - indicatorHeight) / 2);
|
|
14391
14416
|
var self = this;
|
|
14392
14417
|
indicator.on('mouseover', function () {
|
|
14393
14418
|
indicator.getChildren().forEach(function (child) {
|
|
@@ -14434,10 +14459,10 @@ module.exports = function (Konva, Utils, SVGs) {
|
|
|
14434
14459
|
var y = this._indicators[lineId].line.getY() + this._indicators[lineId].line.lineHeight() / 2;
|
|
14435
14460
|
if (y + this._indicators[lineId].line.lineHeight() > 0 && y < this._height) {
|
|
14436
14461
|
if (!this._indicators[lineId].indicator) {
|
|
14437
|
-
this._indicators[lineId].indicator = this._createIndicator(this._indicators[lineId].line, this._indicators[lineId].type);
|
|
14462
|
+
this._indicators[lineId].indicator = this._createIndicator(this._indicators[lineId].line, this._indicators[lineId].type, this._indicators[lineId].text);
|
|
14438
14463
|
this._layer.add(this._indicators[lineId].indicator);
|
|
14439
14464
|
} else {
|
|
14440
|
-
this._indicators[lineId].indicator.y(y - this.
|
|
14465
|
+
this._indicators[lineId].indicator.y(y - this._indicators[lineId].indicator.getAttr('trueHeight') / 2);
|
|
14441
14466
|
}
|
|
14442
14467
|
} else {
|
|
14443
14468
|
this.removeIndicator(lineId, true);
|
|
@@ -14454,9 +14479,6 @@ module.exports = function (Konva, Utils, SVGs) {
|
|
|
14454
14479
|
LineIndicator.prototype.draw = function () {
|
|
14455
14480
|
this._layer.draw();
|
|
14456
14481
|
};
|
|
14457
|
-
LineIndicator.prototype._getIndicatorHeight = function (type) {
|
|
14458
|
-
return type === 'default' ? this._fontSize + this._iconSize + this._defaultPadding : this._fontSize + this._iconSize;
|
|
14459
|
-
};
|
|
14460
14482
|
LineIndicator.prototype._createContextMenu = function () {
|
|
14461
14483
|
var menu = document.createElement('div');
|
|
14462
14484
|
var addLine = document.createElement('button');
|
|
@@ -15389,8 +15411,12 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15389
15411
|
segmentMagnetThreshold: 15,
|
|
15390
15412
|
enableVerticalScrolling: true,
|
|
15391
15413
|
lineIndicatorWidth: 20,
|
|
15392
|
-
|
|
15393
|
-
|
|
15414
|
+
lineIndicatorDefaultIconSize: 19,
|
|
15415
|
+
lineIndicatorVolumeIconSize: 24,
|
|
15416
|
+
lineIndicatorNoVolumeIconSize: 24,
|
|
15417
|
+
lineIndicatorVisibilityIconSize: 24,
|
|
15418
|
+
lineIndicatorNoVisibilityIconSize: 24,
|
|
15419
|
+
lineIndicatorFontSize: 10,
|
|
15394
15420
|
lineIndicatorColor: '#8A8F98',
|
|
15395
15421
|
lineIndicatorSelected: '#ccc',
|
|
15396
15422
|
autoScrollThreshold: 0.05,
|
|
@@ -15534,6 +15560,10 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15534
15560
|
var lineId = this.view.getLineByPosition(linePosition).getId();
|
|
15535
15561
|
this.emit('lineIndicator.setType', lineId, type);
|
|
15536
15562
|
};
|
|
15563
|
+
Peaks.prototype.setIndicatorText = function (linePosition, text) {
|
|
15564
|
+
var lineId = this.view.getLineByPosition(linePosition).getId();
|
|
15565
|
+
this.emit('lineIndicator.setText', lineId, text);
|
|
15566
|
+
};
|
|
15537
15567
|
Peaks.prototype.getVisibleSegments = function () {
|
|
15538
15568
|
return this.view.getSegmentsGroup().getVisibleSegments();
|
|
15539
15569
|
};
|
package/src/line-indicator.js
CHANGED
|
@@ -34,8 +34,16 @@ define([
|
|
|
34
34
|
this._width = this._peaks.options.lineIndicatorWidth;
|
|
35
35
|
this._height = this._view.getHeight();
|
|
36
36
|
|
|
37
|
-
this.
|
|
38
|
-
|
|
37
|
+
this._sizes = {
|
|
38
|
+
font: this._peaks.options.lineIndicatorFontSize,
|
|
39
|
+
icon: {
|
|
40
|
+
default: this._peaks.options.lineIndicatorDefaultIconSize,
|
|
41
|
+
volume: this._peaks.options.lineIndicatorVolumeIconSize,
|
|
42
|
+
noVolume: this._peaks.options.lineIndicatorNoVolumeIconSize,
|
|
43
|
+
visibility: this._peaks.options.lineIndicatorVisibilityIconSize,
|
|
44
|
+
noVisibility: this._peaks.options.lineIndicatorNoVisibilityIconSize
|
|
45
|
+
}
|
|
46
|
+
};
|
|
39
47
|
|
|
40
48
|
this._defaultPadding = 5;
|
|
41
49
|
this._types = ['default'].concat(Object.keys(SVGs));
|
|
@@ -66,6 +74,7 @@ define([
|
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
this._peaks.on('lineIndicator.setType', this._onSetType.bind(this));
|
|
77
|
+
this._peaks.on('lineIndicator.setText', this._onSetText.bind(this));
|
|
69
78
|
}
|
|
70
79
|
|
|
71
80
|
LineIndicator.prototype.fitToView = function() {
|
|
@@ -83,7 +92,8 @@ define([
|
|
|
83
92
|
|
|
84
93
|
var indicator = this._createIndicator(
|
|
85
94
|
this._indicators[lineId].line,
|
|
86
|
-
type
|
|
95
|
+
type,
|
|
96
|
+
this._indicators[lineId].text
|
|
87
97
|
);
|
|
88
98
|
|
|
89
99
|
this._layer.add(indicator);
|
|
@@ -94,6 +104,23 @@ define([
|
|
|
94
104
|
this.draw();
|
|
95
105
|
};
|
|
96
106
|
|
|
107
|
+
LineIndicator.prototype._onSetText = function(lineId, text) {
|
|
108
|
+
this.removeIndicator(lineId, true);
|
|
109
|
+
|
|
110
|
+
var indicator = this._createIndicator(
|
|
111
|
+
this._indicators[lineId].line,
|
|
112
|
+
this._indicators[lineId].type,
|
|
113
|
+
text
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
this._layer.add(indicator);
|
|
117
|
+
|
|
118
|
+
this._indicators[lineId].indicator = indicator;
|
|
119
|
+
this._indicators[lineId].text = text;
|
|
120
|
+
|
|
121
|
+
this.draw();
|
|
122
|
+
};
|
|
123
|
+
|
|
97
124
|
LineIndicator.prototype._showMenu = function(menu) {
|
|
98
125
|
menu.style.display = 'block';
|
|
99
126
|
var containerRect = this._stage.container().getBoundingClientRect();
|
|
@@ -104,50 +131,62 @@ define([
|
|
|
104
131
|
menu.style.left = containerRect.left + this._stage.getPointerPosition().x + 6 + 'px';
|
|
105
132
|
};
|
|
106
133
|
|
|
107
|
-
LineIndicator.prototype._createIndicator = function(line, type) {
|
|
134
|
+
LineIndicator.prototype._createIndicator = function(line, type, text) {
|
|
108
135
|
var indicator = new Konva.Group();
|
|
136
|
+
var indicatorHeight = 0;
|
|
109
137
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
138
|
+
if (text) {
|
|
139
|
+
var textNode = new Konva.Text({
|
|
140
|
+
text: text,
|
|
141
|
+
fontSize: this._sizes.font,
|
|
142
|
+
fontFamily: 'Arial',
|
|
143
|
+
fill: this._peaks.options.lineIndicatorColor,
|
|
144
|
+
align: 'center',
|
|
145
|
+
width: this._width
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
indicator.add(textNode);
|
|
149
|
+
indicatorHeight += this._sizes.font;
|
|
150
|
+
}
|
|
118
151
|
|
|
119
152
|
type = this._types.includes(type) ? type : 'default';
|
|
120
153
|
|
|
121
|
-
var
|
|
154
|
+
var iconNode;
|
|
122
155
|
|
|
123
156
|
if (type === 'default') {
|
|
124
|
-
|
|
157
|
+
var padding = text ? this._defaultPadding : 0;
|
|
158
|
+
|
|
159
|
+
iconNode = new Konva.Circle({
|
|
125
160
|
x: this._width / 2,
|
|
126
|
-
y:
|
|
127
|
-
radius: this.
|
|
161
|
+
y: indicatorHeight + this._sizes.icon.default / 2 + padding,
|
|
162
|
+
radius: this._sizes.icon.default / 2,
|
|
128
163
|
fill: this._peaks.options.lineIndicatorColor,
|
|
129
164
|
strokeWidth: 0,
|
|
130
165
|
lineId: line.getId()
|
|
131
166
|
});
|
|
167
|
+
|
|
168
|
+
indicatorHeight += padding;
|
|
132
169
|
}
|
|
133
170
|
else {
|
|
134
|
-
|
|
135
|
-
x: (this._width - this.
|
|
136
|
-
y:
|
|
171
|
+
iconNode = new Konva.Path({
|
|
172
|
+
x: (this._width - this._sizes.icon[type]) / 2,
|
|
173
|
+
y: indicatorHeight,
|
|
137
174
|
data: SVGs[type].path,
|
|
138
175
|
fill: this._peaks.options.lineIndicatorColor,
|
|
139
176
|
scale: {
|
|
140
|
-
x: (this.
|
|
141
|
-
y: (this.
|
|
177
|
+
x: (this._sizes.icon[type]) / SVGs[type].width,
|
|
178
|
+
y: (this._sizes.icon[type]) / SVGs[type].height
|
|
142
179
|
},
|
|
143
180
|
lineId: line.getId()
|
|
144
181
|
});
|
|
145
182
|
}
|
|
146
183
|
|
|
147
|
-
indicator.add(
|
|
148
|
-
|
|
184
|
+
indicator.add(iconNode);
|
|
185
|
+
indicatorHeight += this._sizes.icon[type];
|
|
149
186
|
|
|
150
|
-
indicator.
|
|
187
|
+
indicator.setAttr('trueHeight', indicatorHeight);
|
|
188
|
+
|
|
189
|
+
indicator.y(line.getY() + (line.lineHeight() - indicatorHeight) / 2);
|
|
151
190
|
|
|
152
191
|
var self = this;
|
|
153
192
|
|
|
@@ -210,13 +249,14 @@ define([
|
|
|
210
249
|
if (!this._indicators[lineId].indicator) {
|
|
211
250
|
this._indicators[lineId].indicator = this._createIndicator(
|
|
212
251
|
this._indicators[lineId].line,
|
|
213
|
-
this._indicators[lineId].type
|
|
252
|
+
this._indicators[lineId].type,
|
|
253
|
+
this._indicators[lineId].text
|
|
214
254
|
);
|
|
215
255
|
this._layer.add(this._indicators[lineId].indicator);
|
|
216
256
|
}
|
|
217
257
|
else {
|
|
218
258
|
this._indicators[lineId].indicator.y(
|
|
219
|
-
y - this.
|
|
259
|
+
y - this._indicators[lineId].indicator.getAttr('trueHeight') / 2
|
|
220
260
|
);
|
|
221
261
|
}
|
|
222
262
|
}
|
|
@@ -239,12 +279,6 @@ define([
|
|
|
239
279
|
this._layer.draw();
|
|
240
280
|
};
|
|
241
281
|
|
|
242
|
-
LineIndicator.prototype._getIndicatorHeight = function(type) {
|
|
243
|
-
return type === 'default' ?
|
|
244
|
-
this._fontSize + this._iconSize + this._defaultPadding :
|
|
245
|
-
this._fontSize + this._iconSize;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
282
|
LineIndicator.prototype._createContextMenu = function() {
|
|
249
283
|
var menu = document.createElement('div');
|
|
250
284
|
var addLine = document.createElement('button');
|
package/src/main.js
CHANGED
|
@@ -283,16 +283,36 @@ define([
|
|
|
283
283
|
/**
|
|
284
284
|
* Size of the line indicators' icon, in pixels
|
|
285
285
|
*/
|
|
286
|
-
|
|
286
|
+
lineIndicatorDefaultIconSize: 19,
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Size of the line indicators' volume icon, in pixels
|
|
290
|
+
*/
|
|
291
|
+
lineIndicatorVolumeIconSize: 24,
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Size of the line indicators' no volume, in pixels
|
|
295
|
+
*/
|
|
296
|
+
lineIndicatorNoVolumeIconSize: 24,
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Size of the line indicators' visibility, in pixels
|
|
300
|
+
*/
|
|
301
|
+
lineIndicatorVisibilityIconSize: 24,
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Size of the line indicators' no visibility icon, in pixels
|
|
305
|
+
*/
|
|
306
|
+
lineIndicatorNoVisibilityIconSize: 24,
|
|
287
307
|
|
|
288
308
|
/**
|
|
289
309
|
* Font size of the line indicators' text, in pixels
|
|
290
310
|
*/
|
|
291
|
-
lineIndicatorFontSize:
|
|
311
|
+
lineIndicatorFontSize: 10,
|
|
292
312
|
|
|
293
313
|
/**
|
|
294
314
|
* Color of the line indicators
|
|
295
|
-
|
|
315
|
+
*/
|
|
296
316
|
lineIndicatorColor: '#8A8F98',
|
|
297
317
|
|
|
298
318
|
/**
|
|
@@ -634,6 +654,12 @@ define([
|
|
|
634
654
|
this.emit('lineIndicator.setType', lineId, type);
|
|
635
655
|
};
|
|
636
656
|
|
|
657
|
+
Peaks.prototype.setIndicatorText = function(linePosition, text) {
|
|
658
|
+
var lineId = this.view.getLineByPosition(linePosition).getId();
|
|
659
|
+
|
|
660
|
+
this.emit('lineIndicator.setText', lineId, text);
|
|
661
|
+
};
|
|
662
|
+
|
|
637
663
|
Peaks.prototype.getVisibleSegments = function() {
|
|
638
664
|
return this.view
|
|
639
665
|
.getSegmentsGroup()
|