@checksub_team/peaks_timeline 1.9.1-beta.3 → 1.9.1-beta.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checksub_team/peaks_timeline",
3
- "version": "1.9.1-beta.3",
3
+ "version": "1.9.1-beta.4",
4
4
  "description": "JavaScript UI component for displaying audio waveforms",
5
5
  "main": "./peaks.js",
6
6
  "types": "./peaks.js.d.ts",
package/peaks.js CHANGED
@@ -15721,7 +15721,6 @@ module.exports = function (Utils, Source, SourceGroup, Konva) {
15721
15721
  this._playheadLayer = playheadLayer;
15722
15722
  this._stage = stage;
15723
15723
  this._selectedElements = {};
15724
- this._currentLine = null;
15725
15724
  this._layer = new Konva.Layer({ listening: this._mode !== 'default' });
15726
15725
  this._prepareDefaultMode();
15727
15726
  this._onMouseClickInDefaultMode = this._onMouseClickInDefaultMode.bind(this);
@@ -15740,7 +15739,6 @@ module.exports = function (Utils, Source, SourceGroup, Konva) {
15740
15739
  const sources = [];
15741
15740
  const segments = [];
15742
15741
  const self = this;
15743
- this.deselectAll(true);
15744
15742
  elements.forEach(function (element) {
15745
15743
  self._selectedElements[element.id] = element;
15746
15744
  element.setSelected(true);
@@ -16265,6 +16263,7 @@ module.exports = function (Utils, Konva) {
16265
16263
  PlayheadLayer.prototype._onPlayheadDragStart = function () {
16266
16264
  this._view.enableAutoScroll(false);
16267
16265
  this._dragging = true;
16266
+ this._scrollInterval = null;
16268
16267
  };
16269
16268
  PlayheadLayer.prototype._onPlayheadDragEnd = function () {
16270
16269
  this._view.enableAutoScroll(true);
@@ -16501,7 +16500,14 @@ module.exports = function (Konva, SegmentMarker, Utils) {
16501
16500
  });
16502
16501
  this._shapeGroup.add(this._rectangle);
16503
16502
  this._shapeGroup.dragBoundFunc(function () {
16504
- return self._onShapeGroupDrag(this);
16503
+ var diff = self._view.getPointerPosition().x - self._mouseDownX;
16504
+ self._group.updateSegment(self._segment, self._initialStartPixel + diff, self._initialEndPixel + diff);
16505
+ self._startMarker.timeUpdated(self._segment.startTime);
16506
+ self._endMarker.timeUpdated(self._segment.endTime);
16507
+ return {
16508
+ x: this.absolutePosition().x,
16509
+ y: this.absolutePosition().y
16510
+ };
16505
16511
  });
16506
16512
  this._shapeGroup.on('mouseenter', this._onMouseEnter.bind(this));
16507
16513
  this._shapeGroup.on('mouseleave', this._onMouseLeave.bind(this));
@@ -16526,16 +16532,6 @@ module.exports = function (Konva, SegmentMarker, Utils) {
16526
16532
  this._shapeGroup.add(this._indicatorsGroup);
16527
16533
  this.createIndicators();
16528
16534
  }
16529
- SegmentShape.prototype._onShapeGroupDrag = function (draggedElement) {
16530
- const diff = this._view.getPointerPosition().x - this._mouseDownX;
16531
- this._group.updateSegment(this._segment, this._initialStartPixel + diff, this._initialEndPixel + diff);
16532
- this._startMarker.timeUpdated(this._segment.startTime);
16533
- this._endMarker.timeUpdated(this._segment.endTime);
16534
- return {
16535
- x: draggedElement.absolutePosition().x,
16536
- y: draggedElement.absolutePosition().y
16537
- };
16538
- };
16539
16535
  SegmentShape.prototype._cornerRadius = function () {
16540
16536
  return this._segment.borderRadius !== undefined && this._segment.borderRadius !== null ? this._segment.borderRadius : SEGMENT_CORNER_RADIUS;
16541
16537
  };
@@ -17638,7 +17634,17 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17638
17634
  this._wrappedHeight = this._peaks.options.wrappedLineHeight;
17639
17635
  this._borderWidth = this._source.borderWidth;
17640
17636
  this._previewList = [];
17641
- this._group = new Konva.Group({ x: this._x });
17637
+ this._group = new Konva.Group({
17638
+ x: this._x,
17639
+ draggable: this._source.draggable,
17640
+ dragBoundFunc: function () {
17641
+ return {
17642
+ x: this.absolutePosition().x,
17643
+ y: this.absolutePosition().y
17644
+ };
17645
+ }
17646
+ });
17647
+ this._group.on('dragstart', this._onSourceGroupDragStart.bind(this));
17642
17648
  this._group.on('mouseover', function () {
17643
17649
  self._view.setHoveredElement(self);
17644
17650
  if (self._view.getCurrentMode() === 'cut') {
@@ -17653,6 +17659,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17653
17659
  self.toggleResizing(true);
17654
17660
  }
17655
17661
  });
17662
+ this._group.on('dragend', this._onSourceGroupDragEnd.bind(this));
17656
17663
  this._group.add(new Konva.Group());
17657
17664
  if (this._borderWidth) {
17658
17665
  this._border = new Konva.Shape({
@@ -17670,30 +17677,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17670
17677
  this._group.add(this._indicatorsGroup);
17671
17678
  this.createIndicators();
17672
17679
  }
17673
- SourceGroup.prototype.setDraggingParent = function () {
17674
- if (this._source.draggable) {
17675
- const self = this;
17676
- if (this._draggingParent) {
17677
- this._draggingParent.setAttrs({
17678
- draggable: this._source.draggable,
17679
- dragBoundFunc: function () {
17680
- return self._onSourceGroupDrag(this);
17681
- }
17682
- });
17683
- this._draggingParent.on('dragstart', this._onSourceGroupDragStart.bind(this));
17684
- this._draggingParent.on('dragend', this._onSourceGroupDragEnd.bind(this));
17685
- } else {
17686
- this._group.setAttrs({
17687
- draggable: this._source.draggable,
17688
- dragBoundFunc: function () {
17689
- return self._onSourceGroupDrag(this);
17690
- }
17691
- });
17692
- this._group.on('dragstart', this._onSourceGroupDragStart.bind(this));
17693
- this._group.on('dragend', this._onSourceGroupDragEnd.bind(this));
17694
- }
17695
- }
17696
- };
17697
17680
  SourceGroup.prototype._onSourceGroupDragStart = function () {
17698
17681
  this._dragged = true;
17699
17682
  this._mouseDownX = this._view.getPointerPosition().x;
@@ -17713,17 +17696,17 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17713
17696
  this._view.updateTimelineLength();
17714
17697
  this._peaks.emit('sources.updated', [this._source]);
17715
17698
  };
17716
- SourceGroup.prototype._updateSourceGroup = function () {
17717
- var mousePos = Math.min(this._view.getWidth() - this._peaks.options.autoScrollThreshold * this._view.getWidth(), Math.max(0, this._view.getPointerPosition().x));
17718
- var diff = mousePos - this._mouseDownX;
17719
- this._layer.updateSource(this._source, this._initialStartPixel + diff + (this._view.getFrameOffset() - this._initialFrameOffset), this._initialEndPixel + diff + (this._view.getFrameOffset() - this._initialFrameOffset), this._view.getPointerPosition().y);
17720
- this._view.setTimelineLength(this._view.timeToPixels(this._source.endTime) + this._view.getWidth());
17721
- };
17722
17699
  SourceGroup.prototype._onSourceGroupDrag = function (draggedElement) {
17723
- this._view.updateWithAutoScroll(this._updateSourceGroup.bind(this));
17700
+ var self = this;
17701
+ var pos = this._view.updateWithAutoScroll(draggedElement, function () {
17702
+ var mousePos = Math.min(self._view.getWidth() - self._peaks.options.autoScrollThreshold * self._view.getWidth(), Math.max(0, self._view.getPointerPosition().x));
17703
+ var diff = mousePos - self._mouseDownX;
17704
+ self._layer.updateSource(self._source, self._initialStartPixel + diff + (self._view.getFrameOffset() - self._initialFrameOffset), self._initialEndPixel + diff + (self._view.getFrameOffset() - self._initialFrameOffset), self._view.getPointerPosition().y);
17705
+ self._view.setTimelineLength(self._view.timeToPixels(self._source.endTime) + self._view.getWidth());
17706
+ });
17724
17707
  return {
17725
- x: draggedElement.absolutePosition().x,
17726
- y: draggedElement.absolutePosition().y
17708
+ x: pos.x,
17709
+ y: pos.y
17727
17710
  };
17728
17711
  };
17729
17712
  SourceGroup.prototype._onSourceGroupHandleDrag = function (draggedElement, dragPos, leftHandle) {
@@ -17788,6 +17771,12 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17788
17771
  }
17789
17772
  });
17790
17773
  if (this._source.resizable) {
17774
+ this._leftHandle.on('dragend', function () {
17775
+ if (this._scrollingInterval) {
17776
+ clearInterval(this._scrollingInterval);
17777
+ this._scrollingInterval = null;
17778
+ }
17779
+ });
17791
17780
  this._leftHandle.on('mouseover', function () {
17792
17781
  self._view.setCursor('ew-resize');
17793
17782
  });
@@ -17808,6 +17797,12 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17808
17797
  }
17809
17798
  });
17810
17799
  if (this._source.resizable) {
17800
+ this._rightHandle.on('dragend', function () {
17801
+ if (this._scrollingInterval) {
17802
+ clearInterval(this._scrollingInterval);
17803
+ this._scrollingInterval = null;
17804
+ }
17805
+ });
17811
17806
  this._rightHandle.on('mouseover', function () {
17812
17807
  self._view.setCursor('ew-resize');
17813
17808
  });
@@ -17878,6 +17873,13 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17878
17873
  var unwrap = new Konva.Group({
17879
17874
  width: this._width,
17880
17875
  height: this._unwrappedHeight,
17876
+ draggable: this._source.draggable,
17877
+ dragBoundFunc: function () {
17878
+ return {
17879
+ x: this.absolutePosition().x,
17880
+ y: this.absolutePosition().y
17881
+ };
17882
+ },
17881
17883
  clipFunc: function (ctx) {
17882
17884
  self.drawSourceShape(ctx, null, true);
17883
17885
  }
@@ -17889,12 +17891,25 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17889
17891
  unwrap.on('mouseout', function () {
17890
17892
  self._view.setCursor('default');
17891
17893
  });
17894
+ unwrap.on('dragstart', function () {
17895
+ this._scrollInterval = null;
17896
+ });
17897
+ unwrap.on('dragend', function () {
17898
+ if (this._scrollingInterval) {
17899
+ clearInterval(this._scrollingInterval);
17900
+ this._scrollingInterval = null;
17901
+ }
17902
+ });
17892
17903
  }
17893
17904
  var background = new Konva.Group();
17894
17905
  background.add(new Konva.Shape({
17895
17906
  fill: this._source.backgroundColor,
17896
17907
  sceneFunc: function (ctx, shape) {
17897
17908
  self.drawSourceShape(ctx, shape, true);
17909
+ },
17910
+ draggable: this._source.draggable,
17911
+ dragBoundFunc: function () {
17912
+ return self._onSourceGroupDrag(this);
17898
17913
  }
17899
17914
  }));
17900
17915
  unwrap.add(background);
@@ -17924,6 +17939,13 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17924
17939
  var wrap = new Konva.Group({
17925
17940
  width: this._width,
17926
17941
  height: this._wrappedHeight,
17942
+ draggable: this._source.draggable,
17943
+ dragBoundFunc: function () {
17944
+ return {
17945
+ x: this.absolutePosition().x,
17946
+ y: this.absolutePosition().y
17947
+ };
17948
+ },
17927
17949
  clipFunc: function (ctx) {
17928
17950
  self.drawSourceShape(ctx, null, true);
17929
17951
  }
@@ -17935,12 +17957,25 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17935
17957
  wrap.on('mouseout', function () {
17936
17958
  self._view.setCursor('default');
17937
17959
  });
17960
+ wrap.on('dragstart', function () {
17961
+ this._scrollInterval = null;
17962
+ });
17963
+ wrap.on('dragend', function () {
17964
+ if (this._scrollingInterval) {
17965
+ clearInterval(this._scrollingInterval);
17966
+ this._scrollingInterval = null;
17967
+ }
17968
+ });
17938
17969
  }
17939
17970
  var background = new Konva.Group();
17940
17971
  background.add(new Konva.Shape({
17941
17972
  fill: this._source.backgroundColor,
17942
17973
  sceneFunc: function (ctx, shape) {
17943
17974
  self.drawSourceShape(ctx, shape, true);
17975
+ },
17976
+ draggable: this._source.draggable,
17977
+ dragBoundFunc: function () {
17978
+ return self._onSourceGroupDrag(this);
17944
17979
  }
17945
17980
  }));
17946
17981
  wrap.add(background);
@@ -18214,7 +18249,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18214
18249
  }
18215
18250
  }
18216
18251
  }
18217
- this.setDraggingParent();
18218
18252
  };
18219
18253
  SourceGroup.prototype.updatePreviews = function () {
18220
18254
  var self = this;
@@ -18324,9 +18358,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18324
18358
  SourceGroup.prototype.destroy = function () {
18325
18359
  this._group.destroy();
18326
18360
  };
18327
- SourceGroup.prototype.getLine = function () {
18328
- return this._source.position;
18329
- };
18330
18361
  SourceGroup.prototype.createIndicators = function () {
18331
18362
  var newIndicatorsColors = this._source.indicators;
18332
18363
  var oldIndicators = this._indicators;
@@ -20106,9 +20137,6 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
20106
20137
  });
20107
20138
  this._stage.on('wheel', function (e) {
20108
20139
  e.evt.preventDefault();
20109
- if (self._mouseDragHandler.isDragging()) {
20110
- return;
20111
- }
20112
20140
  if (self._peaks.keyboardHandler.isCtrlCmdPressed()) {
20113
20141
  if (e.evt.deltaY > 0) {
20114
20142
  self.setZoom(self.getTimeToPixelsScale() + Math.floor(self.getTimeToPixelsScale() / 10) + 1);
@@ -20135,55 +20163,46 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
20135
20163
  }
20136
20164
  }
20137
20165
  });
20138
- window.addEventListener('mouseup', this._mouseUp.bind(this), false);
20139
- window.addEventListener('touchend', this._mouseUp.bind(this), false);
20140
- window.addEventListener('blur', this._mouseUp.bind(this), false);
20141
20166
  }
20142
- TimelineZoomView.prototype._mouseUp = function () {
20143
- this.clearScrollingInterval();
20144
- };
20145
- TimelineZoomView.prototype._createElementGroup = function () {
20146
- this._selectedGroup = new Konva.Group({ listening: false });
20147
- this._layer.add(this._selectedGroup);
20148
- };
20149
- TimelineZoomView.prototype.updateWithAutoScroll = function (updateInInterval, updateOutInterval) {
20167
+ TimelineZoomView.prototype.updateWithAutoScroll = function (obj, updateInInterval, updateOutInterval) {
20150
20168
  var self = this;
20151
20169
  var posX = this.getPointerPosition().x;
20152
20170
  var threshold = Math.round(this._peaks.options.autoScrollThreshold * this.getWidth());
20153
- this._limited = 0;
20171
+ obj._limited = 0;
20154
20172
  if (posX < threshold) {
20155
- this._limited = Math.round(-30 * Math.min(1, (threshold - posX) / threshold));
20173
+ obj._limited = Math.round(-30 * Math.min(1, (threshold - posX) / threshold));
20156
20174
  } else if (posX > this.getWidth() - threshold) {
20157
- this._limited = Math.round(30 * Math.min(1, (posX - (this.getWidth() - threshold)) / threshold));
20175
+ obj._limited = Math.round(30 * Math.min(1, (posX - (this.getWidth() - threshold)) / threshold));
20158
20176
  }
20159
- if (this._limited && self.getFrameOffset() > 0 || this._limited > 0) {
20160
- if (!this._scrollingInterval) {
20161
- this._scrollingInterval = setInterval(function () {
20162
- var newOffset = self.getFrameOffset() + self._limited;
20177
+ if (obj._limited && self.getFrameOffset() > 0 || obj._limited > 0) {
20178
+ if (!obj._scrollingInterval) {
20179
+ obj._scrollingInterval = setInterval(function () {
20180
+ var newOffset = self.getFrameOffset() + obj._limited;
20163
20181
  if (newOffset < 0) {
20164
20182
  self.updateTimeline(0, null, false);
20165
- clearInterval(self._scrollingInterval);
20166
- self._scrollingInterval = null;
20183
+ clearInterval(obj._scrollingInterval);
20184
+ obj._scrollingInterval = null;
20167
20185
  } else {
20168
- self.updateTimeline(self.getFrameOffset() + self._limited, null, false);
20186
+ self.updateTimeline(self.getFrameOffset() + obj._limited, null, false);
20169
20187
  }
20170
20188
  updateInInterval();
20171
20189
  }, 10);
20172
20190
  }
20173
20191
  } else {
20174
- this.clearScrollingInterval();
20192
+ if (obj._scrollingInterval) {
20193
+ clearInterval(obj._scrollingInterval);
20194
+ obj._scrollingInterval = null;
20195
+ }
20175
20196
  if (updateOutInterval) {
20176
20197
  updateOutInterval();
20177
20198
  } else {
20178
20199
  updateInInterval();
20179
20200
  }
20180
20201
  }
20181
- };
20182
- TimelineZoomView.prototype.clearScrollingInterval = function () {
20183
- if (this._scrollingInterval) {
20184
- clearInterval(this._scrollingInterval);
20185
- this._scrollingInterval = null;
20186
- }
20202
+ return {
20203
+ x: obj.absolutePosition().x,
20204
+ y: obj.absolutePosition().y
20205
+ };
20187
20206
  };
20188
20207
  TimelineZoomView.prototype.getCurrentMode = function () {
20189
20208
  return this._modeLayer.getCurrentMode();
@@ -20202,7 +20221,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
20202
20221
  TimelineZoomView.prototype.selectSourceById = function (sourceId) {
20203
20222
  const sourceGroup = this._sourcesLayer.getSourceGroupById(sourceId);
20204
20223
  if (sourceGroup) {
20205
- this._modeLayer.selectElement(sourceGroup, false);
20224
+ this._modeLayer.selectElements([sourceGroup.getSource()], false);
20206
20225
  }
20207
20226
  };
20208
20227
  TimelineZoomView.prototype.selectSourcesOnLineAfter = function (lineId, time) {
package/src/mode-layer.js CHANGED
@@ -36,7 +36,6 @@ define([
36
36
  this._stage = stage;
37
37
 
38
38
  this._selectedElements = {};
39
- this._currentLine = null;
40
39
 
41
40
  this._layer = new Konva.Layer({
42
41
  listening: this._mode !== 'default'
@@ -72,8 +71,6 @@ define([
72
71
  const segments = [];
73
72
  const self = this;
74
73
 
75
- this.deselectAll(true);
76
-
77
74
  elements.forEach(function(element) {
78
75
  self._selectedElements[element.id] = element;
79
76
  element.setSelected(true);
@@ -86,7 +83,6 @@ define([
86
83
  }
87
84
  }
88
85
  });
89
-
90
86
  if (notify) {
91
87
  if (sources.length) {
92
88
  this._peaks.emit('sources.selected', sources);
@@ -117,7 +113,6 @@ define([
117
113
  delete this._selectedElements[id];
118
114
  }
119
115
  }
120
-
121
116
  if (notify) {
122
117
  if (sources.length) {
123
118
  this._peaks.emit('sources.deselected', sources);
@@ -180,6 +180,7 @@ define([
180
180
  PlayheadLayer.prototype._onPlayheadDragStart = function() {
181
181
  this._view.enableAutoScroll(false);
182
182
  this._dragging = true;
183
+ this._scrollInterval = null;
183
184
  };
184
185
 
185
186
  PlayheadLayer.prototype._onPlayheadDragEnd = function() {
@@ -88,7 +88,20 @@ define([
88
88
  this._shapeGroup.add(this._rectangle);
89
89
 
90
90
  this._shapeGroup.dragBoundFunc(function() {
91
- return self._onShapeGroupDrag(this);
91
+ var diff = self._view.getPointerPosition().x - self._mouseDownX;
92
+
93
+ self._group.updateSegment(
94
+ self._segment,
95
+ self._initialStartPixel + diff, self._initialEndPixel + diff
96
+ );
97
+
98
+ self._startMarker.timeUpdated(self._segment.startTime);
99
+ self._endMarker.timeUpdated(self._segment.endTime);
100
+
101
+ return {
102
+ x: this.absolutePosition().x,
103
+ y: this.absolutePosition().y
104
+ };
92
105
  });
93
106
 
94
107
  // Set up event handlers to show/hide the segment label text when the user
@@ -124,23 +137,6 @@ define([
124
137
  this.createIndicators();
125
138
  }
126
139
 
127
- SegmentShape.prototype._onShapeGroupDrag = function(draggedElement) {
128
- const diff = this._view.getPointerPosition().x - this._mouseDownX;
129
-
130
- this._group.updateSegment(
131
- this._segment,
132
- this._initialStartPixel + diff, this._initialEndPixel + diff
133
- );
134
-
135
- this._startMarker.timeUpdated(this._segment.startTime);
136
- this._endMarker.timeUpdated(this._segment.endTime);
137
-
138
- return {
139
- x: draggedElement.absolutePosition().x,
140
- y: draggedElement.absolutePosition().y
141
- };
142
- };
143
-
144
140
  SegmentShape.prototype._cornerRadius = function() {
145
141
  return this._segment.borderRadius !== undefined && this._segment.borderRadius !== null ?
146
142
  this._segment.borderRadius :
@@ -57,9 +57,17 @@ define([
57
57
  this._previewList = [];
58
58
 
59
59
  this._group = new Konva.Group({
60
- x: this._x
60
+ x: this._x,
61
+ draggable: this._source.draggable,
62
+ dragBoundFunc: function() {
63
+ return {
64
+ x: this.absolutePosition().x,
65
+ y: this.absolutePosition().y
66
+ };
67
+ }
61
68
  });
62
69
 
70
+ this._group.on('dragstart', this._onSourceGroupDragStart.bind(this));
63
71
  this._group.on('mouseover', function() {
64
72
  self._view.setHoveredElement(self);
65
73
  if (self._view.getCurrentMode() === 'cut') {
@@ -74,6 +82,7 @@ define([
74
82
  self.toggleResizing(true);
75
83
  }
76
84
  });
85
+ this._group.on('dragend', this._onSourceGroupDragEnd.bind(this));
77
86
 
78
87
  this._group.add(new Konva.Group());
79
88
 
@@ -116,36 +125,6 @@ define([
116
125
  // });
117
126
  // };
118
127
 
119
- SourceGroup.prototype.setDraggingParent = function() {
120
- if (this._source.draggable) {
121
- const self = this;
122
-
123
- // this._draggingParent = this._source._selected ?
124
- // this._layer.getSelectedGroup() :
125
- // null;
126
- if (this._draggingParent) {
127
- this._draggingParent.setAttrs({
128
- draggable: this._source.draggable,
129
- dragBoundFunc: function() {
130
- return self._onSourceGroupDrag(this);
131
- }
132
- });
133
- this._draggingParent.on('dragstart', this._onSourceGroupDragStart.bind(this));
134
- this._draggingParent.on('dragend', this._onSourceGroupDragEnd.bind(this));
135
- }
136
- else {
137
- this._group.setAttrs({
138
- draggable: this._source.draggable,
139
- dragBoundFunc: function() {
140
- return self._onSourceGroupDrag(this);
141
- }
142
- });
143
- this._group.on('dragstart', this._onSourceGroupDragStart.bind(this));
144
- this._group.on('dragend', this._onSourceGroupDragEnd.bind(this));
145
- }
146
- }
147
- };
148
-
149
128
  SourceGroup.prototype._onSourceGroupDragStart = function() {
150
129
  this._dragged = true;
151
130
  this._mouseDownX = this._view.getPointerPosition().x;
@@ -171,35 +150,38 @@ define([
171
150
  this._peaks.emit('sources.updated', [this._source]);
172
151
  };
173
152
 
174
- SourceGroup.prototype._updateSourceGroup = function() {
175
- var mousePos = Math.min(
176
- this._view.getWidth() - this._peaks.options.autoScrollThreshold * this._view.getWidth(),
177
- Math.max(
178
- 0,
179
- this._view.getPointerPosition().x
180
- )
181
- );
153
+ SourceGroup.prototype._onSourceGroupDrag = function(draggedElement) {
154
+ var self = this;
182
155
 
183
- var diff = mousePos - this._mouseDownX;
156
+ var pos = this._view.updateWithAutoScroll(
157
+ draggedElement,
158
+ function() {
159
+ var mousePos = Math.min(
160
+ self._view.getWidth() - self._peaks.options.autoScrollThreshold * self._view.getWidth(),
161
+ Math.max(
162
+ 0,
163
+ self._view.getPointerPosition().x
164
+ )
165
+ );
184
166
 
185
- this._layer.updateSource(
186
- this._source,
187
- this._initialStartPixel + diff + (this._view.getFrameOffset() - this._initialFrameOffset),
188
- this._initialEndPixel + diff + (this._view.getFrameOffset() - this._initialFrameOffset),
189
- this._view.getPointerPosition().y
190
- );
167
+ var diff = mousePos - self._mouseDownX;
191
168
 
192
- this._view.setTimelineLength(
193
- this._view.timeToPixels(this._source.endTime) + this._view.getWidth()
194
- );
195
- };
169
+ self._layer.updateSource(
170
+ self._source,
171
+ self._initialStartPixel + diff + (self._view.getFrameOffset() - self._initialFrameOffset),
172
+ self._initialEndPixel + diff + (self._view.getFrameOffset() - self._initialFrameOffset),
173
+ self._view.getPointerPosition().y
174
+ );
196
175
 
197
- SourceGroup.prototype._onSourceGroupDrag = function(draggedElement) {
198
- this._view.updateWithAutoScroll(this._updateSourceGroup.bind(this));
176
+ self._view.setTimelineLength(
177
+ self._view.timeToPixels(self._source.endTime) + self._view.getWidth()
178
+ );
179
+ }
180
+ );
199
181
 
200
182
  return {
201
- x: draggedElement.absolutePosition().x,
202
- y: draggedElement.absolutePosition().y
183
+ x: pos.x,
184
+ y: pos.y
203
185
  };
204
186
  };
205
187
 
@@ -293,6 +275,13 @@ define([
293
275
  });
294
276
 
295
277
  if (this._source.resizable) {
278
+ this._leftHandle.on('dragend', function() {
279
+ if (this._scrollingInterval) {
280
+ clearInterval(this._scrollingInterval);
281
+ this._scrollingInterval = null;
282
+ }
283
+ });
284
+
296
285
  this._leftHandle.on('mouseover', function() {
297
286
  self._view.setCursor('ew-resize');
298
287
  });
@@ -316,6 +305,13 @@ define([
316
305
  });
317
306
 
318
307
  if (this._source.resizable) {
308
+ this._rightHandle.on('dragend', function() {
309
+ if (this._scrollingInterval) {
310
+ clearInterval(this._scrollingInterval);
311
+ this._scrollingInterval = null;
312
+ }
313
+ });
314
+
319
315
  this._rightHandle.on('mouseover', function() {
320
316
  self._view.setCursor('ew-resize');
321
317
  });
@@ -425,6 +421,13 @@ define([
425
421
  var unwrap = new Konva.Group({
426
422
  width: this._width,
427
423
  height: this._unwrappedHeight,
424
+ draggable: this._source.draggable,
425
+ dragBoundFunc: function() {
426
+ return {
427
+ x: this.absolutePosition().x,
428
+ y: this.absolutePosition().y
429
+ };
430
+ },
428
431
  clipFunc: function(ctx) {
429
432
  self.drawSourceShape(ctx, null, true);
430
433
  }
@@ -437,6 +440,17 @@ define([
437
440
  unwrap.on('mouseout', function() {
438
441
  self._view.setCursor('default');
439
442
  });
443
+
444
+ unwrap.on('dragstart', function() {
445
+ this._scrollInterval = null;
446
+ });
447
+
448
+ unwrap.on('dragend', function() {
449
+ if (this._scrollingInterval) {
450
+ clearInterval(this._scrollingInterval);
451
+ this._scrollingInterval = null;
452
+ }
453
+ });
440
454
  }
441
455
 
442
456
  var background = new Konva.Group();
@@ -445,6 +459,10 @@ define([
445
459
  fill: this._source.backgroundColor,
446
460
  sceneFunc: function(ctx, shape) {
447
461
  self.drawSourceShape(ctx, shape, true);
462
+ },
463
+ draggable: this._source.draggable,
464
+ dragBoundFunc: function() {
465
+ return self._onSourceGroupDrag(this);
448
466
  }
449
467
  }));
450
468
 
@@ -483,6 +501,13 @@ define([
483
501
  var wrap = new Konva.Group({
484
502
  width: this._width,
485
503
  height: this._wrappedHeight,
504
+ draggable: this._source.draggable,
505
+ dragBoundFunc: function() {
506
+ return {
507
+ x: this.absolutePosition().x,
508
+ y: this.absolutePosition().y
509
+ };
510
+ },
486
511
  clipFunc: function(ctx) {
487
512
  self.drawSourceShape(ctx, null, true);
488
513
  }
@@ -495,6 +520,17 @@ define([
495
520
  wrap.on('mouseout', function() {
496
521
  self._view.setCursor('default');
497
522
  });
523
+
524
+ wrap.on('dragstart', function() {
525
+ this._scrollInterval = null;
526
+ });
527
+
528
+ wrap.on('dragend', function() {
529
+ if (this._scrollingInterval) {
530
+ clearInterval(this._scrollingInterval);
531
+ this._scrollingInterval = null;
532
+ }
533
+ });
498
534
  }
499
535
 
500
536
  var background = new Konva.Group();
@@ -503,6 +539,10 @@ define([
503
539
  fill: this._source.backgroundColor,
504
540
  sceneFunc: function(ctx, shape) {
505
541
  self.drawSourceShape(ctx, shape, true);
542
+ },
543
+ draggable: this._source.draggable,
544
+ dragBoundFunc: function() {
545
+ return self._onSourceGroupDrag(this);
506
546
  }
507
547
  }));
508
548
 
@@ -859,7 +899,6 @@ define([
859
899
  }
860
900
  }
861
901
  }
862
- this.setDraggingParent();
863
902
  };
864
903
 
865
904
  SourceGroup.prototype.updatePreviews = function() {
@@ -1009,10 +1048,6 @@ define([
1009
1048
  this._group.destroy();
1010
1049
  };
1011
1050
 
1012
- SourceGroup.prototype.getLine = function() {
1013
- return this._source.position;
1014
- };
1015
-
1016
1051
  SourceGroup.prototype.createIndicators = function() {
1017
1052
  var newIndicatorsColors = this._source.indicators;
1018
1053
 
@@ -241,10 +241,6 @@ define([
241
241
  // prevent parent scrolling
242
242
  e.evt.preventDefault();
243
243
 
244
- if (self._mouseDragHandler.isDragging()) {
245
- return;
246
- }
247
-
248
244
  if (self._peaks.keyboardHandler.isCtrlCmdPressed()) {
249
245
  if (e.evt.deltaY > 0) {
250
246
  self.setZoom(
@@ -292,54 +288,38 @@ define([
292
288
  }
293
289
  }
294
290
  });
295
-
296
- window.addEventListener('mouseup', this._mouseUp.bind(this), false);
297
- window.addEventListener('touchend', this._mouseUp.bind(this), false);
298
- window.addEventListener('blur', this._mouseUp.bind(this), false);
299
291
  }
300
292
 
301
- TimelineZoomView.prototype._mouseUp = function() {
302
- this.clearScrollingInterval();
303
- };
304
-
305
- TimelineZoomView.prototype._createElementGroup = function() {
306
- this._selectedGroup = new Konva.Group({
307
- listening: false
308
- });
309
-
310
- this._layer.add(this._selectedGroup);
311
- };
312
-
313
- TimelineZoomView.prototype.updateWithAutoScroll = function(updateInInterval,
293
+ TimelineZoomView.prototype.updateWithAutoScroll = function(obj, updateInInterval,
314
294
  updateOutInterval) {
315
295
  var self = this;
316
296
  var posX = this.getPointerPosition().x;
317
297
  var threshold = Math.round(this._peaks.options.autoScrollThreshold * this.getWidth());
318
298
 
319
- this._limited = 0;
299
+ obj._limited = 0;
320
300
 
321
301
  if (posX < threshold) {
322
- this._limited = Math.round(-30 * Math.min(1, (threshold - posX) / threshold));
302
+ obj._limited = Math.round(-30 * Math.min(1, (threshold - posX) / threshold));
323
303
  }
324
304
  else if (posX > this.getWidth() - threshold) {
325
- this._limited = Math.round(
305
+ obj._limited = Math.round(
326
306
  30 * Math.min(1, (posX - (this.getWidth() - threshold)) / threshold)
327
307
  );
328
308
  }
329
309
 
330
- if (this._limited && self.getFrameOffset() > 0 || this._limited > 0) {
331
- if (!this._scrollingInterval) {
332
- this._scrollingInterval = setInterval(
310
+ if (obj._limited && self.getFrameOffset() > 0 || obj._limited > 0) {
311
+ if (!obj._scrollingInterval) {
312
+ obj._scrollingInterval = setInterval(
333
313
  function() {
334
- var newOffset = self.getFrameOffset() + self._limited;
314
+ var newOffset = self.getFrameOffset() + obj._limited;
335
315
 
336
316
  if (newOffset < 0) {
337
317
  self.updateTimeline(0, null, false);
338
- clearInterval(self._scrollingInterval);
339
- self._scrollingInterval = null;
318
+ clearInterval(obj._scrollingInterval);
319
+ obj._scrollingInterval = null;
340
320
  }
341
321
  else {
342
- self.updateTimeline(self.getFrameOffset() + self._limited, null, false);
322
+ self.updateTimeline(self.getFrameOffset() + obj._limited, null, false);
343
323
  }
344
324
 
345
325
  updateInInterval();
@@ -349,7 +329,10 @@ define([
349
329
  }
350
330
  }
351
331
  else {
352
- this.clearScrollingInterval();
332
+ if (obj._scrollingInterval) {
333
+ clearInterval(obj._scrollingInterval);
334
+ obj._scrollingInterval = null;
335
+ }
353
336
 
354
337
  if (updateOutInterval) {
355
338
  updateOutInterval();
@@ -358,13 +341,11 @@ define([
358
341
  updateInInterval();
359
342
  }
360
343
  }
361
- };
362
344
 
363
- TimelineZoomView.prototype.clearScrollingInterval = function() {
364
- if (this._scrollingInterval) {
365
- clearInterval(this._scrollingInterval);
366
- this._scrollingInterval = null;
367
- }
345
+ return {
346
+ x: obj.absolutePosition().x,
347
+ y: obj.absolutePosition().y
348
+ };
368
349
  };
369
350
 
370
351
  TimelineZoomView.prototype.getCurrentMode = function() {
@@ -388,7 +369,7 @@ define([
388
369
  const sourceGroup = this._sourcesLayer.getSourceGroupById(sourceId);
389
370
 
390
371
  if (sourceGroup) {
391
- this._modeLayer.selectElement(sourceGroup, false);
372
+ this._modeLayer.selectElements([sourceGroup.getSource()], false);
392
373
  }
393
374
  };
394
375