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

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