@checksub_team/peaks_timeline 2.0.0-alpha.14 → 2.0.0-alpha.15
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 +69 -1
- package/src/components/line-groups.js +36 -0
- package/src/components/line-indicator.js +58 -1
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -15325,6 +15325,7 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
|
|
|
15325
15325
|
this._peaks.on('main.allowInteractions', this.allowInteractions.bind(this));
|
|
15326
15326
|
this._peaks.on('line.heightChanged', this._onLineHeightChanged.bind(this));
|
|
15327
15327
|
this._peaks.on('segments.dragend', this._onSegmentUpdated.bind(this));
|
|
15328
|
+
this._peaks.on('lineIndicator.drag', this._onIndicatorDrag.bind(this));
|
|
15328
15329
|
}
|
|
15329
15330
|
LineGroups.prototype.fitToView = function () {
|
|
15330
15331
|
this._lineIndicator.fitToView();
|
|
@@ -15692,6 +15693,30 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
|
|
|
15692
15693
|
this.refreshLineYs();
|
|
15693
15694
|
return line.id;
|
|
15694
15695
|
};
|
|
15696
|
+
LineGroups.prototype._onIndicatorDrag = function (lineId, y) {
|
|
15697
|
+
const lineGroup = this._lineGroupsById[lineId];
|
|
15698
|
+
if (!lineGroup) {
|
|
15699
|
+
return;
|
|
15700
|
+
}
|
|
15701
|
+
const positions = this.getLinesUnderY(y);
|
|
15702
|
+
if (positions[0] !== positions[1] || positions[0] === lineGroup.getPosition()) {
|
|
15703
|
+
return;
|
|
15704
|
+
}
|
|
15705
|
+
const targetPos = positions[0];
|
|
15706
|
+
const targetLineGroup = this._lineGroupsByPosition[targetPos];
|
|
15707
|
+
const targetCenterY = targetLineGroup.y() + targetLineGroup.lineHeight() / 2;
|
|
15708
|
+
const movingDown = targetPos > lineGroup.getPosition();
|
|
15709
|
+
if (movingDown && y < targetCenterY || !movingDown && y > targetCenterY) {
|
|
15710
|
+
return;
|
|
15711
|
+
}
|
|
15712
|
+
if (targetPos === lineGroup.getPosition() + 1) {
|
|
15713
|
+
this._setLinePosition(targetLineGroup.getId(), lineGroup.getPosition());
|
|
15714
|
+
} else {
|
|
15715
|
+
this._setLinePosition(lineId, targetPos);
|
|
15716
|
+
}
|
|
15717
|
+
this.refreshLineYs();
|
|
15718
|
+
this._peaks.emit('line.moved', lineGroup.getLine());
|
|
15719
|
+
};
|
|
15695
15720
|
LineGroups.prototype.updateSegments = function (frameStartTime, frameEndTime) {
|
|
15696
15721
|
for (var lineId in this._segmentsGroups) {
|
|
15697
15722
|
if (Utils.objectHasProperty(this._segmentsGroups, lineId)) {
|
|
@@ -15776,6 +15801,11 @@ module.exports = function (Konva, SVGs, Utils) {
|
|
|
15776
15801
|
});
|
|
15777
15802
|
this._layer.add(this._separatingLine);
|
|
15778
15803
|
this._layer.draw();
|
|
15804
|
+
this._isDragging = false;
|
|
15805
|
+
this._dragLineId = null;
|
|
15806
|
+
this._dragContainerRect = null;
|
|
15807
|
+
this._onWindowMove = this._onWindowMove.bind(this);
|
|
15808
|
+
this._onWindowUp = this._onWindowUp.bind(this);
|
|
15779
15809
|
}
|
|
15780
15810
|
LineIndicator.prototype.fitToView = function () {
|
|
15781
15811
|
this._height = this._view.getHeight();
|
|
@@ -15863,11 +15893,22 @@ module.exports = function (Konva, SVGs, Utils) {
|
|
|
15863
15893
|
child.fill(child.getAttr('defaultColor'));
|
|
15864
15894
|
});
|
|
15865
15895
|
self.draw();
|
|
15866
|
-
self.
|
|
15896
|
+
if (!self._isDragging) {
|
|
15897
|
+
self._stage.container().style.cursor = 'default';
|
|
15898
|
+
}
|
|
15867
15899
|
});
|
|
15868
15900
|
indicator.on('click', function (e) {
|
|
15869
15901
|
self._peaks.emit('lineIndicator.click', self._indicators[lineGroup.getId()], e.evt);
|
|
15870
15902
|
});
|
|
15903
|
+
indicator.on('mousedown touchstart', function () {
|
|
15904
|
+
self._dragLineId = lineGroup.getId();
|
|
15905
|
+
self._dragContainerRect = self._stage.getContainer().getBoundingClientRect();
|
|
15906
|
+
window.addEventListener('mousemove', self._onWindowMove, false);
|
|
15907
|
+
window.addEventListener('touchmove', self._onWindowMove, false);
|
|
15908
|
+
window.addEventListener('mouseup', self._onWindowUp, false);
|
|
15909
|
+
window.addEventListener('touchend', self._onWindowUp, false);
|
|
15910
|
+
window.addEventListener('blur', self._onWindowUp, false);
|
|
15911
|
+
});
|
|
15871
15912
|
return indicator;
|
|
15872
15913
|
};
|
|
15873
15914
|
LineIndicator.prototype.addIndicator = function (lineGroup) {
|
|
@@ -15953,6 +15994,33 @@ module.exports = function (Konva, SVGs, Utils) {
|
|
|
15953
15994
|
LineIndicator.prototype.draw = function () {
|
|
15954
15995
|
this._layer.draw();
|
|
15955
15996
|
};
|
|
15997
|
+
LineIndicator.prototype._onWindowMove = function (event) {
|
|
15998
|
+
if (!this._dragContainerRect) {
|
|
15999
|
+
return;
|
|
16000
|
+
}
|
|
16001
|
+
if (!this._isDragging) {
|
|
16002
|
+
this._stage.container().style.cursor = 'grabbing';
|
|
16003
|
+
}
|
|
16004
|
+
var clientY;
|
|
16005
|
+
if (event.type === 'touchmove') {
|
|
16006
|
+
clientY = Math.floor(event.changedTouches[0].clientY);
|
|
16007
|
+
} else {
|
|
16008
|
+
clientY = event.clientY;
|
|
16009
|
+
}
|
|
16010
|
+
const relY = clientY - this._dragContainerRect.top;
|
|
16011
|
+
this._peaks.emit('lineIndicator.drag', this._dragLineId, relY);
|
|
16012
|
+
};
|
|
16013
|
+
LineIndicator.prototype._onWindowUp = function () {
|
|
16014
|
+
window.removeEventListener('mousemove', this._onWindowMove, false);
|
|
16015
|
+
window.removeEventListener('touchmove', this._onWindowMove, false);
|
|
16016
|
+
window.removeEventListener('mouseup', this._onWindowUp, false);
|
|
16017
|
+
window.removeEventListener('touchend', this._onWindowUp, false);
|
|
16018
|
+
window.removeEventListener('blur', this._onWindowUp, false);
|
|
16019
|
+
this._isDragging = false;
|
|
16020
|
+
this._dragLineId = null;
|
|
16021
|
+
this._dragContainerRect = null;
|
|
16022
|
+
this._stage.container().style.cursor = 'pointer';
|
|
16023
|
+
};
|
|
15956
16024
|
return LineIndicator;
|
|
15957
16025
|
}(_dereq_('konva'), _dereq_('./svgs'), _dereq_('../utils'));
|
|
15958
16026
|
},{"../utils":116,"./svgs":104,"konva":43}],94:[function(_dereq_,module,exports){
|
|
@@ -61,6 +61,8 @@ define([
|
|
|
61
61
|
this._peaks.on('line.heightChanged', this._onLineHeightChanged.bind(this));
|
|
62
62
|
|
|
63
63
|
this._peaks.on('segments.dragend', this._onSegmentUpdated.bind(this));
|
|
64
|
+
|
|
65
|
+
this._peaks.on('lineIndicator.drag', this._onIndicatorDrag.bind(this));
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
LineGroups.prototype.fitToView = function() {
|
|
@@ -563,6 +565,40 @@ define([
|
|
|
563
565
|
return line.id;
|
|
564
566
|
};
|
|
565
567
|
|
|
568
|
+
LineGroups.prototype._onIndicatorDrag = function(lineId, y) {
|
|
569
|
+
const lineGroup = this._lineGroupsById[lineId];
|
|
570
|
+
|
|
571
|
+
if (!lineGroup) {
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
const positions = this.getLinesUnderY(y);
|
|
576
|
+
|
|
577
|
+
if (positions[0] !== positions[1] || positions[0] === lineGroup.getPosition()) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
const targetPos = positions[0];
|
|
582
|
+
const targetLineGroup = this._lineGroupsByPosition[targetPos];
|
|
583
|
+
const targetCenterY = targetLineGroup.y() + (targetLineGroup.lineHeight() / 2);
|
|
584
|
+
const movingDown = targetPos > lineGroup.getPosition();
|
|
585
|
+
|
|
586
|
+
if ((movingDown && y < targetCenterY) || (!movingDown && y > targetCenterY)) {
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
if (targetPos === lineGroup.getPosition() + 1) {
|
|
591
|
+
this._setLinePosition(targetLineGroup.getId(), lineGroup.getPosition());
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
this._setLinePosition(lineId, targetPos);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
this.refreshLineYs();
|
|
598
|
+
|
|
599
|
+
this._peaks.emit('line.moved', lineGroup.getLine());
|
|
600
|
+
};
|
|
601
|
+
|
|
566
602
|
LineGroups.prototype.updateSegments = function(frameStartTime, frameEndTime) {
|
|
567
603
|
for (var lineId in this._segmentsGroups) {
|
|
568
604
|
if (Utils.objectHasProperty(this._segmentsGroups, lineId)) {
|
|
@@ -69,6 +69,13 @@ define([
|
|
|
69
69
|
this._layer.add(this._separatingLine);
|
|
70
70
|
|
|
71
71
|
this._layer.draw();
|
|
72
|
+
|
|
73
|
+
this._isDragging = false;
|
|
74
|
+
this._dragLineId = null;
|
|
75
|
+
this._dragContainerRect = null;
|
|
76
|
+
|
|
77
|
+
this._onWindowMove = this._onWindowMove.bind(this);
|
|
78
|
+
this._onWindowUp = this._onWindowUp.bind(this);
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
LineIndicator.prototype.fitToView = function() {
|
|
@@ -174,13 +181,26 @@ define([
|
|
|
174
181
|
child.fill(child.getAttr('defaultColor'));
|
|
175
182
|
});
|
|
176
183
|
self.draw();
|
|
177
|
-
self.
|
|
184
|
+
if (!self._isDragging) {
|
|
185
|
+
self._stage.container().style.cursor = 'default';
|
|
186
|
+
}
|
|
178
187
|
});
|
|
179
188
|
|
|
180
189
|
indicator.on('click', function(e) {
|
|
181
190
|
self._peaks.emit('lineIndicator.click', self._indicators[lineGroup.getId()], e.evt);
|
|
182
191
|
});
|
|
183
192
|
|
|
193
|
+
indicator.on('mousedown touchstart', function() {
|
|
194
|
+
self._dragLineId = lineGroup.getId();
|
|
195
|
+
self._dragContainerRect = self._stage.getContainer().getBoundingClientRect();
|
|
196
|
+
|
|
197
|
+
window.addEventListener('mousemove', self._onWindowMove, false);
|
|
198
|
+
window.addEventListener('touchmove', self._onWindowMove, false);
|
|
199
|
+
window.addEventListener('mouseup', self._onWindowUp, false);
|
|
200
|
+
window.addEventListener('touchend', self._onWindowUp, false);
|
|
201
|
+
window.addEventListener('blur', self._onWindowUp, false);
|
|
202
|
+
});
|
|
203
|
+
|
|
184
204
|
return indicator;
|
|
185
205
|
};
|
|
186
206
|
|
|
@@ -309,5 +329,42 @@ define([
|
|
|
309
329
|
this._layer.draw();
|
|
310
330
|
};
|
|
311
331
|
|
|
332
|
+
LineIndicator.prototype._onWindowMove = function(event) {
|
|
333
|
+
if (!this._dragContainerRect) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (!this._isDragging) {
|
|
338
|
+
this._stage.container().style.cursor = 'grabbing';
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
var clientY;
|
|
342
|
+
|
|
343
|
+
if (event.type === 'touchmove') {
|
|
344
|
+
clientY = Math.floor(event.changedTouches[0].clientY);
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
clientY = event.clientY;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const relY = clientY - this._dragContainerRect.top;
|
|
351
|
+
|
|
352
|
+
this._peaks.emit('lineIndicator.drag', this._dragLineId, relY);
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
LineIndicator.prototype._onWindowUp = function() {
|
|
356
|
+
window.removeEventListener('mousemove', this._onWindowMove, false);
|
|
357
|
+
window.removeEventListener('touchmove', this._onWindowMove, false);
|
|
358
|
+
window.removeEventListener('mouseup', this._onWindowUp, false);
|
|
359
|
+
window.removeEventListener('touchend', this._onWindowUp, false);
|
|
360
|
+
window.removeEventListener('blur', this._onWindowUp, false);
|
|
361
|
+
|
|
362
|
+
this._isDragging = false;
|
|
363
|
+
this._dragLineId = null;
|
|
364
|
+
this._dragContainerRect = null;
|
|
365
|
+
|
|
366
|
+
this._stage.container().style.cursor = 'pointer';
|
|
367
|
+
};
|
|
368
|
+
|
|
312
369
|
return LineIndicator;
|
|
313
370
|
});
|