gridviz 3.0.39 → 3.0.40

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": "gridviz",
3
- "version": "3.0.39",
3
+ "version": "3.0.40",
4
4
  "description": "Visualization tool for gridded statistics",
5
5
  "keywords": [
6
6
  "statistics",
package/src/core/Map.js CHANGED
@@ -245,7 +245,11 @@ export class Map {
245
245
  //remove legend elements: the legends themselves only, not what is inside them
246
246
  //(a legend keeps its content while one of its swatches is hovered, see Style.updateLegends)
247
247
  //except the one being hovered, which would lose its mouseleave (see Legend.highlight)
248
- if (this.legend) this.legend.selectAll(':scope > *:not([data-gridviz-hovered])').remove()
248
+ if (this.legend) {
249
+ this.legend.selectAll(':scope > *:not([data-gridviz-hovered])').remove()
250
+ // the legends of this draw are placed one after the other (see GridLayer.addLegends)
251
+ this.legend.node()._gridvizLegendCursor = null
252
+ }
249
253
 
250
254
  //clear
251
255
  this.geoCanvas.initCanvasTransform()
@@ -137,8 +137,16 @@ export class GridLayer extends Layer {
137
137
  // so that hovering a swatch can highlight the cells of the style on the map
138
138
  lg.style_ = style
139
139
  lg.redraw = () => (geoCanvas.redraw ? geoCanvas.redraw() : undefined)
140
- // a hovered legend is still in place (see Map.redrawNow): moving it would lose its mouseleave
141
- if (lg.div.node().parentNode !== legendComp.node()) legendComp.node().append(lg.div.node())
140
+ // The legends go in the order they are drawn, after the one placed before them. A hovered legend is
141
+ // still in the container (see Map.redrawNow) and is left where it is: moving it would lose its mouseleave,
142
+ // and appending the others after it would put it above the legends that come before it.
143
+ const container = legendComp.node()
144
+ const el = lg.div.node()
145
+ const previous = container._gridvizLegendCursor
146
+ if (previous) {
147
+ if (el.previousSibling !== previous) previous.after(el)
148
+ } else if (container.firstChild !== el) container.prepend(el)
149
+ container._gridvizLegendCursor = el
142
150
  }
143
151
  }
144
152