@@ -53,20 +53,33 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
53
53
var filterPoly , testPoly , mergedPolygons , currentPolygon ;
54
54
var i , cd , trace , searchInfo , eventData ;
55
55
56
- if ( fullLayout . _lastSelectedSubplot && fullLayout . _lastSelectedSubplot === plotinfo . id ) {
56
+ var selectingOnSameSubplot = (
57
+ fullLayout . _lastSelectedSubplot &&
58
+ fullLayout . _lastSelectedSubplot === plotinfo . id
59
+ ) ;
60
+
61
+ if (
62
+ selectingOnSameSubplot &&
63
+ ( e . shiftKey || e . altKey ) &&
64
+ ( plotinfo . selection && plotinfo . selection . polygons ) &&
65
+ ! dragOptions . polygons
66
+ ) {
57
67
// take over selection polygons from prev mode, if any
58
- if ( ( e . shiftKey || e . altKey ) && ( plotinfo . selection && plotinfo . selection . polygons ) && ! dragOptions . polygons ) {
59
- dragOptions . polygons = plotinfo . selection . polygons ;
60
- dragOptions . mergedPolygons = plotinfo . selection . mergedPolygons ;
61
- }
62
- // create new polygons, if shift mode
63
- else if ( ( ! e . shiftKey && ! e . altKey ) || ( ( e . shiftKey || e . altKey ) && ! plotinfo . selection ) ) {
64
- plotinfo . selection = { } ;
65
- plotinfo . selection . polygons = dragOptions . polygons = [ ] ;
66
- plotinfo . selection . mergedPolygons = dragOptions . mergedPolygons = [ ] ;
67
- }
68
- } else {
69
- // do not allow multi-selection across different subplots
68
+ dragOptions . polygons = plotinfo . selection . polygons ;
69
+ dragOptions . mergedPolygons = plotinfo . selection . mergedPolygons ;
70
+ } else if (
71
+ ( ! e . shiftKey && ! e . altKey ) ||
72
+ ( ( e . shiftKey || e . altKey ) &&
73
+ ! plotinfo . selection )
74
+ ) {
75
+ // create new polygons, if shift mode or selecting across different subplots
76
+ plotinfo . selection = { } ;
77
+ plotinfo . selection . polygons = dragOptions . polygons = [ ] ;
78
+ plotinfo . selection . mergedPolygons = dragOptions . mergedPolygons = [ ] ;
79
+ }
80
+
81
+ // clear selection outline when selecting a different subplot
82
+ if ( ! selectingOnSameSubplot ) {
70
83
clearSelect ( zoomLayer ) ;
71
84
fullLayout . _lastSelectedSubplot = plotinfo . id ;
72
85
}
0 commit comments