@guardian/interactive-component-library 0.7.0 → 0.7.1

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.
@@ -26,6 +26,9 @@ export class TextLayer {
26
26
  * called with the hovered feature, and the mouse event.
27
27
  *
28
28
  * The callback can optionally return a cleanup function that will be called when the mouse leaves this feature.
29
+ *
30
+ * Note that this callback is attached to the "pointerover" and "pointerout" events, so touch
31
+ * events will not trigger it.
29
32
  * @param {boolean} [params.restyleOnHover] If true, the layer will re-render when the mouse hovers over a feature.
30
33
  *
31
34
  * The provided style function will be called with the `isHovering` parameter set to `true` for the hovered feature.
@@ -89,6 +89,9 @@ class TextLayer {
89
89
  * called with the hovered feature, and the mouse event.
90
90
  *
91
91
  * The callback can optionally return a cleanup function that will be called when the mouse leaves this feature.
92
+ *
93
+ * Note that this callback is attached to the "pointerover" and "pointerout" events, so touch
94
+ * events will not trigger it.
92
95
  * @param {boolean} [params.restyleOnHover] If true, the layer will re-render when the mouse hovers over a feature.
93
96
  *
94
97
  * The provided style function will be called with the `isHovering` parameter set to `true` for the hovered feature.
@@ -276,7 +276,7 @@ class TextLayerRenderer {
276
276
  });
277
277
  }
278
278
  if (this.layer.onHover) {
279
- this._element.addEventListener("mouseover", (event) => {
279
+ this._element.addEventListener("pointerover", (event) => {
280
280
  if (!event.target) return;
281
281
  const hoveredFeature = this.layer.source.getFeatures().find((feature) => {
282
282
  var _a;
@@ -285,14 +285,14 @@ class TextLayerRenderer {
285
285
  if (!hoveredFeature) return;
286
286
  const onHoverLeave = this.layer.onHover(hoveredFeature, event);
287
287
  if (onHoverLeave) {
288
- this._element.addEventListener("mouseout", onHoverLeave, {
288
+ this._element.addEventListener("pointerout", onHoverLeave, {
289
289
  once: true
290
290
  });
291
291
  }
292
292
  });
293
293
  }
294
294
  if (this.layer.restyleOnHover) {
295
- this._element.addEventListener("mouseover", (event) => {
295
+ this._element.addEventListener("pointerover", (event) => {
296
296
  if (!event.target) return;
297
297
  const hoveredFeature = this.layer.source.getFeatures().find((feature) => {
298
298
  var _a;
@@ -302,7 +302,7 @@ class TextLayerRenderer {
302
302
  this._hoveredFeature = hoveredFeature;
303
303
  this.layer.dispatcher.dispatch(MapEvent.CHANGE);
304
304
  this._element.addEventListener(
305
- "mouseout",
305
+ "pointerout",
306
306
  () => {
307
307
  this._hoveredFeature = void 0;
308
308
  this.layer.dispatcher.dispatch(MapEvent.CHANGE);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@guardian/interactive-component-library",
3
3
  "private": false,
4
- "version": "0.7.0",
4
+ "version": "0.7.1",
5
5
  "packageManager": "pnpm@8.4.0",
6
6
  "repository": {
7
7
  "type": "git",