plotly.js 2.13.2 → 2.13.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": "plotly.js",
3
- "version": "2.13.2",
3
+ "version": "2.13.3",
4
4
  "description": "The open source javascript graphing library that powers plotly",
5
5
  "license": "MIT",
6
6
  "main": "./lib/index.js",
@@ -174,6 +174,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
174
174
  }
175
175
 
176
176
  if(selectionErased) {
177
+ gd._fullLayout._noEmitSelectedAtStart = true;
178
+
177
179
  Registry.call('_guiRelayout', gd, {
178
180
  selections: list
179
181
  });
@@ -315,10 +317,10 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
315
317
  displayOutlines(convertPoly(mergedPolygons, isOpenMode), outlines, dragOptions);
316
318
 
317
319
  if(isSelectMode) {
318
- var _res = reselect(gd);
320
+ var _res = reselect(gd, false);
319
321
  var extraPoints = _res.eventData ? _res.eventData.points.slice() : [];
320
322
 
321
- _res = reselect(gd, selectionTesters, searchTraces, dragOptions);
323
+ _res = reselect(gd, false, selectionTesters, searchTraces, dragOptions);
322
324
  selectionTesters = _res.selectionTesters;
323
325
  eventData = _res.eventData;
324
326
 
@@ -412,9 +414,13 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
412
414
  }
413
415
  }
414
416
 
415
- Registry.call('_guiRelayout', gd, {
416
- selections: subSelections
417
- });
417
+ if(subSelections.length < allSelections.length) {
418
+ gd._fullLayout._noEmitSelectedAtStart = true;
419
+
420
+ Registry.call('_guiRelayout', gd, {
421
+ selections: subSelections
422
+ });
423
+ }
418
424
  }
419
425
  }
420
426
  } else {
@@ -733,6 +739,8 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
733
739
  selections = newSelections(outlines, dragOptions);
734
740
  }
735
741
  if(selections) {
742
+ gd._fullLayout._noEmitSelectedAtStart = true;
743
+
736
744
  Registry.call('_guiRelayout', gd, {
737
745
  selections: selections
738
746
  }).then(function() {
@@ -1070,7 +1078,7 @@ function _doSelect(selectionTesters, searchTraces) {
1070
1078
  return allSelections;
1071
1079
  }
1072
1080
 
1073
- function reselect(gd, selectionTesters, searchTraces, dragOptions) {
1081
+ function reselect(gd, mayEmitSelected, selectionTesters, searchTraces, dragOptions) {
1074
1082
  var hadSearchTraces = !!searchTraces;
1075
1083
  var plotinfo, xRef, yRef;
1076
1084
  if(dragOptions) {
@@ -1193,15 +1201,15 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
1193
1201
  updateSelectedState(gd, allSearchTraces, eventData);
1194
1202
 
1195
1203
  var clickmode = fullLayout.clickmode;
1196
- var sendEvents = clickmode.indexOf('event') > -1;
1204
+ var sendEvents = clickmode.indexOf('event') > -1 && mayEmitSelected;
1197
1205
 
1198
1206
  if(
1199
1207
  !plotinfo && // get called from plot_api & plots
1200
- fullLayout._reselect
1208
+ mayEmitSelected
1201
1209
  ) {
1202
- if(sendEvents) {
1203
- var activePolygons = getLayoutPolygons(gd, true);
1210
+ var activePolygons = getLayoutPolygons(gd, true);
1204
1211
 
1212
+ if(activePolygons.length) {
1205
1213
  var xref = activePolygons[0].xref;
1206
1214
  var yref = activePolygons[0].yref;
1207
1215
  if(xref && yref) {
@@ -1214,8 +1222,12 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
1214
1222
 
1215
1223
  fillRangeItems(eventData, poly);
1216
1224
  }
1225
+ }
1217
1226
 
1218
- emitSelected(gd, eventData);
1227
+ if(gd._fullLayout._noEmitSelectedAtStart) {
1228
+ gd._fullLayout._noEmitSelectedAtStart = false;
1229
+ } else {
1230
+ if(sendEvents) emitSelected(gd, eventData);
1219
1231
  }
1220
1232
 
1221
1233
  fullLayout._reselect = false;
@@ -1237,7 +1249,7 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
1237
1249
  if(eventData.points.length) {
1238
1250
  emitSelected(gd, eventData);
1239
1251
  } else {
1240
- gd.emit('plotly_deselect', null);
1252
+ emitDeselect(gd);
1241
1253
  }
1242
1254
  }
1243
1255
 
@@ -3364,7 +3364,16 @@ plots.redrag = function(gd) {
3364
3364
  };
3365
3365
 
3366
3366
  plots.reselect = function(gd) {
3367
- Registry.getComponentMethod('selections', 'reselect')(gd);
3367
+ var fullLayout = gd._fullLayout;
3368
+
3369
+ var A = (gd.layout || {}).selections;
3370
+ var B = fullLayout._previousSelections;
3371
+ fullLayout._previousSelections = A;
3372
+
3373
+ var mayEmitSelected = fullLayout._reselect ||
3374
+ JSON.stringify(A) !== JSON.stringify(B);
3375
+
3376
+ Registry.getComponentMethod('selections', 'reselect')(gd, mayEmitSelected);
3368
3377
  };
3369
3378
 
3370
3379
  plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subplotLayout) {
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use strict';
2
2
 
3
3
  // package version injected by `npm run preprocess`
4
- exports.version = '2.13.2';
4
+ exports.version = '2.13.3';