@checksub_team/peaks_timeline 1.5.5 → 1.5.7

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.5.5",
3
+ "version": "1.5.7",
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
@@ -14155,7 +14155,7 @@ module.exports = function (Utils, Konva) {
14155
14155
  };
14156
14156
  return DefaultSegmentMarker;
14157
14157
  }(_dereq_('./utils'), _dereq_('konva'));
14158
- },{"./utils":111,"konva":43}],89:[function(_dereq_,module,exports){
14158
+ },{"./utils":112,"konva":43}],89:[function(_dereq_,module,exports){
14159
14159
  module.exports = function () {
14160
14160
  'use strict';
14161
14161
  function Invoker() {
@@ -14288,7 +14288,7 @@ module.exports = function () {
14288
14288
  return KeyboardHandler;
14289
14289
  }();
14290
14290
  },{}],91:[function(_dereq_,module,exports){
14291
- module.exports = function (Konva, Utils) {
14291
+ module.exports = function (Konva, Utils, SVGs) {
14292
14292
  'use strict';
14293
14293
  function LineIndicator(peaks, view, container) {
14294
14294
  this._peaks = peaks;
@@ -14296,7 +14296,10 @@ module.exports = function (Konva, Utils) {
14296
14296
  this._container = container;
14297
14297
  this._width = this._peaks.options.lineIndicatorWidth;
14298
14298
  this._height = this._view.getHeight();
14299
- this._indicatorRadius = this._width / 4;
14299
+ this._iconSize = this._peaks.options.lineIndicatorIconSize;
14300
+ this._fontSize = this._peaks.options.lineIndicatorFontSize;
14301
+ this._defaultPadding = 5;
14302
+ this._types = ['default'].concat(Object.keys(SVGs));
14300
14303
  this._stage = new Konva.Stage({
14301
14304
  container: container,
14302
14305
  width: this._width,
@@ -14321,15 +14324,7 @@ module.exports = function (Konva, Utils) {
14321
14324
  if (this._peaks.options.enableLineIndicatorContextMenu) {
14322
14325
  this._createContextMenu();
14323
14326
  }
14324
- this.ICON_SIZE = 18;
14325
- 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';
14326
- 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';
14327
14327
  this._peaks.on('lineIndicator.setType', this._onSetType.bind(this));
14328
- this._types = [
14329
- 'default',
14330
- 'volume',
14331
- 'noVolume'
14332
- ];
14333
14328
  }
14334
14329
  LineIndicator.prototype.fitToView = function () {
14335
14330
  this._height = this._view.getHeight();
@@ -14357,38 +14352,53 @@ module.exports = function (Konva, Utils) {
14357
14352
  menu.style.left = containerRect.left + this._stage.getPointerPosition().x + 6 + 'px';
14358
14353
  };
14359
14354
  LineIndicator.prototype._createIndicator = function (line, type) {
14360
- var indicator;
14361
- type = typeof type !== 'undefined' ? type : 'default';
14355
+ var indicator = new Konva.Group();
14356
+ var text = new Konva.Text({
14357
+ text: 'This is just a test',
14358
+ fontSize: this._fontSize,
14359
+ fontFamily: 'Arial',
14360
+ fill: this._peaks.options.lineIndicatorColor,
14361
+ align: 'center',
14362
+ width: this._width
14363
+ });
14364
+ type = this._types.includes(type) ? type : 'default';
14365
+ var icon;
14362
14366
  if (type === 'default') {
14363
- indicator = new Konva.Circle({
14367
+ icon = new Konva.Circle({
14364
14368
  x: this._width / 2,
14365
- y: line.getY() + line.lineHeight() / 2,
14366
- radius: this._indicatorRadius,
14369
+ y: this._fontSize + this._iconSize / 2 + this._defaultPadding,
14370
+ radius: this._iconSize / 2,
14367
14371
  fill: this._peaks.options.lineIndicatorColor,
14368
14372
  strokeWidth: 0,
14369
14373
  lineId: line.getId()
14370
14374
  });
14371
14375
  } else {
14372
- var scaleFactor = this._width / 2 / this.ICON_SIZE;
14373
- indicator = new Konva.Path({
14374
- x: this._width / 4,
14375
- y: line.getY() + line.lineHeight() / 2 - this._width / 4,
14376
- data: type === 'volume' ? this._volumeSVGPath : this._noVolumeSVGPath,
14376
+ icon = new Konva.Path({
14377
+ x: (this._width - this._iconSize) / 2,
14378
+ y: this._fontSize,
14379
+ data: SVGs[type].path,
14377
14380
  fill: this._peaks.options.lineIndicatorColor,
14378
14381
  scale: {
14379
- x: scaleFactor,
14380
- y: scaleFactor
14382
+ x: this._iconSize / SVGs[type].width,
14383
+ y: this._iconSize / SVGs[type].height
14381
14384
  },
14382
14385
  lineId: line.getId()
14383
14386
  });
14384
14387
  }
14388
+ indicator.add(text);
14389
+ indicator.add(icon);
14390
+ indicator.y(line.getY() + (line.lineHeight() - this._getIndicatorHeight(type)) / 2);
14385
14391
  var self = this;
14386
14392
  indicator.on('mouseover', function () {
14387
- indicator.fill(self._peaks.options.lineIndicatorSelected);
14393
+ indicator.getChildren().forEach(function (child) {
14394
+ child.fill(self._peaks.options.lineIndicatorSelected);
14395
+ });
14388
14396
  self.draw();
14389
14397
  });
14390
14398
  indicator.on('mouseout', function () {
14391
- indicator.fill(self._peaks.options.lineIndicatorColor);
14399
+ indicator.getChildren().forEach(function (child) {
14400
+ child.fill(self._peaks.options.lineIndicatorColor);
14401
+ });
14392
14402
  self.draw();
14393
14403
  });
14394
14404
  indicator.on('click', function (e) {
@@ -14419,18 +14429,15 @@ module.exports = function (Konva, Utils) {
14419
14429
  }
14420
14430
  }
14421
14431
  };
14422
- LineIndicator.prototype.getPixelsFromCenter = function (lineId) {
14423
- return this._indicators[lineId].type === 'default' ? 0 : this._width / 4;
14424
- };
14425
14432
  LineIndicator.prototype.updateIndicator = function (lineId) {
14426
14433
  if (this._indicators[lineId]) {
14427
14434
  var y = this._indicators[lineId].line.getY() + this._indicators[lineId].line.lineHeight() / 2;
14428
- if (y + this._indicatorRadius > 0 && y - this._indicatorRadius < this._height) {
14435
+ if (y + this._indicators[lineId].line.lineHeight() > 0 && y < this._height) {
14429
14436
  if (!this._indicators[lineId].indicator) {
14430
14437
  this._indicators[lineId].indicator = this._createIndicator(this._indicators[lineId].line, this._indicators[lineId].type);
14431
14438
  this._layer.add(this._indicators[lineId].indicator);
14432
14439
  } else {
14433
- this._indicators[lineId].indicator.y(y - this.getPixelsFromCenter(lineId));
14440
+ this._indicators[lineId].indicator.y(y - this._getIndicatorHeight(this._indicators[lineId].type) / 2);
14434
14441
  }
14435
14442
  } else {
14436
14443
  this.removeIndicator(lineId, true);
@@ -14447,6 +14454,9 @@ module.exports = function (Konva, Utils) {
14447
14454
  LineIndicator.prototype.draw = function () {
14448
14455
  this._layer.draw();
14449
14456
  };
14457
+ LineIndicator.prototype._getIndicatorHeight = function (type) {
14458
+ return type === 'default' ? this._fontSize + this._iconSize + this._defaultPadding : this._fontSize + this._iconSize;
14459
+ };
14450
14460
  LineIndicator.prototype._createContextMenu = function () {
14451
14461
  var menu = document.createElement('div');
14452
14462
  var addLine = document.createElement('button');
@@ -14560,8 +14570,8 @@ module.exports = function (Konva, Utils) {
14560
14570
  });
14561
14571
  };
14562
14572
  return LineIndicator;
14563
- }(_dereq_('konva'), _dereq_('./utils'));
14564
- },{"./utils":111,"konva":43}],92:[function(_dereq_,module,exports){
14573
+ }(_dereq_('konva'), _dereq_('./utils'), _dereq_('./svgs'));
14574
+ },{"./svgs":107,"./utils":112,"konva":43}],92:[function(_dereq_,module,exports){
14565
14575
  module.exports = function (Konva, Utils) {
14566
14576
  'use strict';
14567
14577
  function Line(peaks, view, y, id, position) {
@@ -15024,7 +15034,7 @@ module.exports = function (Konva, Utils) {
15024
15034
  };
15025
15035
  return Line;
15026
15036
  }(_dereq_('konva'), _dereq_('./utils'));
15027
- },{"./utils":111,"konva":43}],93:[function(_dereq_,module,exports){
15037
+ },{"./utils":112,"konva":43}],93:[function(_dereq_,module,exports){
15028
15038
  module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
15029
15039
  'use strict';
15030
15040
  function Lines(peaks, view, layer) {
@@ -15329,7 +15339,7 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
15329
15339
  };
15330
15340
  return Lines;
15331
15341
  }(_dereq_('./segments-group'), _dereq_('./line'), _dereq_('./line-indicator'), _dereq_('./utils'));
15332
- },{"./line":92,"./line-indicator":91,"./segments-group":103,"./utils":111}],94:[function(_dereq_,module,exports){
15342
+ },{"./line":92,"./line-indicator":91,"./segments-group":103,"./utils":112}],94:[function(_dereq_,module,exports){
15333
15343
  module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSources, KeyboardHandler, Player, MarkerFactories, TimelineZoomView, Utils) {
15334
15344
  'use strict';
15335
15345
  function Peaks() {
@@ -15379,6 +15389,8 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
15379
15389
  segmentMagnetThreshold: 15,
15380
15390
  enableVerticalScrolling: true,
15381
15391
  lineIndicatorWidth: 20,
15392
+ lineIndicatorIconSize: 10,
15393
+ lineIndicatorFontSize: 12,
15382
15394
  lineIndicatorColor: '#8A8F98',
15383
15395
  lineIndicatorSelected: '#ccc',
15384
15396
  autoScrollThreshold: 0.05,
@@ -15572,7 +15584,7 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
15572
15584
  };
15573
15585
  return Peaks;
15574
15586
  }(_dereq_('colors.css'), _dereq_('eventemitter2'), _dereq_('./timeline-segments'), _dereq_('./timeline-sources'), _dereq_('./keyboard-handler'), _dereq_('./player'), _dereq_('./marker-factories'), _dereq_('./timeline-zoomview'), _dereq_('./utils'));
15575
- },{"./keyboard-handler":90,"./marker-factories":95,"./player":98,"./timeline-segments":108,"./timeline-sources":109,"./timeline-zoomview":110,"./utils":111,"colors.css":1,"eventemitter2":2}],95:[function(_dereq_,module,exports){
15587
+ },{"./keyboard-handler":90,"./marker-factories":95,"./player":98,"./timeline-segments":109,"./timeline-sources":110,"./timeline-zoomview":111,"./utils":112,"colors.css":1,"eventemitter2":2}],95:[function(_dereq_,module,exports){
15576
15588
  module.exports = function (DefaultSegmentMarker, Utils, Konva) {
15577
15589
  'use strict';
15578
15590
  function createSegmentMarker(options) {
@@ -15604,7 +15616,7 @@ module.exports = function (DefaultSegmentMarker, Utils, Konva) {
15604
15616
  createSegmentLabel: createSegmentLabel
15605
15617
  };
15606
15618
  }(_dereq_('./default-segment-marker'), _dereq_('./utils'), _dereq_('konva'));
15607
- },{"./default-segment-marker":88,"./utils":111,"konva":43}],96:[function(_dereq_,module,exports){
15619
+ },{"./default-segment-marker":88,"./utils":112,"konva":43}],96:[function(_dereq_,module,exports){
15608
15620
  module.exports = function (Utils, SourceGroup, Konva) {
15609
15621
  'use strict';
15610
15622
  var TIME_X_OFFSET = 20;
@@ -15880,7 +15892,7 @@ module.exports = function (Utils, SourceGroup, Konva) {
15880
15892
  };
15881
15893
  return ModeLayer;
15882
15894
  }(_dereq_('./utils'), _dereq_('./source-group'), _dereq_('konva'));
15883
- },{"./source-group":104,"./utils":111,"konva":43}],97:[function(_dereq_,module,exports){
15895
+ },{"./source-group":104,"./utils":112,"konva":43}],97:[function(_dereq_,module,exports){
15884
15896
  module.exports = function (Konva) {
15885
15897
  'use strict';
15886
15898
  function getMarkerObject(obj) {
@@ -16009,7 +16021,7 @@ module.exports = function (Utils) {
16009
16021
  };
16010
16022
  return Player;
16011
16023
  }(_dereq_('./utils'));
16012
- },{"./utils":111}],99:[function(_dereq_,module,exports){
16024
+ },{"./utils":112}],99:[function(_dereq_,module,exports){
16013
16025
  module.exports = function (Utils, Konva) {
16014
16026
  'use strict';
16015
16027
  var HANDLE_RADIUS = 10;
@@ -16195,7 +16207,7 @@ module.exports = function (Utils, Konva) {
16195
16207
  };
16196
16208
  return PlayheadLayer;
16197
16209
  }(_dereq_('./utils'), _dereq_('konva'));
16198
- },{"./utils":111,"konva":43}],100:[function(_dereq_,module,exports){
16210
+ },{"./utils":112,"konva":43}],100:[function(_dereq_,module,exports){
16199
16211
  module.exports = function (Konva) {
16200
16212
  'use strict';
16201
16213
  function SegmentMarker(options) {
@@ -16331,9 +16343,9 @@ module.exports = function (Konva, SegmentMarker, Utils) {
16331
16343
  this._rectangle = new Konva.Rect({
16332
16344
  width: width,
16333
16345
  height: this._segmentHeight,
16334
- cornerRadius: SEGMENT_CORNER_RADIUS,
16335
- stroke: segment.textColor + 'FF',
16336
- strokeWidth: 2,
16346
+ cornerRadius: this._cornerRadius(),
16347
+ stroke: segment.borderColor || segment.textColor + 'FF',
16348
+ strokeWidth: segment.borderWidth !== undefined && segment.borderWidth !== null ? segment.borderWidth : 2,
16337
16349
  fillPriority: segment.shouldShowWarning() ? 'linear-gradient' : 'color',
16338
16350
  fill: fillColor,
16339
16351
  fillLinearGradientColorStops: [
@@ -16379,6 +16391,9 @@ module.exports = function (Konva, SegmentMarker, Utils) {
16379
16391
  this._shapeGroup.add(this._indicatorsGroup);
16380
16392
  this.createIndicators();
16381
16393
  }
16394
+ SegmentShape.prototype._cornerRadius = function () {
16395
+ return this._segment.borderRadius !== undefined && this._segment.borderRadius !== null ? this._segment.borderRadius : SEGMENT_CORNER_RADIUS;
16396
+ };
16382
16397
  SegmentShape.prototype.update = function () {
16383
16398
  var startPixel = this._view.timeToPixels(this._segment.startTime);
16384
16399
  var endPixel = this._view.timeToPixels(this._segment.endTime);
@@ -16629,21 +16644,22 @@ module.exports = function (Konva, SegmentMarker, Utils) {
16629
16644
  }
16630
16645
  };
16631
16646
  SegmentShape.prototype._drawRect = function (ctx) {
16647
+ var cornerRadius = this._cornerRadius();
16632
16648
  ctx.beginPath();
16633
- ctx.moveTo(SEGMENT_CORNER_RADIUS + 1.5, 0);
16634
- ctx.lineTo(this._segmentWidth - SEGMENT_CORNER_RADIUS - 1.5, 0);
16635
- ctx.quadraticCurveTo(this._segmentWidth, 0, this._segmentWidth, SEGMENT_CORNER_RADIUS + 1.5);
16636
- ctx.lineTo(this._segmentWidth, this._segmentHeight - SEGMENT_CORNER_RADIUS - 1.5);
16637
- ctx.quadraticCurveTo(this._segmentWidth, this._segmentHeight, this._segmentWidth - SEGMENT_CORNER_RADIUS - 1.5, this._segmentHeight);
16638
- ctx.lineTo(SEGMENT_CORNER_RADIUS + 1.5, this._segmentHeight);
16639
- ctx.quadraticCurveTo(0, this._segmentHeight, 0, this._segmentHeight - SEGMENT_CORNER_RADIUS - 1.5);
16640
- ctx.lineTo(0, SEGMENT_CORNER_RADIUS + 1.5);
16641
- ctx.quadraticCurveTo(0, 0, SEGMENT_CORNER_RADIUS + 1.5, 0);
16649
+ ctx.moveTo(cornerRadius + 1.5, 0);
16650
+ ctx.lineTo(this._segmentWidth - cornerRadius - 1.5, 0);
16651
+ ctx.quadraticCurveTo(this._segmentWidth, 0, this._segmentWidth, cornerRadius + 1.5);
16652
+ ctx.lineTo(this._segmentWidth, this._segmentHeight - cornerRadius - 1.5);
16653
+ ctx.quadraticCurveTo(this._segmentWidth, this._segmentHeight, this._segmentWidth - cornerRadius - 1.5, this._segmentHeight);
16654
+ ctx.lineTo(cornerRadius + 1.5, this._segmentHeight);
16655
+ ctx.quadraticCurveTo(0, this._segmentHeight, 0, this._segmentHeight - cornerRadius - 1.5);
16656
+ ctx.lineTo(0, cornerRadius + 1.5);
16657
+ ctx.quadraticCurveTo(0, 0, cornerRadius + 1.5, 0);
16642
16658
  ctx.closePath();
16643
16659
  };
16644
16660
  return SegmentShape;
16645
16661
  }(_dereq_('konva'), _dereq_('./segment-marker'), _dereq_('./utils'));
16646
- },{"./segment-marker":100,"./utils":111,"konva":43}],102:[function(_dereq_,module,exports){
16662
+ },{"./segment-marker":100,"./utils":112,"konva":43}],102:[function(_dereq_,module,exports){
16647
16663
  module.exports = function (Utils) {
16648
16664
  'use strict';
16649
16665
  function validateSegment(peaks, options, context) {
@@ -16698,7 +16714,7 @@ module.exports = function (Utils) {
16698
16714
  }
16699
16715
  return shouldNotifyUpdate;
16700
16716
  }
16701
- function Segment(peaks, id, startTime, endTime, duration, labelText, color, textColor, handleTextColor, hoverColor, warningColor, opacity, editable, allowDeletion, line, indicators) {
16717
+ function Segment(peaks, id, startTime, endTime, duration, labelText, color, textColor, handleTextColor, hoverColor, warningColor, opacity, borderColor, borderWidth, borderRadius, editable, allowDeletion, line, indicators) {
16702
16718
  var opts = {
16703
16719
  startTime: startTime,
16704
16720
  endTime: endTime,
@@ -16710,6 +16726,9 @@ module.exports = function (Utils) {
16710
16726
  hoverColor: hoverColor,
16711
16727
  warningColor: warningColor,
16712
16728
  opacity: opacity,
16729
+ borderColor: borderColor,
16730
+ borderWidth: borderWidth,
16731
+ borderRadius: borderRadius,
16713
16732
  editable: editable,
16714
16733
  allowDeletion: allowDeletion,
16715
16734
  line: line,
@@ -16728,6 +16747,9 @@ module.exports = function (Utils) {
16728
16747
  this._handleTextColor = opts.handleTextColor;
16729
16748
  this._warningColor = opts.warningColor;
16730
16749
  this._opacity = opts.opacity;
16750
+ this._borderColor = opts.borderColor;
16751
+ this._borderWidth = opts.borderWidth;
16752
+ this._borderRadius = opts.borderRadius;
16731
16753
  this._editable = opts.editable;
16732
16754
  this._allowDeletion = opts.allowDeletion;
16733
16755
  this._line = opts.line;
@@ -16814,6 +16836,24 @@ module.exports = function (Utils) {
16814
16836
  return this._opacity;
16815
16837
  }
16816
16838
  },
16839
+ borderColor: {
16840
+ enumerable: true,
16841
+ get: function () {
16842
+ return this._borderColor;
16843
+ }
16844
+ },
16845
+ borderWidth: {
16846
+ enumerable: true,
16847
+ get: function () {
16848
+ return this._borderWidth;
16849
+ }
16850
+ },
16851
+ borderRadius: {
16852
+ enumerable: true,
16853
+ get: function () {
16854
+ return this._borderRadius;
16855
+ }
16856
+ },
16817
16857
  editable: {
16818
16858
  enumerable: true,
16819
16859
  get: function () {
@@ -16866,6 +16906,9 @@ module.exports = function (Utils) {
16866
16906
  hoverColor: this.hoverColor,
16867
16907
  warningColor: this.warningColor,
16868
16908
  opacity: this.opacity,
16909
+ borderColor: this.borderColor,
16910
+ borderWidth: this.borderWidth,
16911
+ borderRadius: this.borderRadius,
16869
16912
  editable: this.editable,
16870
16913
  allowDeletion: this.allowDeletion,
16871
16914
  line: this.line,
@@ -16883,6 +16926,9 @@ module.exports = function (Utils) {
16883
16926
  this._hoverColor = opts.hoverColor;
16884
16927
  this._warningColor = opts.warningColor;
16885
16928
  this._opacity = opts.opacity;
16929
+ this._borderColor = opts.borderColor;
16930
+ this._borderWidth = opts.borderWidth;
16931
+ this._borderRadius = opts.borderRadius;
16886
16932
  this._editable = opts.editable;
16887
16933
  this._allowDeletion = opts.allowDeletion;
16888
16934
  this._line = opts.line;
@@ -16901,7 +16947,7 @@ module.exports = function (Utils) {
16901
16947
  };
16902
16948
  return Segment;
16903
16949
  }(_dereq_('./utils'));
16904
- },{"./utils":111}],103:[function(_dereq_,module,exports){
16950
+ },{"./utils":112}],103:[function(_dereq_,module,exports){
16905
16951
  module.exports = function (SegmentShape, Utils, Konva) {
16906
16952
  'use strict';
16907
16953
  function SegmentsGroup(peaks, view, allowEditing) {
@@ -17421,7 +17467,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
17421
17467
  };
17422
17468
  return SegmentsGroup;
17423
17469
  }(_dereq_('./segment-shape'), _dereq_('./utils'), _dereq_('konva'));
17424
- },{"./segment-shape":101,"./utils":111,"konva":43}],104:[function(_dereq_,module,exports){
17470
+ },{"./segment-shape":101,"./utils":112,"konva":43}],104:[function(_dereq_,module,exports){
17425
17471
  module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17426
17472
  'use strict';
17427
17473
  var SPACING_BETWEEN_PREVIEW_AND_BORDER_RATIO = 0.15;
@@ -18142,7 +18188,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
18142
18188
  };
18143
18189
  return SourceGroup;
18144
18190
  }(_dereq_('./waveform-builder'), _dereq_('./waveform-shape'), _dereq_('./utils'), _dereq_('konva'));
18145
- },{"./utils":111,"./waveform-builder":112,"./waveform-shape":113,"konva":43}],105:[function(_dereq_,module,exports){
18191
+ },{"./utils":112,"./waveform-builder":113,"./waveform-shape":114,"konva":43}],105:[function(_dereq_,module,exports){
18146
18192
  module.exports = function (Utils) {
18147
18193
  'use strict';
18148
18194
  function validateSource(peaks, options, context) {
@@ -18739,7 +18785,7 @@ module.exports = function (Utils) {
18739
18785
  };
18740
18786
  return Source;
18741
18787
  }(_dereq_('./utils'));
18742
- },{"./utils":111}],106:[function(_dereq_,module,exports){
18788
+ },{"./utils":112}],106:[function(_dereq_,module,exports){
18743
18789
  module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Konva) {
18744
18790
  'use strict';
18745
18791
  function SourcesLayer(peaks, view, allowEditing) {
@@ -19092,7 +19138,34 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
19092
19138
  };
19093
19139
  return SourcesLayer;
19094
19140
  }(_dereq_('./source-group'), _dereq_('./lines'), _dereq_('./data-retriever'), _dereq_('./utils'), _dereq_('./invoker'), _dereq_('konva'));
19095
- },{"./data-retriever":86,"./invoker":89,"./lines":93,"./source-group":104,"./utils":111,"konva":43}],107:[function(_dereq_,module,exports){
19141
+ },{"./data-retriever":86,"./invoker":89,"./lines":93,"./source-group":104,"./utils":112,"konva":43}],107:[function(_dereq_,module,exports){
19142
+ module.exports = function () {
19143
+ 'use strict';
19144
+ var SVGs = {
19145
+ volume: {
19146
+ width: 24,
19147
+ height: 24,
19148
+ path: 'M15.35 20.7262C15.0167 20.8595 14.7083 20.8179 14.425 20.6012C14.1417 20.3845 14 20.0845 14 19.7012C14 19.5179 14.0543 19.3555 14.163 19.2142C14.271 19.0722 14.4083 18.9679 14.575 18.9012C15.9083 18.3679 16.9793 17.5179 17.788 16.3512C18.596 15.1845 19 13.8679 19 12.4012C19 10.9345 18.596 9.61786 17.788 8.45119C16.9793 7.28452 15.9083 6.43452 14.575 5.90119C14.3917 5.83452 14.25 5.72619 14.15 5.57619C14.05 5.42619 14 5.25952 14 5.07619C14 4.70952 14.1417 4.41786 14.425 4.20119C14.7083 3.98452 15.0167 3.94286 15.35 4.07619C17.05 4.75952 18.4167 5.85119 19.45 7.35119C20.4833 8.85119 21 10.5345 21 12.4012C21 14.2679 20.4833 15.9512 19.45 17.4512C18.4167 18.9512 17.05 20.0429 15.35 20.7262ZM4 15.4262C3.71667 15.4262 3.47933 15.3302 3.288 15.1382C3.096 14.9469 3 14.7095 3 14.4262V10.4262C3 10.1429 3.096 9.90519 3.288 9.71319C3.47933 9.52186 3.71667 9.42619 4 9.42619H7L10.3 6.12619C10.6167 5.80952 10.979 5.73852 11.387 5.91319C11.7957 6.08852 12 6.40119 12 6.85119V18.0012C12 18.4512 11.7957 18.7635 11.387 18.9382C10.979 19.1135 10.6167 19.0429 10.3 18.7262L7 15.4262H4ZM14 16.4262V8.37619C14.75 8.72619 15.354 9.26786 15.812 10.0012C16.2707 10.7345 16.5 11.5429 16.5 12.4262C16.5 13.3095 16.2707 14.1095 15.812 14.8262C15.354 15.5429 14.75 16.0762 14 16.4262ZM10 9.27619L7.85 11.4262H5V13.4262H7.85L10 15.5762V9.27619Z'
19149
+ },
19150
+ noVolume: {
19151
+ width: 24,
19152
+ height: 24,
19153
+ path: 'M19.275 21.675L16.95 19.35C16.7167 19.4833 16.4833 19.6123 16.25 19.737C16.0167 19.8623 15.775 19.975 15.525 20.075C15.1917 20.2083 14.8833 20.1667 14.6 19.95C14.3167 19.7333 14.175 19.4333 14.175 19.05C14.175 18.8667 14.2293 18.7043 14.338 18.563C14.446 18.421 14.5833 18.3167 14.75 18.25C14.8833 18.2 15.0127 18.1457 15.138 18.087C15.2627 18.029 15.3833 17.9667 15.5 17.9L12.175 14.575V17.35C12.175 17.8 11.9707 18.1123 11.562 18.287C11.154 18.4623 10.7917 18.3917 10.475 18.075L7.175 14.775H4.175C3.89167 14.775 3.65433 14.679 3.463 14.487C3.271 14.2957 3.175 14.0583 3.175 13.775V9.775C3.175 9.49167 3.271 9.254 3.463 9.062C3.65433 8.87067 3.89167 8.775 4.175 8.775H6.375L2.275 4.675C2.09167 4.49167 2 4.25833 2 3.975C2 3.69167 2.09167 3.45833 2.275 3.275C2.45833 3.09167 2.69167 3 2.975 3C3.25833 3 3.49167 3.09167 3.675 3.275L20.675 20.275C20.8583 20.4583 20.95 20.6917 20.95 20.975C20.95 21.2583 20.8583 21.4917 20.675 21.675C20.4917 21.8583 20.2583 21.95 19.975 21.95C19.6917 21.95 19.4583 21.8583 19.275 21.675ZM15.525 3.425C17.225 4.10833 18.5917 5.2 19.625 6.7C20.6583 8.2 21.175 9.88333 21.175 11.75C21.175 12.6333 21.0543 13.4833 20.813 14.3C20.571 15.1167 20.225 15.875 19.775 16.575L18.325 15.125C18.6083 14.6083 18.821 14.0667 18.963 13.5C19.1043 12.9333 19.175 12.35 19.175 11.75C19.175 10.2833 18.771 8.96667 17.963 7.8C17.1543 6.63333 16.0833 5.78333 14.75 5.25C14.5667 5.18333 14.425 5.075 14.325 4.925C14.225 4.775 14.175 4.60833 14.175 4.425C14.175 4.05833 14.3167 3.76667 14.6 3.55C14.8833 3.33333 15.1917 3.29167 15.525 3.425ZM16.425 13.225L14.175 10.975V7.725C14.9583 8.09167 15.571 8.64167 16.013 9.375C16.4543 10.1083 16.675 10.9083 16.675 11.775C16.675 12.025 16.6543 12.271 16.613 12.513C16.571 12.7543 16.5083 12.9917 16.425 13.225ZM12.175 8.975L9.575 6.375L10.475 5.475C10.7917 5.15833 11.154 5.08733 11.562 5.262C11.9707 5.43733 12.175 5.75 12.175 6.2V8.975ZM10.175 14.925V12.575L8.375 10.775H5.175V12.775H8.025L10.175 14.925Z'
19154
+ },
19155
+ visibility: {
19156
+ width: 24,
19157
+ height: 24,
19158
+ path: 'M11.9998 17C13.2498 17 14.3125 16.5627 15.1878 15.688C16.0625 14.8127 16.4998 13.75 16.4998 12.5C16.4998 11.25 16.0625 10.1873 15.1878 9.312C14.3125 8.43733 13.2498 8 11.9998 8C10.7498 8 9.68714 8.43733 8.8118 9.312C7.93714 10.1873 7.4998 11.25 7.4998 12.5C7.4998 13.75 7.93714 14.8127 8.8118 15.688C9.68714 16.5627 10.7498 17 11.9998 17ZM11.9998 15.2C11.2498 15.2 10.6125 14.9373 10.0878 14.412C9.56247 13.8873 9.2998 13.25 9.2998 12.5C9.2998 11.75 9.56247 11.1123 10.0878 10.587C10.6125 10.0623 11.2498 9.8 11.9998 9.8C12.7498 9.8 13.3875 10.0623 13.9128 10.587C14.4375 11.1123 14.6998 11.75 14.6998 12.5C14.6998 13.25 14.4375 13.8873 13.9128 14.412C13.3875 14.9373 12.7498 15.2 11.9998 15.2ZM11.9998 20C9.68314 20 7.56647 19.3877 5.64981 18.163C3.73314 16.9377 2.28314 15.2833 1.2998 13.2C1.2498 13.1167 1.21647 13.0123 1.1998 12.887C1.18314 12.7623 1.1748 12.6333 1.1748 12.5C1.1748 12.3667 1.18314 12.2373 1.1998 12.112C1.21647 11.9873 1.2498 11.8833 1.2998 11.8C2.28314 9.71667 3.73314 8.06267 5.64981 6.838C7.56647 5.61267 9.68314 5 11.9998 5C14.3165 5 16.4331 5.61267 18.3498 6.838C20.2665 8.06267 21.7165 9.71667 22.6998 11.8C22.7498 11.8833 22.7831 11.9873 22.7998 12.112C22.8165 12.2373 22.8248 12.3667 22.8248 12.5C22.8248 12.6333 22.8165 12.7623 22.7998 12.887C22.7831 13.0123 22.7498 13.1167 22.6998 13.2C21.7165 15.2833 20.2665 16.9377 18.3498 18.163C16.4331 19.3877 14.3165 20 11.9998 20ZM11.9998 18C13.8831 18 15.6125 17.504 17.1878 16.512C18.7625 15.5207 19.9665 14.1833 20.7998 12.5C19.9665 10.8167 18.7625 9.479 17.1878 8.487C15.6125 7.49567 13.8831 7 11.9998 7C10.1165 7 8.38714 7.49567 6.8118 8.487C5.23714 9.479 4.03314 10.8167 3.1998 12.5C4.03314 14.1833 5.23714 15.5207 6.8118 16.512C8.38714 17.504 10.1165 18 11.9998 18Z'
19159
+ },
19160
+ noVisibility: {
19161
+ width: 24,
19162
+ height: 24,
19163
+ path: 'M16.0998 13.3L14.6498 11.85C14.7998 11.0666 14.5748 10.3333 13.9748 9.64998C13.3748 8.96664 12.5998 8.69998 11.6498 8.84998L10.1998 7.39998C10.4831 7.26664 10.7705 7.16664 11.0618 7.09998C11.3538 7.03331 11.6665 6.99998 11.9998 6.99998C13.2498 6.99998 14.3125 7.43731 15.1878 8.31198C16.0625 9.18731 16.4998 10.25 16.4998 11.5C16.4998 11.8333 16.4665 12.146 16.3998 12.438C16.3331 12.7293 16.2331 13.0166 16.0998 13.3ZM19.2998 16.45L17.8498 15.05C18.4831 14.5666 19.0458 14.0373 19.5378 13.462C20.0291 12.8873 20.4498 12.2333 20.7998 11.5C19.9665 9.81664 18.7705 8.47898 17.2118 7.48698C15.6538 6.49564 13.9165 5.99998 11.9998 5.99998C11.5165 5.99998 11.0415 6.03331 10.5748 6.09998C10.1081 6.16664 9.6498 6.26664 9.1998 6.39998L7.64981 4.84998C8.33314 4.56664 9.03314 4.35398 9.7498 4.21198C10.4665 4.07064 11.2165 3.99998 11.9998 3.99998C14.3831 3.99998 16.5248 4.62898 18.4248 5.88698C20.3248 7.14564 21.7498 8.78331 22.6998 10.8C22.7498 10.8833 22.7831 10.9873 22.7998 11.112C22.8165 11.2373 22.8248 11.3666 22.8248 11.5C22.8248 11.6333 22.8125 11.7623 22.7878 11.887C22.7625 12.0123 22.7331 12.1166 22.6998 12.2C22.3165 13.05 21.8375 13.8333 21.2628 14.55C20.6875 15.2666 20.0331 15.9 19.2998 16.45ZM19.0998 21.9L15.5998 18.45C15.0165 18.6333 14.4291 18.771 13.8378 18.863C13.2458 18.9543 12.6331 19 11.9998 19C9.61647 19 7.4748 18.371 5.5748 17.113C3.6748 15.8543 2.2498 14.2166 1.2998 12.2C1.2498 12.1166 1.21647 12.0123 1.1998 11.887C1.18314 11.7623 1.1748 11.6333 1.1748 11.5C1.1748 11.3666 1.18314 11.2416 1.1998 11.125C1.21647 11.0083 1.2498 10.9083 1.2998 10.825C1.6498 10.075 2.06647 9.38331 2.5498 8.74998C3.03314 8.11664 3.56647 7.53331 4.1498 6.99998L2.0748 4.89998C1.89147 4.71664 1.7998 4.48731 1.7998 4.21198C1.7998 3.93731 1.8998 3.69998 2.0998 3.49998C2.28314 3.31664 2.51647 3.22498 2.7998 3.22498C3.08314 3.22498 3.31647 3.31664 3.4998 3.49998L20.4998 20.5C20.6831 20.6833 20.7791 20.9126 20.7878 21.188C20.7958 21.4626 20.6998 21.7 20.4998 21.9C20.3165 22.0833 20.0831 22.175 19.7998 22.175C19.5165 22.175 19.2831 22.0833 19.0998 21.9ZM5.5498 8.39998C5.06647 8.83331 4.6248 9.30831 4.2248 9.82498C3.8248 10.3416 3.48314 10.9 3.1998 11.5C4.03314 13.1833 5.22881 14.5206 6.78681 15.512C8.34547 16.504 10.0831 17 11.9998 17C12.3331 17 12.6581 16.9793 12.9748 16.938C13.2915 16.896 13.6165 16.85 13.9498 16.8L13.0498 15.85C12.8665 15.9 12.6915 15.9373 12.5248 15.962C12.3581 15.9873 12.1831 16 11.9998 16C10.7498 16 9.68714 15.5626 8.8118 14.688C7.93714 13.8126 7.4998 12.75 7.4998 11.5C7.4998 11.3166 7.51214 11.1416 7.53681 10.975C7.56214 10.8083 7.5998 10.6333 7.64981 10.45L5.5498 8.39998Z'
19164
+ }
19165
+ };
19166
+ return SVGs;
19167
+ }();
19168
+ },{}],108:[function(_dereq_,module,exports){
19096
19169
  module.exports = function (Utils, Konva) {
19097
19170
  'use strict';
19098
19171
  var LEFT_PADDING = 4;
@@ -19234,7 +19307,7 @@ module.exports = function (Utils, Konva) {
19234
19307
  };
19235
19308
  return TimelineAxis;
19236
19309
  }(_dereq_('./utils'), _dereq_('konva'));
19237
- },{"./utils":111,"konva":43}],108:[function(_dereq_,module,exports){
19310
+ },{"./utils":112,"konva":43}],109:[function(_dereq_,module,exports){
19238
19311
  module.exports = function (Colors, Segment, Utils) {
19239
19312
  'use strict';
19240
19313
  function TimelineSegments(peaks) {
@@ -19277,7 +19350,7 @@ module.exports = function (Colors, Segment, Utils) {
19277
19350
  if (!Utils.isObject(options)) {
19278
19351
  throw new TypeError('peaks.segments.add(): expected a Segment object parameter');
19279
19352
  }
19280
- var segment = new Segment(this._peaks, Utils.isNullOrUndefined(options.id) ? this._getNextSegmentId() : options.id, options.startTime, options.endTime, options.duration, options.labelText, options.color || this._getSegmentColor(), options.textColor || '#000000', options.handleTextColor || '#000000', options.hoverColor, options.warningColor, options.opacity || 1, options.editable, options.allowDeletion || false, options.line, options.indicators);
19353
+ var segment = new Segment(this._peaks, Utils.isNullOrUndefined(options.id) ? this._getNextSegmentId() : options.id, options.startTime, options.endTime, options.duration, options.labelText, options.color || this._getSegmentColor(), options.textColor || '#000000', options.handleTextColor || '#000000', options.hoverColor, options.warningColor, options.opacity || 1, options.borderColor, options.borderWidth, options.borderRadius, options.editable, options.allowDeletion || false, options.line, options.indicators);
19281
19354
  return segment;
19282
19355
  };
19283
19356
  TimelineSegments.prototype.getSegments = function () {
@@ -19396,7 +19469,7 @@ module.exports = function (Colors, Segment, Utils) {
19396
19469
  };
19397
19470
  return TimelineSegments;
19398
19471
  }(_dereq_('colors.css'), _dereq_('./segment'), _dereq_('./utils'));
19399
- },{"./segment":102,"./utils":111,"colors.css":1}],109:[function(_dereq_,module,exports){
19472
+ },{"./segment":102,"./utils":112,"colors.css":1}],110:[function(_dereq_,module,exports){
19400
19473
  module.exports = function (Source, Utils) {
19401
19474
  'use strict';
19402
19475
  function TimelineSources(peaks) {
@@ -19567,7 +19640,7 @@ module.exports = function (Source, Utils) {
19567
19640
  };
19568
19641
  return TimelineSources;
19569
19642
  }(_dereq_('./source'), _dereq_('./utils'));
19570
- },{"./source":105,"./utils":111}],110:[function(_dereq_,module,exports){
19643
+ },{"./source":105,"./utils":112}],111:[function(_dereq_,module,exports){
19571
19644
  module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLayer, TimelineAxis, Utils, Konva) {
19572
19645
  'use strict';
19573
19646
  function TimelineZoomView(container, peaks) {
@@ -20127,7 +20200,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
20127
20200
  };
20128
20201
  return TimelineZoomView;
20129
20202
  }(_dereq_('./mouse-drag-handler'), _dereq_('./playhead-layer'), _dereq_('./sources-layer'), _dereq_('./mode-layer'), _dereq_('./timeline-axis'), _dereq_('./utils'), _dereq_('konva'));
20130
- },{"./mode-layer":96,"./mouse-drag-handler":97,"./playhead-layer":99,"./sources-layer":106,"./timeline-axis":107,"./utils":111,"konva":43}],111:[function(_dereq_,module,exports){
20203
+ },{"./mode-layer":96,"./mouse-drag-handler":97,"./playhead-layer":99,"./sources-layer":106,"./timeline-axis":108,"./utils":112,"konva":43}],112:[function(_dereq_,module,exports){
20131
20204
  module.exports = function (UUID) {
20132
20205
  'use strict';
20133
20206
  if (typeof Number.isFinite !== 'function') {
@@ -20291,7 +20364,7 @@ module.exports = function (UUID) {
20291
20364
  }
20292
20365
  };
20293
20366
  }(_dereq_('uuid'));
20294
- },{"uuid":62}],112:[function(_dereq_,module,exports){
20367
+ },{"uuid":62}],113:[function(_dereq_,module,exports){
20295
20368
  module.exports = function (WaveformData, Utils) {
20296
20369
  'use strict';
20297
20370
  var isXhr2 = 'withCredentials' in new XMLHttpRequest();
@@ -20483,7 +20556,7 @@ module.exports = function (WaveformData, Utils) {
20483
20556
  };
20484
20557
  return WaveformBuilder;
20485
20558
  }(_dereq_('waveform-data'), _dereq_('./utils'));
20486
- },{"./utils":111,"waveform-data":85}],113:[function(_dereq_,module,exports){
20559
+ },{"./utils":112,"waveform-data":85}],114:[function(_dereq_,module,exports){
20487
20560
  module.exports = function (Utils, Konva) {
20488
20561
  'use strict';
20489
20562
  function scaleY(amplitude, height, scale) {
@@ -20573,6 +20646,6 @@ module.exports = function (Utils, Konva) {
20573
20646
  };
20574
20647
  return WaveformShape;
20575
20648
  }(_dereq_('./utils'), _dereq_('konva'));
20576
- },{"./utils":111,"konva":43}]},{},[94])(94)
20649
+ },{"./utils":112,"konva":43}]},{},[94])(94)
20577
20650
  });
20578
20651
  //# sourceMappingURL=peaks.js.map
@@ -8,10 +8,12 @@
8
8
 
9
9
  define([
10
10
  'konva',
11
- './utils'
11
+ './utils',
12
+ './svgs'
12
13
  ], function(
13
14
  Konva,
14
- Utils) {
15
+ Utils,
16
+ SVGs) {
15
17
  'use strict';
16
18
 
17
19
  /**
@@ -32,7 +34,11 @@ define([
32
34
  this._width = this._peaks.options.lineIndicatorWidth;
33
35
  this._height = this._view.getHeight();
34
36
 
35
- this._indicatorRadius = this._width / 4;
37
+ this._iconSize = this._peaks.options.lineIndicatorIconSize;
38
+ this._fontSize = this._peaks.options.lineIndicatorFontSize;
39
+
40
+ this._defaultPadding = 5;
41
+ this._types = ['default'].concat(Object.keys(SVGs));
36
42
 
37
43
  this._stage = new Konva.Stage({
38
44
  container: container,
@@ -59,15 +65,7 @@ define([
59
65
  this._createContextMenu();
60
66
  }
61
67
 
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
68
  this._peaks.on('lineIndicator.setType', this._onSetType.bind(this));
69
-
70
- this._types = ['default', 'volume', 'noVolume'];
71
69
  }
72
70
 
73
71
  LineIndicator.prototype.fitToView = function() {
@@ -107,47 +105,63 @@ define([
107
105
  };
108
106
 
109
107
  LineIndicator.prototype._createIndicator = function(line, type) {
110
- var indicator;
108
+ var indicator = new Konva.Group();
109
+
110
+ var text = new Konva.Text({
111
+ text: 'This is just a test',
112
+ fontSize: this._fontSize,
113
+ fontFamily: 'Arial',
114
+ fill: this._peaks.options.lineIndicatorColor,
115
+ align: 'center',
116
+ width: this._width
117
+ });
111
118
 
112
- type = typeof type !== 'undefined' ? type : 'default';
119
+ type = this._types.includes(type) ? type : 'default';
120
+
121
+ var icon;
113
122
 
114
123
  if (type === 'default') {
115
- indicator = new Konva.Circle({
124
+ icon = new Konva.Circle({
116
125
  x: this._width / 2,
117
- y: line.getY() + (line.lineHeight() / 2),
118
- radius: this._indicatorRadius,
126
+ y: this._fontSize + this._iconSize / 2 + this._defaultPadding,
127
+ radius: this._iconSize / 2,
119
128
  fill: this._peaks.options.lineIndicatorColor,
120
129
  strokeWidth: 0,
121
130
  lineId: line.getId()
122
131
  });
123
132
  }
124
133
  else {
125
- var scaleFactor = (this._width / 2) / this.ICON_SIZE;
126
-
127
- indicator = new Konva.Path({
128
- x: this._width / 4,
129
- y: line.getY() + (line.lineHeight() / 2) - (this._width / 4),
130
- data: type === 'volume' ?
131
- this._volumeSVGPath :
132
- this._noVolumeSVGPath,
134
+ icon = new Konva.Path({
135
+ x: (this._width - this._iconSize) / 2,
136
+ y: this._fontSize,
137
+ data: SVGs[type].path,
133
138
  fill: this._peaks.options.lineIndicatorColor,
134
139
  scale: {
135
- x: scaleFactor,
136
- y: scaleFactor
140
+ x: (this._iconSize) / SVGs[type].width,
141
+ y: (this._iconSize) / SVGs[type].height
137
142
  },
138
143
  lineId: line.getId()
139
144
  });
140
145
  }
141
146
 
147
+ indicator.add(text);
148
+ indicator.add(icon);
149
+
150
+ indicator.y(line.getY() + (line.lineHeight() - this._getIndicatorHeight(type)) / 2);
151
+
142
152
  var self = this;
143
153
 
144
154
  indicator.on('mouseover', function() {
145
- indicator.fill(self._peaks.options.lineIndicatorSelected);
155
+ indicator.getChildren().forEach(function(child) {
156
+ child.fill(self._peaks.options.lineIndicatorSelected);
157
+ });
146
158
  self.draw();
147
159
  });
148
160
 
149
161
  indicator.on('mouseout', function() {
150
- indicator.fill(self._peaks.options.lineIndicatorColor);
162
+ indicator.getChildren().forEach(function(child) {
163
+ child.fill(self._peaks.options.lineIndicatorColor);
164
+ });
151
165
  self.draw();
152
166
  });
153
167
 
@@ -186,18 +200,12 @@ define([
186
200
  }
187
201
  };
188
202
 
189
- LineIndicator.prototype.getPixelsFromCenter = function(lineId) {
190
- return this._indicators[lineId].type === 'default' ?
191
- 0 :
192
- this._width / 4;
193
- };
194
-
195
203
  LineIndicator.prototype.updateIndicator = function(lineId) {
196
204
  if (this._indicators[lineId]) {
197
205
  var y = this._indicators[lineId].line.getY()
198
- + (this._indicators[lineId].line.lineHeight() / 2);
206
+ + (this._indicators[lineId].line.lineHeight() / 2);
199
207
 
200
- if (y + this._indicatorRadius > 0 && y - this._indicatorRadius < this._height) {
208
+ if (y + this._indicators[lineId].line.lineHeight() > 0 && y < this._height) {
201
209
  // The indicator is visible
202
210
  if (!this._indicators[lineId].indicator) {
203
211
  this._indicators[lineId].indicator = this._createIndicator(
@@ -207,7 +215,9 @@ define([
207
215
  this._layer.add(this._indicators[lineId].indicator);
208
216
  }
209
217
  else {
210
- this._indicators[lineId].indicator.y(y - this.getPixelsFromCenter(lineId));
218
+ this._indicators[lineId].indicator.y(
219
+ y - this._getIndicatorHeight(this._indicators[lineId].type) / 2
220
+ );
211
221
  }
212
222
  }
213
223
  else {
@@ -229,6 +239,12 @@ define([
229
239
  this._layer.draw();
230
240
  };
231
241
 
242
+ LineIndicator.prototype._getIndicatorHeight = function(type) {
243
+ return type === 'default' ?
244
+ this._fontSize + this._iconSize + this._defaultPadding :
245
+ this._fontSize + this._iconSize;
246
+ };
247
+
232
248
  LineIndicator.prototype._createContextMenu = function() {
233
249
  var menu = document.createElement('div');
234
250
  var addLine = document.createElement('button');
package/src/main.js CHANGED
@@ -280,6 +280,16 @@ define([
280
280
  */
281
281
  lineIndicatorWidth: 20,
282
282
 
283
+ /**
284
+ * Size of the line indicators' icon, in pixels
285
+ */
286
+ lineIndicatorIconSize: 10,
287
+
288
+ /**
289
+ * Font size of the line indicators' text, in pixels
290
+ */
291
+ lineIndicatorFontSize: 12,
292
+
283
293
  /**
284
294
  * Color of the line indicators
285
295
  */
@@ -71,9 +71,11 @@ define([
71
71
  this._rectangle = new Konva.Rect({
72
72
  width: width,
73
73
  height: this._segmentHeight,
74
- cornerRadius: SEGMENT_CORNER_RADIUS,
75
- stroke: segment.textColor + 'FF',
76
- strokeWidth: 2,
74
+ cornerRadius: this._cornerRadius(),
75
+ stroke: segment.borderColor || segment.textColor + 'FF',
76
+ strokeWidth: segment.borderWidth !== undefined && segment.borderWidth !== null ?
77
+ segment.borderWidth :
78
+ 2,
77
79
  fillPriority: segment.shouldShowWarning() ? 'linear-gradient' : 'color',
78
80
  fill: fillColor,
79
81
  fillLinearGradientColorStops: [
@@ -136,6 +138,12 @@ define([
136
138
  this.createIndicators();
137
139
  }
138
140
 
141
+ SegmentShape.prototype._cornerRadius = function() {
142
+ return this._segment.borderRadius !== undefined && this._segment.borderRadius !== null ?
143
+ this._segment.borderRadius :
144
+ SEGMENT_CORNER_RADIUS;
145
+ };
146
+
139
147
  SegmentShape.prototype.update = function() {
140
148
  var startPixel = this._view.timeToPixels(this._segment.startTime);
141
149
  var endPixel = this._view.timeToPixels(this._segment.endTime);
@@ -475,23 +483,25 @@ define([
475
483
  };
476
484
 
477
485
  SegmentShape.prototype._drawRect = function(ctx) {
486
+ var cornerRadius = this._cornerRadius();
487
+
478
488
  ctx.beginPath();
479
- ctx.moveTo(SEGMENT_CORNER_RADIUS + 1.5, 0);
480
- ctx.lineTo(this._segmentWidth - SEGMENT_CORNER_RADIUS - 1.5, 0);
481
- ctx.quadraticCurveTo(this._segmentWidth, 0, this._segmentWidth, SEGMENT_CORNER_RADIUS + 1.5);
482
- ctx.lineTo(this._segmentWidth, this._segmentHeight - SEGMENT_CORNER_RADIUS - 1.5);
489
+ ctx.moveTo(cornerRadius + 1.5, 0);
490
+ ctx.lineTo(this._segmentWidth - cornerRadius - 1.5, 0);
491
+ ctx.quadraticCurveTo(this._segmentWidth, 0, this._segmentWidth, cornerRadius + 1.5);
492
+ ctx.lineTo(this._segmentWidth, this._segmentHeight - cornerRadius - 1.5);
483
493
  ctx.quadraticCurveTo(
484
494
  this._segmentWidth,
485
495
  this._segmentHeight,
486
- this._segmentWidth - SEGMENT_CORNER_RADIUS - 1.5,
496
+ this._segmentWidth - cornerRadius - 1.5,
487
497
  this._segmentHeight
488
498
  );
489
- ctx.lineTo(SEGMENT_CORNER_RADIUS + 1.5, this._segmentHeight);
499
+ ctx.lineTo(cornerRadius + 1.5, this._segmentHeight);
490
500
  ctx.quadraticCurveTo(
491
- 0, this._segmentHeight, 0, this._segmentHeight - SEGMENT_CORNER_RADIUS - 1.5
501
+ 0, this._segmentHeight, 0, this._segmentHeight - cornerRadius - 1.5
492
502
  );
493
- ctx.lineTo(0, SEGMENT_CORNER_RADIUS + 1.5);
494
- ctx.quadraticCurveTo(0, 0, SEGMENT_CORNER_RADIUS + 1.5, 0);
503
+ ctx.lineTo(0, cornerRadius + 1.5);
504
+ ctx.quadraticCurveTo(0, 0, cornerRadius + 1.5, 0);
495
505
  ctx.closePath();
496
506
  };
497
507
 
package/src/segment.js CHANGED
@@ -105,7 +105,8 @@ define([
105
105
 
106
106
  function Segment(peaks, id, startTime, endTime, duration, labelText,
107
107
  color, textColor, handleTextColor, hoverColor, warningColor, opacity,
108
- editable, allowDeletion, line, indicators) {
108
+ borderColor, borderWidth, borderRadius, editable, allowDeletion, line,
109
+ indicators) {
109
110
  var opts = {
110
111
  startTime: startTime,
111
112
  endTime: endTime,
@@ -117,6 +118,9 @@ define([
117
118
  hoverColor: hoverColor,
118
119
  warningColor: warningColor,
119
120
  opacity: opacity,
121
+ borderColor: borderColor,
122
+ borderWidth: borderWidth,
123
+ borderRadius: borderRadius,
120
124
  editable: editable,
121
125
  allowDeletion: allowDeletion,
122
126
  line: line,
@@ -137,6 +141,9 @@ define([
137
141
  this._handleTextColor = opts.handleTextColor;
138
142
  this._warningColor = opts.warningColor;
139
143
  this._opacity = opts.opacity;
144
+ this._borderColor = opts.borderColor;
145
+ this._borderWidth = opts.borderWidth;
146
+ this._borderRadius = opts.borderRadius;
140
147
  this._editable = opts.editable;
141
148
  this._allowDeletion = opts.allowDeletion;
142
149
  this._line = opts.line;
@@ -228,6 +235,24 @@ define([
228
235
  return this._opacity;
229
236
  }
230
237
  },
238
+ borderColor: {
239
+ enumerable: true,
240
+ get: function() {
241
+ return this._borderColor;
242
+ }
243
+ },
244
+ borderWidth: {
245
+ enumerable: true,
246
+ get: function() {
247
+ return this._borderWidth;
248
+ }
249
+ },
250
+ borderRadius: {
251
+ enumerable: true,
252
+ get: function() {
253
+ return this._borderRadius;
254
+ }
255
+ },
231
256
  editable: {
232
257
  enumerable: true,
233
258
  get: function() {
@@ -281,6 +306,9 @@ define([
281
306
  hoverColor: this.hoverColor,
282
307
  warningColor: this.warningColor,
283
308
  opacity: this.opacity,
309
+ borderColor: this.borderColor,
310
+ borderWidth: this.borderWidth,
311
+ borderRadius: this.borderRadius,
284
312
  editable: this.editable,
285
313
  allowDeletion: this.allowDeletion,
286
314
  line: this.line,
@@ -301,6 +329,9 @@ define([
301
329
  this._hoverColor = opts.hoverColor;
302
330
  this._warningColor = opts.warningColor;
303
331
  this._opacity = opts.opacity;
332
+ this._borderColor = opts.borderColor;
333
+ this._borderWidth = opts.borderWidth;
334
+ this._borderRadius = opts.borderRadius;
304
335
  this._editable = opts.editable;
305
336
  this._allowDeletion = opts.allowDeletion;
306
337
  this._line = opts.line;
package/src/svgs.js ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @file
3
+ *
4
+ * Defines the {@link data} class.
5
+ *
6
+ * @module data
7
+ */
8
+
9
+ define([
10
+ ], function() {
11
+ 'use strict';
12
+
13
+ /**
14
+ * A data object associated with a source.
15
+ *
16
+ * @class
17
+ * @alias Data
18
+ *
19
+ * @param {String} type The MIME type (image, video, audio...)
20
+ * @param {Object} content Content of the data retrieved.
21
+ */
22
+
23
+ /* eslint-disable max-len */
24
+ var SVGs = {
25
+ volume: {
26
+ width: 24,
27
+ height: 24,
28
+ path: 'M15.35 20.7262C15.0167 20.8595 14.7083 20.8179 14.425 20.6012C14.1417 20.3845 14 20.0845 14 19.7012C14 19.5179 14.0543 19.3555 14.163 19.2142C14.271 19.0722 14.4083 18.9679 14.575 18.9012C15.9083 18.3679 16.9793 17.5179 17.788 16.3512C18.596 15.1845 19 13.8679 19 12.4012C19 10.9345 18.596 9.61786 17.788 8.45119C16.9793 7.28452 15.9083 6.43452 14.575 5.90119C14.3917 5.83452 14.25 5.72619 14.15 5.57619C14.05 5.42619 14 5.25952 14 5.07619C14 4.70952 14.1417 4.41786 14.425 4.20119C14.7083 3.98452 15.0167 3.94286 15.35 4.07619C17.05 4.75952 18.4167 5.85119 19.45 7.35119C20.4833 8.85119 21 10.5345 21 12.4012C21 14.2679 20.4833 15.9512 19.45 17.4512C18.4167 18.9512 17.05 20.0429 15.35 20.7262ZM4 15.4262C3.71667 15.4262 3.47933 15.3302 3.288 15.1382C3.096 14.9469 3 14.7095 3 14.4262V10.4262C3 10.1429 3.096 9.90519 3.288 9.71319C3.47933 9.52186 3.71667 9.42619 4 9.42619H7L10.3 6.12619C10.6167 5.80952 10.979 5.73852 11.387 5.91319C11.7957 6.08852 12 6.40119 12 6.85119V18.0012C12 18.4512 11.7957 18.7635 11.387 18.9382C10.979 19.1135 10.6167 19.0429 10.3 18.7262L7 15.4262H4ZM14 16.4262V8.37619C14.75 8.72619 15.354 9.26786 15.812 10.0012C16.2707 10.7345 16.5 11.5429 16.5 12.4262C16.5 13.3095 16.2707 14.1095 15.812 14.8262C15.354 15.5429 14.75 16.0762 14 16.4262ZM10 9.27619L7.85 11.4262H5V13.4262H7.85L10 15.5762V9.27619Z'
29
+ },
30
+ noVolume: {
31
+ width: 24,
32
+ height: 24,
33
+ path: 'M19.275 21.675L16.95 19.35C16.7167 19.4833 16.4833 19.6123 16.25 19.737C16.0167 19.8623 15.775 19.975 15.525 20.075C15.1917 20.2083 14.8833 20.1667 14.6 19.95C14.3167 19.7333 14.175 19.4333 14.175 19.05C14.175 18.8667 14.2293 18.7043 14.338 18.563C14.446 18.421 14.5833 18.3167 14.75 18.25C14.8833 18.2 15.0127 18.1457 15.138 18.087C15.2627 18.029 15.3833 17.9667 15.5 17.9L12.175 14.575V17.35C12.175 17.8 11.9707 18.1123 11.562 18.287C11.154 18.4623 10.7917 18.3917 10.475 18.075L7.175 14.775H4.175C3.89167 14.775 3.65433 14.679 3.463 14.487C3.271 14.2957 3.175 14.0583 3.175 13.775V9.775C3.175 9.49167 3.271 9.254 3.463 9.062C3.65433 8.87067 3.89167 8.775 4.175 8.775H6.375L2.275 4.675C2.09167 4.49167 2 4.25833 2 3.975C2 3.69167 2.09167 3.45833 2.275 3.275C2.45833 3.09167 2.69167 3 2.975 3C3.25833 3 3.49167 3.09167 3.675 3.275L20.675 20.275C20.8583 20.4583 20.95 20.6917 20.95 20.975C20.95 21.2583 20.8583 21.4917 20.675 21.675C20.4917 21.8583 20.2583 21.95 19.975 21.95C19.6917 21.95 19.4583 21.8583 19.275 21.675ZM15.525 3.425C17.225 4.10833 18.5917 5.2 19.625 6.7C20.6583 8.2 21.175 9.88333 21.175 11.75C21.175 12.6333 21.0543 13.4833 20.813 14.3C20.571 15.1167 20.225 15.875 19.775 16.575L18.325 15.125C18.6083 14.6083 18.821 14.0667 18.963 13.5C19.1043 12.9333 19.175 12.35 19.175 11.75C19.175 10.2833 18.771 8.96667 17.963 7.8C17.1543 6.63333 16.0833 5.78333 14.75 5.25C14.5667 5.18333 14.425 5.075 14.325 4.925C14.225 4.775 14.175 4.60833 14.175 4.425C14.175 4.05833 14.3167 3.76667 14.6 3.55C14.8833 3.33333 15.1917 3.29167 15.525 3.425ZM16.425 13.225L14.175 10.975V7.725C14.9583 8.09167 15.571 8.64167 16.013 9.375C16.4543 10.1083 16.675 10.9083 16.675 11.775C16.675 12.025 16.6543 12.271 16.613 12.513C16.571 12.7543 16.5083 12.9917 16.425 13.225ZM12.175 8.975L9.575 6.375L10.475 5.475C10.7917 5.15833 11.154 5.08733 11.562 5.262C11.9707 5.43733 12.175 5.75 12.175 6.2V8.975ZM10.175 14.925V12.575L8.375 10.775H5.175V12.775H8.025L10.175 14.925Z'
34
+ },
35
+ visibility: {
36
+ width: 24,
37
+ height: 24,
38
+ path: 'M11.9998 17C13.2498 17 14.3125 16.5627 15.1878 15.688C16.0625 14.8127 16.4998 13.75 16.4998 12.5C16.4998 11.25 16.0625 10.1873 15.1878 9.312C14.3125 8.43733 13.2498 8 11.9998 8C10.7498 8 9.68714 8.43733 8.8118 9.312C7.93714 10.1873 7.4998 11.25 7.4998 12.5C7.4998 13.75 7.93714 14.8127 8.8118 15.688C9.68714 16.5627 10.7498 17 11.9998 17ZM11.9998 15.2C11.2498 15.2 10.6125 14.9373 10.0878 14.412C9.56247 13.8873 9.2998 13.25 9.2998 12.5C9.2998 11.75 9.56247 11.1123 10.0878 10.587C10.6125 10.0623 11.2498 9.8 11.9998 9.8C12.7498 9.8 13.3875 10.0623 13.9128 10.587C14.4375 11.1123 14.6998 11.75 14.6998 12.5C14.6998 13.25 14.4375 13.8873 13.9128 14.412C13.3875 14.9373 12.7498 15.2 11.9998 15.2ZM11.9998 20C9.68314 20 7.56647 19.3877 5.64981 18.163C3.73314 16.9377 2.28314 15.2833 1.2998 13.2C1.2498 13.1167 1.21647 13.0123 1.1998 12.887C1.18314 12.7623 1.1748 12.6333 1.1748 12.5C1.1748 12.3667 1.18314 12.2373 1.1998 12.112C1.21647 11.9873 1.2498 11.8833 1.2998 11.8C2.28314 9.71667 3.73314 8.06267 5.64981 6.838C7.56647 5.61267 9.68314 5 11.9998 5C14.3165 5 16.4331 5.61267 18.3498 6.838C20.2665 8.06267 21.7165 9.71667 22.6998 11.8C22.7498 11.8833 22.7831 11.9873 22.7998 12.112C22.8165 12.2373 22.8248 12.3667 22.8248 12.5C22.8248 12.6333 22.8165 12.7623 22.7998 12.887C22.7831 13.0123 22.7498 13.1167 22.6998 13.2C21.7165 15.2833 20.2665 16.9377 18.3498 18.163C16.4331 19.3877 14.3165 20 11.9998 20ZM11.9998 18C13.8831 18 15.6125 17.504 17.1878 16.512C18.7625 15.5207 19.9665 14.1833 20.7998 12.5C19.9665 10.8167 18.7625 9.479 17.1878 8.487C15.6125 7.49567 13.8831 7 11.9998 7C10.1165 7 8.38714 7.49567 6.8118 8.487C5.23714 9.479 4.03314 10.8167 3.1998 12.5C4.03314 14.1833 5.23714 15.5207 6.8118 16.512C8.38714 17.504 10.1165 18 11.9998 18Z'
39
+ },
40
+ noVisibility: {
41
+ width: 24,
42
+ height: 24,
43
+ path: 'M16.0998 13.3L14.6498 11.85C14.7998 11.0666 14.5748 10.3333 13.9748 9.64998C13.3748 8.96664 12.5998 8.69998 11.6498 8.84998L10.1998 7.39998C10.4831 7.26664 10.7705 7.16664 11.0618 7.09998C11.3538 7.03331 11.6665 6.99998 11.9998 6.99998C13.2498 6.99998 14.3125 7.43731 15.1878 8.31198C16.0625 9.18731 16.4998 10.25 16.4998 11.5C16.4998 11.8333 16.4665 12.146 16.3998 12.438C16.3331 12.7293 16.2331 13.0166 16.0998 13.3ZM19.2998 16.45L17.8498 15.05C18.4831 14.5666 19.0458 14.0373 19.5378 13.462C20.0291 12.8873 20.4498 12.2333 20.7998 11.5C19.9665 9.81664 18.7705 8.47898 17.2118 7.48698C15.6538 6.49564 13.9165 5.99998 11.9998 5.99998C11.5165 5.99998 11.0415 6.03331 10.5748 6.09998C10.1081 6.16664 9.6498 6.26664 9.1998 6.39998L7.64981 4.84998C8.33314 4.56664 9.03314 4.35398 9.7498 4.21198C10.4665 4.07064 11.2165 3.99998 11.9998 3.99998C14.3831 3.99998 16.5248 4.62898 18.4248 5.88698C20.3248 7.14564 21.7498 8.78331 22.6998 10.8C22.7498 10.8833 22.7831 10.9873 22.7998 11.112C22.8165 11.2373 22.8248 11.3666 22.8248 11.5C22.8248 11.6333 22.8125 11.7623 22.7878 11.887C22.7625 12.0123 22.7331 12.1166 22.6998 12.2C22.3165 13.05 21.8375 13.8333 21.2628 14.55C20.6875 15.2666 20.0331 15.9 19.2998 16.45ZM19.0998 21.9L15.5998 18.45C15.0165 18.6333 14.4291 18.771 13.8378 18.863C13.2458 18.9543 12.6331 19 11.9998 19C9.61647 19 7.4748 18.371 5.5748 17.113C3.6748 15.8543 2.2498 14.2166 1.2998 12.2C1.2498 12.1166 1.21647 12.0123 1.1998 11.887C1.18314 11.7623 1.1748 11.6333 1.1748 11.5C1.1748 11.3666 1.18314 11.2416 1.1998 11.125C1.21647 11.0083 1.2498 10.9083 1.2998 10.825C1.6498 10.075 2.06647 9.38331 2.5498 8.74998C3.03314 8.11664 3.56647 7.53331 4.1498 6.99998L2.0748 4.89998C1.89147 4.71664 1.7998 4.48731 1.7998 4.21198C1.7998 3.93731 1.8998 3.69998 2.0998 3.49998C2.28314 3.31664 2.51647 3.22498 2.7998 3.22498C3.08314 3.22498 3.31647 3.31664 3.4998 3.49998L20.4998 20.5C20.6831 20.6833 20.7791 20.9126 20.7878 21.188C20.7958 21.4626 20.6998 21.7 20.4998 21.9C20.3165 22.0833 20.0831 22.175 19.7998 22.175C19.5165 22.175 19.2831 22.0833 19.0998 21.9ZM5.5498 8.39998C5.06647 8.83331 4.6248 9.30831 4.2248 9.82498C3.8248 10.3416 3.48314 10.9 3.1998 11.5C4.03314 13.1833 5.22881 14.5206 6.78681 15.512C8.34547 16.504 10.0831 17 11.9998 17C12.3331 17 12.6581 16.9793 12.9748 16.938C13.2915 16.896 13.6165 16.85 13.9498 16.8L13.0498 15.85C12.8665 15.9 12.6915 15.9373 12.5248 15.962C12.3581 15.9873 12.1831 16 11.9998 16C10.7498 16 9.68714 15.5626 8.8118 14.688C7.93714 13.8126 7.4998 12.75 7.4998 11.5C7.4998 11.3166 7.51214 11.1416 7.53681 10.975C7.56214 10.8083 7.5998 10.6333 7.64981 10.45L5.5498 8.39998Z'
44
+ }
45
+ };
46
+ /* eslint-enable max-len */
47
+
48
+ return SVGs;
49
+ });
@@ -139,6 +139,9 @@ define([
139
139
  options.hoverColor,
140
140
  options.warningColor,
141
141
  options.opacity || 1,
142
+ options.borderColor,
143
+ options.borderWidth,
144
+ options.borderRadius,
142
145
  options.editable,
143
146
  options.allowDeletion || false,
144
147
  options.line,