@checksub_team/peaks_timeline 1.5.8 → 1.5.10

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.8",
3
+ "version": "1.5.10",
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
@@ -14306,6 +14306,7 @@ module.exports = function (Konva, Utils, SVGs) {
14306
14306
  noVisibility: this._peaks.options.lineIndicatorNoVisibilityIconSize
14307
14307
  }
14308
14308
  };
14309
+ this._yPadding = 30;
14309
14310
  this._defaultPadding = 5;
14310
14311
  this._types = ['default'].concat(Object.keys(SVGs));
14311
14312
  this._stage = new Konva.Stage({
@@ -14376,10 +14377,12 @@ module.exports = function (Konva, Utils, SVGs) {
14376
14377
  text: text,
14377
14378
  fontSize: this._sizes.font,
14378
14379
  fontFamily: 'Arial',
14379
- fill: this._peaks.options.lineIndicatorColor,
14380
+ fill: this._peaks.options.lineIndicatorTextColor,
14380
14381
  align: 'center',
14381
14382
  width: this._width
14382
14383
  });
14384
+ textNode.setAttr('defaultColor', this._peaks.options.lineIndicatorTextColor);
14385
+ textNode.setAttr('selectedColor', this._peaks.options.lineIndicatorSelectedTextColor);
14383
14386
  indicator.add(textNode);
14384
14387
  indicatorHeight += this._sizes.font;
14385
14388
  }
@@ -14391,7 +14394,7 @@ module.exports = function (Konva, Utils, SVGs) {
14391
14394
  x: this._width / 2,
14392
14395
  y: indicatorHeight + this._sizes.icon.default / 2 + padding,
14393
14396
  radius: this._sizes.icon.default / 2,
14394
- fill: this._peaks.options.lineIndicatorColor,
14397
+ fill: this._peaks.options.lineIndicatorIconColor,
14395
14398
  strokeWidth: 0,
14396
14399
  lineId: line.getId()
14397
14400
  });
@@ -14401,7 +14404,7 @@ module.exports = function (Konva, Utils, SVGs) {
14401
14404
  x: (this._width - this._sizes.icon[type]) / 2,
14402
14405
  y: indicatorHeight,
14403
14406
  data: SVGs[type].path,
14404
- fill: this._peaks.options.lineIndicatorColor,
14407
+ fill: this._peaks.options.lineIndicatorIconColor,
14405
14408
  scale: {
14406
14409
  x: this._sizes.icon[type] / SVGs[type].width,
14407
14410
  y: this._sizes.icon[type] / SVGs[type].height
@@ -14409,6 +14412,8 @@ module.exports = function (Konva, Utils, SVGs) {
14409
14412
  lineId: line.getId()
14410
14413
  });
14411
14414
  }
14415
+ iconNode.setAttr('defaultColor', this._peaks.options.lineIndicatorIconColor);
14416
+ iconNode.setAttr('selectedColor', this._peaks.options.lineIndicatorSelectedIconColor);
14412
14417
  indicator.add(iconNode);
14413
14418
  indicatorHeight += this._sizes.icon[type];
14414
14419
  indicator.setAttr('trueHeight', indicatorHeight);
@@ -14416,13 +14421,13 @@ module.exports = function (Konva, Utils, SVGs) {
14416
14421
  var self = this;
14417
14422
  indicator.on('mouseover', function () {
14418
14423
  indicator.getChildren().forEach(function (child) {
14419
- child.fill(self._peaks.options.lineIndicatorSelected);
14424
+ child.fill(child.getAttr('selectedColor'));
14420
14425
  });
14421
14426
  self.draw();
14422
14427
  });
14423
14428
  indicator.on('mouseout', function () {
14424
14429
  indicator.getChildren().forEach(function (child) {
14425
- child.fill(self._peaks.options.lineIndicatorColor);
14430
+ child.fill(child.getAttr('defaultColor'));
14426
14431
  });
14427
14432
  self.draw();
14428
14433
  });
@@ -14445,6 +14450,7 @@ module.exports = function (Konva, Utils, SVGs) {
14445
14450
  LineIndicator.prototype.removeIndicator = function (lineId, keepInList) {
14446
14451
  if (this._indicators[lineId]) {
14447
14452
  if (this._indicators[lineId].indicator) {
14453
+ console.log('remove', lineId);
14448
14454
  this._indicators[lineId].indicator.destroy();
14449
14455
  }
14450
14456
  if (!keepInList) {
@@ -14456,13 +14462,13 @@ module.exports = function (Konva, Utils, SVGs) {
14456
14462
  };
14457
14463
  LineIndicator.prototype.updateIndicator = function (lineId) {
14458
14464
  if (this._indicators[lineId]) {
14459
- var y = this._indicators[lineId].line.getY() + this._indicators[lineId].line.lineHeight() / 2;
14460
- if (y + this._indicators[lineId].line.lineHeight() > 0 && y < this._height) {
14465
+ var y = this._indicators[lineId].line.getY();
14466
+ if (y + this._indicators[lineId].line.lineHeight() + this._yPadding > 0 && y - this._yPadding < this._height) {
14461
14467
  if (!this._indicators[lineId].indicator) {
14462
14468
  this._indicators[lineId].indicator = this._createIndicator(this._indicators[lineId].line, this._indicators[lineId].type, this._indicators[lineId].text);
14463
14469
  this._layer.add(this._indicators[lineId].indicator);
14464
14470
  } else {
14465
- this._indicators[lineId].indicator.y(y - this._indicators[lineId].indicator.getAttr('trueHeight') / 2);
14471
+ this._indicators[lineId].indicator.y(y + this._indicators[lineId].line.lineHeight() / 2 - this._indicators[lineId].indicator.getAttr('trueHeight') / 2);
14466
14472
  }
14467
14473
  } else {
14468
14474
  this.removeIndicator(lineId, true);
@@ -15417,8 +15423,10 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
15417
15423
  lineIndicatorVisibilityIconSize: 24,
15418
15424
  lineIndicatorNoVisibilityIconSize: 24,
15419
15425
  lineIndicatorFontSize: 10,
15420
- lineIndicatorColor: '#8A8F98',
15421
- lineIndicatorSelected: '#ccc',
15426
+ lineIndicatorTextColor: '#8A8F98',
15427
+ lineIndicatorIconColor: '#8A8F98',
15428
+ lineIndicatorSelectedTextColor: '#ccc',
15429
+ lineIndicatorSelectedIconColor: '#ccc',
15422
15430
  autoScrollThreshold: 0.05,
15423
15431
  enableLineIndicatorContextMenu: true,
15424
15432
  minSourceSize: 0.05,
@@ -45,6 +45,7 @@ define([
45
45
  }
46
46
  };
47
47
 
48
+ this._yPadding = 30;
48
49
  this._defaultPadding = 5;
49
50
  this._types = ['default'].concat(Object.keys(SVGs));
50
51
 
@@ -140,11 +141,14 @@ define([
140
141
  text: text,
141
142
  fontSize: this._sizes.font,
142
143
  fontFamily: 'Arial',
143
- fill: this._peaks.options.lineIndicatorColor,
144
+ fill: this._peaks.options.lineIndicatorTextColor,
144
145
  align: 'center',
145
146
  width: this._width
146
147
  });
147
148
 
149
+ textNode.setAttr('defaultColor', this._peaks.options.lineIndicatorTextColor);
150
+ textNode.setAttr('selectedColor', this._peaks.options.lineIndicatorSelectedTextColor);
151
+
148
152
  indicator.add(textNode);
149
153
  indicatorHeight += this._sizes.font;
150
154
  }
@@ -160,7 +164,7 @@ define([
160
164
  x: this._width / 2,
161
165
  y: indicatorHeight + this._sizes.icon.default / 2 + padding,
162
166
  radius: this._sizes.icon.default / 2,
163
- fill: this._peaks.options.lineIndicatorColor,
167
+ fill: this._peaks.options.lineIndicatorIconColor,
164
168
  strokeWidth: 0,
165
169
  lineId: line.getId()
166
170
  });
@@ -172,7 +176,7 @@ define([
172
176
  x: (this._width - this._sizes.icon[type]) / 2,
173
177
  y: indicatorHeight,
174
178
  data: SVGs[type].path,
175
- fill: this._peaks.options.lineIndicatorColor,
179
+ fill: this._peaks.options.lineIndicatorIconColor,
176
180
  scale: {
177
181
  x: (this._sizes.icon[type]) / SVGs[type].width,
178
182
  y: (this._sizes.icon[type]) / SVGs[type].height
@@ -181,6 +185,9 @@ define([
181
185
  });
182
186
  }
183
187
 
188
+ iconNode.setAttr('defaultColor', this._peaks.options.lineIndicatorIconColor);
189
+ iconNode.setAttr('selectedColor', this._peaks.options.lineIndicatorSelectedIconColor);
190
+
184
191
  indicator.add(iconNode);
185
192
  indicatorHeight += this._sizes.icon[type];
186
193
 
@@ -192,14 +199,14 @@ define([
192
199
 
193
200
  indicator.on('mouseover', function() {
194
201
  indicator.getChildren().forEach(function(child) {
195
- child.fill(self._peaks.options.lineIndicatorSelected);
202
+ child.fill(child.getAttr('selectedColor'));
196
203
  });
197
204
  self.draw();
198
205
  });
199
206
 
200
207
  indicator.on('mouseout', function() {
201
208
  indicator.getChildren().forEach(function(child) {
202
- child.fill(self._peaks.options.lineIndicatorColor);
209
+ child.fill(child.getAttr('defaultColor'));
203
210
  });
204
211
  self.draw();
205
212
  });
@@ -228,6 +235,7 @@ define([
228
235
  LineIndicator.prototype.removeIndicator = function(lineId, keepInList) {
229
236
  if (this._indicators[lineId]) {
230
237
  if (this._indicators[lineId].indicator) {
238
+ console.log('remove', lineId);
231
239
  this._indicators[lineId].indicator.destroy();
232
240
  }
233
241
  if (!keepInList) {
@@ -241,10 +249,9 @@ define([
241
249
 
242
250
  LineIndicator.prototype.updateIndicator = function(lineId) {
243
251
  if (this._indicators[lineId]) {
244
- var y = this._indicators[lineId].line.getY()
245
- + (this._indicators[lineId].line.lineHeight() / 2);
252
+ var y = this._indicators[lineId].line.getY();
246
253
 
247
- if (y + this._indicators[lineId].line.lineHeight() > 0 && y < this._height) {
254
+ if (y + this._indicators[lineId].line.lineHeight() + this._yPadding > 0 && y - this._yPadding < this._height) {
248
255
  // The indicator is visible
249
256
  if (!this._indicators[lineId].indicator) {
250
257
  this._indicators[lineId].indicator = this._createIndicator(
@@ -256,7 +263,8 @@ define([
256
263
  }
257
264
  else {
258
265
  this._indicators[lineId].indicator.y(
259
- y - this._indicators[lineId].indicator.getAttr('trueHeight') / 2
266
+ y + this._indicators[lineId].line.lineHeight() / 2
267
+ - this._indicators[lineId].indicator.getAttr('trueHeight') / 2
260
268
  );
261
269
  }
262
270
  }
package/src/main.js CHANGED
@@ -311,14 +311,24 @@ define([
311
311
  lineIndicatorFontSize: 10,
312
312
 
313
313
  /**
314
- * Color of the line indicators
314
+ * Color of the line indicators' text
315
315
  */
316
- lineIndicatorColor: '#8A8F98',
316
+ lineIndicatorTextColor: '#8A8F98',
317
317
 
318
318
  /**
319
- * Color for the indicator when selected
319
+ * Color of the line indicators' icon
320
+ */
321
+ lineIndicatorIconColor: '#8A8F98',
322
+
323
+ /**
324
+ * Color for the indicator's text when selected
325
+ */
326
+ lineIndicatorSelectedTextColor: '#ccc',
327
+
328
+ /**
329
+ * Color for the indicator's icon when selected
320
330
  */
321
- lineIndicatorSelected: '#ccc',
331
+ lineIndicatorSelectedIconColor: '#ccc',
322
332
 
323
333
  /**
324
334
  * Threshold size on the left and right border of the view,