@checksub_team/peaks_timeline 1.4.33 → 1.4.36
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 +71 -15
- package/src/line-indicator.js +79 -14
- package/src/lines.js +4 -0
- package/src/main.js +7 -1
- package/src/segment.js +2 -1
- package/src/sources-layer.js +4 -0
- package/src/timeline-zoomview.js +4 -0
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -14320,30 +14320,68 @@ module.exports = function (Konva, Utils) {
|
|
|
14320
14320
|
if (this._peaks.options.enableLineIndicatorContextMenu) {
|
|
14321
14321
|
this._createContextMenu();
|
|
14322
14322
|
}
|
|
14323
|
+
this.ICON_SIZE = 18;
|
|
14324
|
+
this._volumeSVGPath = 'M0 6.00001V12H4L9 17V1.00001L4 6.00001H0ZM13.5 9.00001C13.5 7.23001 12.48 5.71001 11 4.97001V13.02C12.48 12.29 13.5 10.77 13.5 9.00001ZM11 0.230011V2.29001C13.89 3.15001 16 5.83001 16 9.00001C16 12.17 13.89 14.85 11 15.71V17.77C15.01 16.86 18 13.28 18 9.00001C18 4.72001 15.01 1.14001 11 0.230011Z';
|
|
14325
|
+
this._noVolumeSVGPath = 'M13.5 9C13.5 7.23 12.48 5.71 11 4.97V7.18L13.45 9.63C13.48 9.43 13.5 9.22 13.5 9ZM16 9C16 9.94 15.8 10.82 15.46 11.64L16.97 13.15C17.63 11.91 18 10.5 18 9C18 4.72 15.01 1.14 11 0.23V2.29C13.89 3.15 16 5.83 16 9ZM1.27 0L0 1.27L4.73 6H0V12H4L9 17V10.27L13.25 14.52C12.58 15.04 11.83 15.45 11 15.7V17.76C12.38 17.45 13.63 16.81 14.69 15.95L16.73 18L18 16.73L9 7.73L1.27 0ZM9 1L6.91 3.09L9 5.18V1Z';
|
|
14326
|
+
this._peaks.on('lineIndicator.setType', this._onSetType.bind(this));
|
|
14327
|
+
this._types = [
|
|
14328
|
+
'default',
|
|
14329
|
+
'volume',
|
|
14330
|
+
'noVolume'
|
|
14331
|
+
];
|
|
14323
14332
|
}
|
|
14333
|
+
LineIndicator.prototype._onSetType = function (lineId, type) {
|
|
14334
|
+
this.removeIndicator(lineId, true);
|
|
14335
|
+
type = this._types.includes(type) ? type : 'default';
|
|
14336
|
+
var indicator = this._createIndicator(this._indicators[lineId].line, type);
|
|
14337
|
+
this._layer.add(indicator);
|
|
14338
|
+
this._indicators[lineId].indicator = indicator;
|
|
14339
|
+
this._indicators[lineId].type = type;
|
|
14340
|
+
this.draw();
|
|
14341
|
+
};
|
|
14324
14342
|
LineIndicator.prototype._showMenu = function (menu) {
|
|
14325
14343
|
menu.style.display = 'block';
|
|
14326
14344
|
var containerRect = this._stage.container().getBoundingClientRect();
|
|
14327
14345
|
menu.style.top = containerRect.top + this._stage.getPointerPosition().y - menu.offsetHeight + 'px';
|
|
14328
14346
|
menu.style.left = containerRect.left + this._stage.getPointerPosition().x + 6 + 'px';
|
|
14329
14347
|
};
|
|
14330
|
-
LineIndicator.prototype._createIndicator = function (line) {
|
|
14331
|
-
var indicator
|
|
14332
|
-
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
|
|
14336
|
-
|
|
14337
|
-
|
|
14338
|
-
|
|
14348
|
+
LineIndicator.prototype._createIndicator = function (line, type) {
|
|
14349
|
+
var indicator;
|
|
14350
|
+
type = typeof type !== 'undefined' ? type : 'default';
|
|
14351
|
+
if (type === 'default') {
|
|
14352
|
+
indicator = new Konva.Circle({
|
|
14353
|
+
x: this._width / 2,
|
|
14354
|
+
y: line.getY() + line.lineHeight() / 2,
|
|
14355
|
+
radius: this._indicatorRadius,
|
|
14356
|
+
fill: this._peaks.options.lineIndicatorColor,
|
|
14357
|
+
strokeWidth: 0,
|
|
14358
|
+
lineId: line.getId()
|
|
14359
|
+
});
|
|
14360
|
+
} else {
|
|
14361
|
+
var scaleFactor = this._width / 2 / this.ICON_SIZE;
|
|
14362
|
+
indicator = new Konva.Path({
|
|
14363
|
+
x: this._width / 4,
|
|
14364
|
+
y: line.getY() + line.lineHeight() / 2 - this._width / 4,
|
|
14365
|
+
data: type === 'volume' ? this._volumeSVGPath : this._noVolumeSVGPath,
|
|
14366
|
+
fill: this._peaks.options.lineIndicatorColor,
|
|
14367
|
+
scale: {
|
|
14368
|
+
x: scaleFactor,
|
|
14369
|
+
y: scaleFactor
|
|
14370
|
+
},
|
|
14371
|
+
lineId: line.getId()
|
|
14372
|
+
});
|
|
14373
|
+
}
|
|
14339
14374
|
var self = this;
|
|
14340
14375
|
indicator.on('mouseover', function () {
|
|
14341
14376
|
indicator.fill(self._peaks.options.lineIndicatorSelected);
|
|
14342
|
-
|
|
14377
|
+
self.draw();
|
|
14343
14378
|
});
|
|
14344
14379
|
indicator.on('mouseout', function () {
|
|
14345
14380
|
indicator.fill(self._peaks.options.lineIndicatorColor);
|
|
14346
|
-
|
|
14381
|
+
self.draw();
|
|
14382
|
+
});
|
|
14383
|
+
indicator.on('click', function (e) {
|
|
14384
|
+
self._peaks.emit('lineIndicator.click', self._indicators[line.getId()], e.evt.button);
|
|
14347
14385
|
});
|
|
14348
14386
|
return indicator;
|
|
14349
14387
|
};
|
|
@@ -14353,7 +14391,8 @@ module.exports = function (Konva, Utils) {
|
|
|
14353
14391
|
this._layer.add(indicator);
|
|
14354
14392
|
this._indicators[line.getId()] = {
|
|
14355
14393
|
indicator: indicator,
|
|
14356
|
-
line: line
|
|
14394
|
+
line: line,
|
|
14395
|
+
type: 'default'
|
|
14357
14396
|
};
|
|
14358
14397
|
}
|
|
14359
14398
|
};
|
|
@@ -14369,15 +14408,18 @@ module.exports = function (Konva, Utils) {
|
|
|
14369
14408
|
}
|
|
14370
14409
|
}
|
|
14371
14410
|
};
|
|
14411
|
+
LineIndicator.prototype.getPixelsFromCenter = function (lineId) {
|
|
14412
|
+
return this._indicators[lineId].type === 'default' ? 0 : this._width / 4;
|
|
14413
|
+
};
|
|
14372
14414
|
LineIndicator.prototype.updateIndicator = function (lineId) {
|
|
14373
14415
|
if (this._indicators[lineId]) {
|
|
14374
14416
|
var y = this._indicators[lineId].line.getY() + this._indicators[lineId].line.lineHeight() / 2;
|
|
14375
14417
|
if (y + this._indicatorRadius > 0 && y - this._indicatorRadius < this._height) {
|
|
14376
14418
|
if (!this._indicators[lineId].indicator) {
|
|
14377
|
-
this._indicators[lineId].indicator = this._createIndicator(this._indicators[lineId].line);
|
|
14419
|
+
this._indicators[lineId].indicator = this._createIndicator(this._indicators[lineId].line, this._indicators[lineId].type);
|
|
14378
14420
|
this._layer.add(this._indicators[lineId].indicator);
|
|
14379
14421
|
} else {
|
|
14380
|
-
this._indicators[lineId].indicator.y(y);
|
|
14422
|
+
this._indicators[lineId].indicator.y(y - this.getPixelsFromCenter(lineId));
|
|
14381
14423
|
}
|
|
14382
14424
|
} else {
|
|
14383
14425
|
this.removeIndicator(lineId, true);
|
|
@@ -15174,6 +15216,9 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15174
15216
|
}
|
|
15175
15217
|
}
|
|
15176
15218
|
};
|
|
15219
|
+
Lines.prototype.getLineByPosition = function (pos) {
|
|
15220
|
+
return this._linesByPosition[pos];
|
|
15221
|
+
};
|
|
15177
15222
|
Lines.prototype.getLineOnPosition = function (y) {
|
|
15178
15223
|
var height;
|
|
15179
15224
|
var pos = [
|
|
@@ -15320,7 +15365,7 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15320
15365
|
segmentMagnetThreshold: 15,
|
|
15321
15366
|
enableVerticalScrolling: true,
|
|
15322
15367
|
lineIndicatorWidth: 20,
|
|
15323
|
-
lineIndicatorColor: '
|
|
15368
|
+
lineIndicatorColor: '#8A8F98',
|
|
15324
15369
|
lineIndicatorSelected: '#ccc',
|
|
15325
15370
|
autoScrollThreshold: 0.05,
|
|
15326
15371
|
enableLineIndicatorContextMenu: true,
|
|
@@ -15459,6 +15504,10 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15459
15504
|
Peaks.prototype.setCutMode = function () {
|
|
15460
15505
|
this.emit('cut_mode');
|
|
15461
15506
|
};
|
|
15507
|
+
Peaks.prototype.setIndicatorType = function (linePosition, type) {
|
|
15508
|
+
var lineId = this.view.getLineByPosition(linePosition).getId();
|
|
15509
|
+
this.emit('lineIndicator.setType', lineId, type);
|
|
15510
|
+
};
|
|
15462
15511
|
Peaks.prototype.getVisibleSegments = function () {
|
|
15463
15512
|
return this.view.getSegmentsGroup().getVisibleSegments();
|
|
15464
15513
|
};
|
|
@@ -16729,6 +16778,7 @@ module.exports = function (Utils) {
|
|
|
16729
16778
|
color: this.color,
|
|
16730
16779
|
textColor: this.textColor,
|
|
16731
16780
|
handleTextColor: this.handleTextColor,
|
|
16781
|
+
hoverColor: this.hoverColor,
|
|
16732
16782
|
opacity: this.opacity,
|
|
16733
16783
|
editable: this.editable,
|
|
16734
16784
|
allowDeletion: this.allowDeletion,
|
|
@@ -18838,6 +18888,9 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
18838
18888
|
SourcesLayer.prototype.getLength = function () {
|
|
18839
18889
|
return this._lines.linesLength();
|
|
18840
18890
|
};
|
|
18891
|
+
SourcesLayer.prototype.getLineByPosition = function (pos) {
|
|
18892
|
+
return this._lines.getLineByPosition(pos);
|
|
18893
|
+
};
|
|
18841
18894
|
return SourcesLayer;
|
|
18842
18895
|
}(_dereq_('./source-group'), _dereq_('./lines'), _dereq_('./data-retriever'), _dereq_('./utils'), _dereq_('./invoker'), _dereq_('konva'));
|
|
18843
18896
|
},{"./data-retriever":86,"./invoker":89,"./lines":93,"./source-group":104,"./utils":111,"konva":43}],107:[function(_dereq_,module,exports){
|
|
@@ -19709,6 +19762,9 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
19709
19762
|
TimelineZoomView.prototype.getEndTime = function () {
|
|
19710
19763
|
return this.pixelsToTime(this._frameOffset + this._width);
|
|
19711
19764
|
};
|
|
19765
|
+
TimelineZoomView.prototype.getLineByPosition = function (pos) {
|
|
19766
|
+
return this._sourcesLayer.getLineByPosition(pos);
|
|
19767
|
+
};
|
|
19712
19768
|
TimelineZoomView.prototype.setStartTime = function (time) {
|
|
19713
19769
|
if (time < 0) {
|
|
19714
19770
|
time = 0;
|
package/src/line-indicator.js
CHANGED
|
@@ -58,8 +58,36 @@ define([
|
|
|
58
58
|
if (this._peaks.options.enableLineIndicatorContextMenu) {
|
|
59
59
|
this._createContextMenu();
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
/* eslint-disable max-len */
|
|
63
|
+
this.ICON_SIZE = 18;
|
|
64
|
+
this._volumeSVGPath = 'M0 6.00001V12H4L9 17V1.00001L4 6.00001H0ZM13.5 9.00001C13.5 7.23001 12.48 5.71001 11 4.97001V13.02C12.48 12.29 13.5 10.77 13.5 9.00001ZM11 0.230011V2.29001C13.89 3.15001 16 5.83001 16 9.00001C16 12.17 13.89 14.85 11 15.71V17.77C15.01 16.86 18 13.28 18 9.00001C18 4.72001 15.01 1.14001 11 0.230011Z';
|
|
65
|
+
this._noVolumeSVGPath = 'M13.5 9C13.5 7.23 12.48 5.71 11 4.97V7.18L13.45 9.63C13.48 9.43 13.5 9.22 13.5 9ZM16 9C16 9.94 15.8 10.82 15.46 11.64L16.97 13.15C17.63 11.91 18 10.5 18 9C18 4.72 15.01 1.14 11 0.23V2.29C13.89 3.15 16 5.83 16 9ZM1.27 0L0 1.27L4.73 6H0V12H4L9 17V10.27L13.25 14.52C12.58 15.04 11.83 15.45 11 15.7V17.76C12.38 17.45 13.63 16.81 14.69 15.95L16.73 18L18 16.73L9 7.73L1.27 0ZM9 1L6.91 3.09L9 5.18V1Z';
|
|
66
|
+
/* eslint-enable max-len */
|
|
67
|
+
|
|
68
|
+
this._peaks.on('lineIndicator.setType', this._onSetType.bind(this));
|
|
69
|
+
|
|
70
|
+
this._types = ['default', 'volume', 'noVolume'];
|
|
61
71
|
}
|
|
62
72
|
|
|
73
|
+
LineIndicator.prototype._onSetType = function(lineId, type) {
|
|
74
|
+
this.removeIndicator(lineId, true);
|
|
75
|
+
|
|
76
|
+
type = this._types.includes(type) ? type : 'default';
|
|
77
|
+
|
|
78
|
+
var indicator = this._createIndicator(
|
|
79
|
+
this._indicators[lineId].line,
|
|
80
|
+
type
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
this._layer.add(indicator);
|
|
84
|
+
|
|
85
|
+
this._indicators[lineId].indicator = indicator;
|
|
86
|
+
this._indicators[lineId].type = type;
|
|
87
|
+
|
|
88
|
+
this.draw();
|
|
89
|
+
};
|
|
90
|
+
|
|
63
91
|
LineIndicator.prototype._showMenu = function(menu) {
|
|
64
92
|
menu.style.display = 'block';
|
|
65
93
|
var containerRect = this._stage.container().getBoundingClientRect();
|
|
@@ -70,26 +98,53 @@ define([
|
|
|
70
98
|
menu.style.left = containerRect.left + this._stage.getPointerPosition().x + 6 + 'px';
|
|
71
99
|
};
|
|
72
100
|
|
|
73
|
-
LineIndicator.prototype._createIndicator = function(line) {
|
|
74
|
-
var indicator
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
101
|
+
LineIndicator.prototype._createIndicator = function(line, type) {
|
|
102
|
+
var indicator;
|
|
103
|
+
|
|
104
|
+
type = typeof type !== 'undefined' ? type : 'default';
|
|
105
|
+
|
|
106
|
+
if (type === 'default') {
|
|
107
|
+
indicator = new Konva.Circle({
|
|
108
|
+
x: this._width / 2,
|
|
109
|
+
y: line.getY() + (line.lineHeight() / 2),
|
|
110
|
+
radius: this._indicatorRadius,
|
|
111
|
+
fill: this._peaks.options.lineIndicatorColor,
|
|
112
|
+
strokeWidth: 0,
|
|
113
|
+
lineId: line.getId()
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
var scaleFactor = (this._width / 2) / this.ICON_SIZE;
|
|
118
|
+
|
|
119
|
+
indicator = new Konva.Path({
|
|
120
|
+
x: this._width / 4,
|
|
121
|
+
y: line.getY() + (line.lineHeight() / 2) - (this._width / 4),
|
|
122
|
+
data: type === 'volume' ?
|
|
123
|
+
this._volumeSVGPath :
|
|
124
|
+
this._noVolumeSVGPath,
|
|
125
|
+
fill: this._peaks.options.lineIndicatorColor,
|
|
126
|
+
scale: {
|
|
127
|
+
x: scaleFactor,
|
|
128
|
+
y: scaleFactor
|
|
129
|
+
},
|
|
130
|
+
lineId: line.getId()
|
|
131
|
+
});
|
|
132
|
+
}
|
|
82
133
|
|
|
83
134
|
var self = this;
|
|
84
135
|
|
|
85
136
|
indicator.on('mouseover', function() {
|
|
86
137
|
indicator.fill(self._peaks.options.lineIndicatorSelected);
|
|
87
|
-
|
|
138
|
+
self.draw();
|
|
88
139
|
});
|
|
89
140
|
|
|
90
141
|
indicator.on('mouseout', function() {
|
|
91
142
|
indicator.fill(self._peaks.options.lineIndicatorColor);
|
|
92
|
-
|
|
143
|
+
self.draw();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
indicator.on('click', function(e) {
|
|
147
|
+
self._peaks.emit('lineIndicator.click', self._indicators[line.getId()], e.evt.button);
|
|
93
148
|
});
|
|
94
149
|
|
|
95
150
|
return indicator;
|
|
@@ -103,7 +158,8 @@ define([
|
|
|
103
158
|
|
|
104
159
|
this._indicators[line.getId()] = {
|
|
105
160
|
indicator: indicator,
|
|
106
|
-
line: line
|
|
161
|
+
line: line,
|
|
162
|
+
type: 'default'
|
|
107
163
|
};
|
|
108
164
|
}
|
|
109
165
|
};
|
|
@@ -122,6 +178,12 @@ define([
|
|
|
122
178
|
}
|
|
123
179
|
};
|
|
124
180
|
|
|
181
|
+
LineIndicator.prototype.getPixelsFromCenter = function(lineId) {
|
|
182
|
+
return this._indicators[lineId].type === 'default' ?
|
|
183
|
+
0 :
|
|
184
|
+
this._width / 4;
|
|
185
|
+
};
|
|
186
|
+
|
|
125
187
|
LineIndicator.prototype.updateIndicator = function(lineId) {
|
|
126
188
|
if (this._indicators[lineId]) {
|
|
127
189
|
var y = this._indicators[lineId].line.getY()
|
|
@@ -130,11 +192,14 @@ define([
|
|
|
130
192
|
if (y + this._indicatorRadius > 0 && y - this._indicatorRadius < this._height) {
|
|
131
193
|
// The indicator is visible
|
|
132
194
|
if (!this._indicators[lineId].indicator) {
|
|
133
|
-
this._indicators[lineId].indicator = this._createIndicator(
|
|
195
|
+
this._indicators[lineId].indicator = this._createIndicator(
|
|
196
|
+
this._indicators[lineId].line,
|
|
197
|
+
this._indicators[lineId].type
|
|
198
|
+
);
|
|
134
199
|
this._layer.add(this._indicators[lineId].indicator);
|
|
135
200
|
}
|
|
136
201
|
else {
|
|
137
|
-
this._indicators[lineId].indicator.y(y);
|
|
202
|
+
this._indicators[lineId].indicator.y(y - this.getPixelsFromCenter(lineId));
|
|
138
203
|
}
|
|
139
204
|
}
|
|
140
205
|
else {
|
package/src/lines.js
CHANGED
package/src/main.js
CHANGED
|
@@ -283,7 +283,7 @@ define([
|
|
|
283
283
|
/**
|
|
284
284
|
* Color of the line indicators
|
|
285
285
|
*/
|
|
286
|
-
lineIndicatorColor: '
|
|
286
|
+
lineIndicatorColor: '#8A8F98',
|
|
287
287
|
|
|
288
288
|
/**
|
|
289
289
|
* Color for the indicator when selected
|
|
@@ -618,6 +618,12 @@ define([
|
|
|
618
618
|
this.emit('cut_mode');
|
|
619
619
|
};
|
|
620
620
|
|
|
621
|
+
Peaks.prototype.setIndicatorType = function(linePosition, type) {
|
|
622
|
+
var lineId = this.view.getLineByPosition(linePosition).getId();
|
|
623
|
+
|
|
624
|
+
this.emit('lineIndicator.setType', lineId, type);
|
|
625
|
+
};
|
|
626
|
+
|
|
621
627
|
Peaks.prototype.getVisibleSegments = function() {
|
|
622
628
|
return this.view
|
|
623
629
|
.getSegmentsGroup()
|
package/src/segment.js
CHANGED
|
@@ -219,6 +219,7 @@ define([
|
|
|
219
219
|
color: this.color,
|
|
220
220
|
textColor: this.textColor,
|
|
221
221
|
handleTextColor: this.handleTextColor,
|
|
222
|
+
hoverColor: this.hoverColor,
|
|
222
223
|
opacity: this.opacity,
|
|
223
224
|
editable: this.editable,
|
|
224
225
|
allowDeletion: this.allowDeletion,
|
|
@@ -235,7 +236,7 @@ define([
|
|
|
235
236
|
this._color = opts.color;
|
|
236
237
|
this._textColor = opts.textColor;
|
|
237
238
|
this._handleTextColor = opts.handleTextColor;
|
|
238
|
-
this._hoverColor = opts.hoverColor
|
|
239
|
+
this._hoverColor = opts.hoverColor;
|
|
239
240
|
this._opacity = opts.opacity;
|
|
240
241
|
this._editable = opts.editable;
|
|
241
242
|
this._allowDeletion = opts.allowDeletion;
|
package/src/sources-layer.js
CHANGED
package/src/timeline-zoomview.js
CHANGED
|
@@ -638,6 +638,10 @@ define([
|
|
|
638
638
|
return this.pixelsToTime(this._frameOffset + this._width);
|
|
639
639
|
};
|
|
640
640
|
|
|
641
|
+
TimelineZoomView.prototype.getLineByPosition = function(pos) {
|
|
642
|
+
return this._sourcesLayer.getLineByPosition(pos);
|
|
643
|
+
};
|
|
644
|
+
|
|
641
645
|
TimelineZoomView.prototype.setStartTime = function(time) {
|
|
642
646
|
if (time < 0) {
|
|
643
647
|
time = 0;
|