@checksub_team/peaks_timeline 2.0.0-alpha.6 → 2.0.0-alpha.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 +30 -7
- package/src/components/line-group.js +4 -0
- package/src/components/line-groups.js +10 -5
- package/src/components/line-indicator.js +2 -0
- package/src/line-handler.js +2 -1
- package/src/models/line.js +20 -3
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -14827,6 +14827,9 @@ module.exports = function (SourceGroup, Utils, Konva) {
|
|
|
14827
14827
|
LineGroup.prototype.getId = function () {
|
|
14828
14828
|
return this._line.id;
|
|
14829
14829
|
};
|
|
14830
|
+
LineGroup.prototype.isLocked = function () {
|
|
14831
|
+
return this._line.locked;
|
|
14832
|
+
};
|
|
14830
14833
|
LineGroup.prototype.getLine = function () {
|
|
14831
14834
|
return this._line;
|
|
14832
14835
|
};
|
|
@@ -15525,13 +15528,18 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
|
|
|
15525
15528
|
if (Utils.isNullOrUndefined(mouseX)) {
|
|
15526
15529
|
return;
|
|
15527
15530
|
}
|
|
15528
|
-
const
|
|
15531
|
+
const currentLineGroup = this._lineGroupsById[sources[0].lineId];
|
|
15532
|
+
const position = currentLineGroup.getPosition();
|
|
15529
15533
|
const linePos = this.getLinesUnderY(mouseY);
|
|
15534
|
+
if (currentLineGroup.isLocked()) {
|
|
15535
|
+
return;
|
|
15536
|
+
}
|
|
15530
15537
|
if (linePos[0] !== linePos[1]) {
|
|
15531
15538
|
this.manageAutomaticLineCreation(linePos[0] + 1, position, sources);
|
|
15532
15539
|
} else {
|
|
15533
15540
|
this.stopAutomaticLineCreation();
|
|
15534
|
-
|
|
15541
|
+
const targetLineGroup = this._lineGroupsByPosition[linePos[0]];
|
|
15542
|
+
if (!Utils.isNullOrUndefined(mouseX) && linePos[0] !== position && !targetLineGroup.isLocked() && !targetLineGroup.isSegmentsLine()) {
|
|
15535
15543
|
var mouseTime = this._view.pixelsToTime(mouseX + this._view.getFrameOffset());
|
|
15536
15544
|
var sourceDuration = Utils.roundTime(endTime - startTime);
|
|
15537
15545
|
this._moveSourcesToPositionIfPossible(sources, linePos[0], mouseTime, sourceDuration);
|
|
@@ -15687,7 +15695,6 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
|
|
|
15687
15695
|
LineGroups.prototype.allowInteractions = function (forSources, forSegments) {
|
|
15688
15696
|
this._areSourceInteractionsAllowed = !Utils.isNullOrUndefined(forSources) ? forSources : this._areSourceInteractionsAllowed;
|
|
15689
15697
|
this._areSegmentInteractionsAllowed = !Utils.isNullOrUndefined(forSegments) ? forSegments : this._areSegmentInteractionsAllowed;
|
|
15690
|
-
console.log('peaks.lines.allowInteractions(): ' + 'forSources: ' + this._areSourceInteractionsAllowed + ', forSegments: ' + this._areSegmentInteractionsAllowed);
|
|
15691
15698
|
for (var id in this._lineGroupsById) {
|
|
15692
15699
|
if (Utils.objectHasProperty(this._lineGroupsById, id)) {
|
|
15693
15700
|
this._setInteractions(id);
|
|
@@ -15749,6 +15756,7 @@ module.exports = function (Konva, SVGs, Utils) {
|
|
|
15749
15756
|
this._width,
|
|
15750
15757
|
this._height
|
|
15751
15758
|
]);
|
|
15759
|
+
this.refreshIndicators();
|
|
15752
15760
|
};
|
|
15753
15761
|
LineIndicator.prototype._createIndicator = function (lineGroup, type, text) {
|
|
15754
15762
|
const indicator = new Konva.Group();
|
|
@@ -19682,7 +19690,7 @@ module.exports = function (Line, Utils) {
|
|
|
19682
19690
|
if (!Utils.isObject(options)) {
|
|
19683
19691
|
throw new TypeError('peaks.lines.add(): expected a Line object parameter');
|
|
19684
19692
|
}
|
|
19685
|
-
var line = new Line(this._peaks, Utils.isNullOrUndefined(options.id) ? Utils.createUuidv4() : options.id, options.position, options.indicatorType, options.indicatorText);
|
|
19693
|
+
var line = new Line(this._peaks, Utils.isNullOrUndefined(options.id) ? Utils.createUuidv4() : options.id, options.position, options.indicatorType, options.indicatorText, options.locked);
|
|
19686
19694
|
return line;
|
|
19687
19695
|
};
|
|
19688
19696
|
LineHandler.prototype.getLines = function () {
|
|
@@ -20031,12 +20039,18 @@ module.exports = function (Utils) {
|
|
|
20031
20039
|
} else if (!Utils.isString(options.indicatorText)) {
|
|
20032
20040
|
throw new TypeError('peaks.lines.' + context + ': indicatorText must be a string');
|
|
20033
20041
|
}
|
|
20042
|
+
if (Utils.isNullOrUndefined(options.locked)) {
|
|
20043
|
+
options.locked = false;
|
|
20044
|
+
} else if (!Utils.isBoolean(options.locked)) {
|
|
20045
|
+
throw new TypeError('peaks.lines.' + context + ': locked must be a boolean');
|
|
20046
|
+
}
|
|
20034
20047
|
}
|
|
20035
|
-
function Line(peaks, id, position, indicatorType, indicatorText) {
|
|
20048
|
+
function Line(peaks, id, position, indicatorType, indicatorText, locked) {
|
|
20036
20049
|
var opts = {
|
|
20037
20050
|
position: position,
|
|
20038
20051
|
indicatorType: indicatorType,
|
|
20039
|
-
indicatorText: indicatorText
|
|
20052
|
+
indicatorText: indicatorText,
|
|
20053
|
+
locked: locked
|
|
20040
20054
|
};
|
|
20041
20055
|
validateLine(opts, 'add()');
|
|
20042
20056
|
this._peaks = peaks;
|
|
@@ -20044,6 +20058,7 @@ module.exports = function (Utils) {
|
|
|
20044
20058
|
this._position = opts.position;
|
|
20045
20059
|
this._indicatorType = opts.indicatorType;
|
|
20046
20060
|
this._indicatorText = opts.indicatorText;
|
|
20061
|
+
this._locked = opts.locked;
|
|
20047
20062
|
}
|
|
20048
20063
|
Object.defineProperties(Line.prototype, {
|
|
20049
20064
|
id: {
|
|
@@ -20072,19 +20087,27 @@ module.exports = function (Utils) {
|
|
|
20072
20087
|
get: function () {
|
|
20073
20088
|
return this._indicatorText;
|
|
20074
20089
|
}
|
|
20090
|
+
},
|
|
20091
|
+
locked: {
|
|
20092
|
+
enumerable: true,
|
|
20093
|
+
get: function () {
|
|
20094
|
+
return this._locked;
|
|
20095
|
+
}
|
|
20075
20096
|
}
|
|
20076
20097
|
});
|
|
20077
20098
|
Line.prototype.update = function (options) {
|
|
20078
20099
|
var opts = {
|
|
20079
20100
|
position: this.position,
|
|
20080
20101
|
indicatorType: this.indicatorType,
|
|
20081
|
-
indicatorText: this.indicatorText
|
|
20102
|
+
indicatorText: this.indicatorText,
|
|
20103
|
+
locked: this.locked
|
|
20082
20104
|
};
|
|
20083
20105
|
Utils.extend(opts, options);
|
|
20084
20106
|
validateLine(opts, 'update()');
|
|
20085
20107
|
this._position = opts.position;
|
|
20086
20108
|
this._indicatorType = opts.indicatorType;
|
|
20087
20109
|
this._indicatorText = opts.indicatorText;
|
|
20110
|
+
this._locked = opts.locked;
|
|
20088
20111
|
this._peaks.emit('model.line.update', this);
|
|
20089
20112
|
};
|
|
20090
20113
|
Line.prototype.toSerializable = function () {
|
|
@@ -333,19 +333,27 @@ define([
|
|
|
333
333
|
return;
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
const
|
|
336
|
+
const currentLineGroup = this._lineGroupsById[sources[0].lineId];
|
|
337
|
+
const position = currentLineGroup.getPosition();
|
|
337
338
|
const linePos = this.getLinesUnderY(mouseY);
|
|
338
339
|
|
|
340
|
+
if (currentLineGroup.isLocked()) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
|
|
339
344
|
if (linePos[0] !== linePos[1]) {
|
|
340
345
|
this.manageAutomaticLineCreation(linePos[0] + 1, position, sources);
|
|
341
346
|
}
|
|
342
347
|
else {
|
|
343
348
|
this.stopAutomaticLineCreation();
|
|
344
349
|
|
|
350
|
+
const targetLineGroup = this._lineGroupsByPosition[linePos[0]];
|
|
351
|
+
|
|
345
352
|
if (
|
|
346
353
|
!Utils.isNullOrUndefined(mouseX)
|
|
347
354
|
&& linePos[0] !== position
|
|
348
|
-
&& !
|
|
355
|
+
&& !targetLineGroup.isLocked()
|
|
356
|
+
&& !targetLineGroup.isSegmentsLine()
|
|
349
357
|
) {
|
|
350
358
|
var mouseTime = this._view.pixelsToTime(mouseX + this._view.getFrameOffset());
|
|
351
359
|
var sourceDuration = Utils.roundTime(endTime - startTime);
|
|
@@ -567,9 +575,6 @@ define([
|
|
|
567
575
|
forSources : this._areSourceInteractionsAllowed;
|
|
568
576
|
this._areSegmentInteractionsAllowed = !Utils.isNullOrUndefined(forSegments) ?
|
|
569
577
|
forSegments : this._areSegmentInteractionsAllowed;
|
|
570
|
-
console.log('peaks.lines.allowInteractions(): ' +
|
|
571
|
-
'forSources: ' + this._areSourceInteractionsAllowed + ', forSegments: ' + this._areSegmentInteractionsAllowed
|
|
572
|
-
);
|
|
573
578
|
for (var id in this._lineGroupsById) {
|
|
574
579
|
if (Utils.objectHasProperty(this._lineGroupsById, id)) {
|
|
575
580
|
this._setInteractions(id);
|
package/src/line-handler.js
CHANGED
package/src/models/line.js
CHANGED
|
@@ -29,6 +29,13 @@ define([
|
|
|
29
29
|
else if (!Utils.isString(options.indicatorText)) {
|
|
30
30
|
throw new TypeError('peaks.lines.' + context + ': indicatorText must be a string');
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
if (Utils.isNullOrUndefined(options.locked)) {
|
|
34
|
+
options.locked = false;
|
|
35
|
+
}
|
|
36
|
+
else if (!Utils.isBoolean(options.locked)) {
|
|
37
|
+
throw new TypeError('peaks.lines.' + context + ': locked must be a boolean');
|
|
38
|
+
}
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
/**
|
|
@@ -44,11 +51,12 @@ define([
|
|
|
44
51
|
* @param {String} indicatorText Text to display above the line indicator.
|
|
45
52
|
*/
|
|
46
53
|
|
|
47
|
-
function Line(peaks, id, position, indicatorType, indicatorText) {
|
|
54
|
+
function Line(peaks, id, position, indicatorType, indicatorText, locked) {
|
|
48
55
|
var opts = {
|
|
49
56
|
position: position,
|
|
50
57
|
indicatorType: indicatorType,
|
|
51
|
-
indicatorText: indicatorText
|
|
58
|
+
indicatorText: indicatorText,
|
|
59
|
+
locked: locked
|
|
52
60
|
};
|
|
53
61
|
|
|
54
62
|
validateLine(opts, 'add()');
|
|
@@ -58,6 +66,7 @@ define([
|
|
|
58
66
|
this._position = opts.position;
|
|
59
67
|
this._indicatorType = opts.indicatorType;
|
|
60
68
|
this._indicatorText = opts.indicatorText;
|
|
69
|
+
this._locked = opts.locked;
|
|
61
70
|
}
|
|
62
71
|
|
|
63
72
|
Object.defineProperties(Line.prototype, {
|
|
@@ -88,6 +97,12 @@ define([
|
|
|
88
97
|
get: function() {
|
|
89
98
|
return this._indicatorText;
|
|
90
99
|
}
|
|
100
|
+
},
|
|
101
|
+
locked: {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function() {
|
|
104
|
+
return this._locked;
|
|
105
|
+
}
|
|
91
106
|
}
|
|
92
107
|
});
|
|
93
108
|
|
|
@@ -95,7 +110,8 @@ define([
|
|
|
95
110
|
var opts = {
|
|
96
111
|
position: this.position,
|
|
97
112
|
indicatorType: this.indicatorType,
|
|
98
|
-
indicatorText: this.indicatorText
|
|
113
|
+
indicatorText: this.indicatorText,
|
|
114
|
+
locked: this.locked
|
|
99
115
|
};
|
|
100
116
|
|
|
101
117
|
Utils.extend(opts, options);
|
|
@@ -105,6 +121,7 @@ define([
|
|
|
105
121
|
this._position = opts.position;
|
|
106
122
|
this._indicatorType = opts.indicatorType;
|
|
107
123
|
this._indicatorText = opts.indicatorText;
|
|
124
|
+
this._locked = opts.locked;
|
|
108
125
|
|
|
109
126
|
this._peaks.emit('model.line.update', this);
|
|
110
127
|
};
|