From 410a54b19be1e489f16e0b637316ad4e90f6603f Mon Sep 17 00:00:00 2001 From: mk-pmb Date: Sun, 14 Jul 2024 00:16:38 +0200 Subject: [PATCH] Adjust mouse hover event names to match other events. --- src/components/anno-viewer/anno-viewer.html | 4 ++-- src/components/anno-viewer/anno-viewer.js | 26 ++++++++++----------- src/default-config/events.md | 2 +- test/html/tests.fragment-selector.js | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/anno-viewer/anno-viewer.html b/src/components/anno-viewer/anno-viewer.html index 93eb5b6..fd2266b 100644 --- a/src/components/anno-viewer/anno-viewer.html +++ b/src/components/anno-viewer/anno-viewer.html @@ -12,8 +12,8 @@ (otherVersionsExist() ? 'has' : 'no') + '-other-versions', (isOwnAnno && 'own-anno'), ].filter(Boolean)" - v-on:mouseover.stop="mouseenter" - v-on:mouseleave.stop="mouseleave" + @mouseenter="onMouseEnter" + @mouseleave="onMouseLeave" :data-w3-anno-id="annoIdUrl" :data-iana-working-copy="annotation['iana:working-copy']" :data-target-fragment="targetFragment" diff --git a/src/components/anno-viewer/anno-viewer.js b/src/components/anno-viewer/anno-viewer.js index a2bfba6..9c33dd5 100644 --- a/src/components/anno-viewer/anno-viewer.js +++ b/src/components/anno-viewer/anno-viewer.js @@ -44,8 +44,8 @@ const xrxUtilsUtils = require('./xrxUtilsUtils.js'); * - `reply`: A new annotation as a reply to this annotation should be opened in an editor * - `startHighlighting`: Start highlighting this annotation * - `stopHighlighting`: Stop highlighting this annotation - * - `mouseenter`: The mouse cursor is now on this annotation - * - `mouseleave`: The mouse cursor has left this annotation + * - `mouseEnter`: The mouse cursor is now on this annotation + * - `mouseLeave`: The mouse cursor has left this annotation */ function firstEntryIfArray(x) { return (x && Array.isArray(x) && x[0]); } @@ -437,21 +437,21 @@ module.exports = { return setDoiMsg('mint_doi.success'); }, - mouseenter() { - this.startHighlighting(); - eventBus.$emit('mouseenter', this.makeEventContext()); + onMouseEnter() { + this.startHighlighting(); + eventBus.$emit('mouseEnter', this.makeEventContext()); }, - mouseleave() { - this.stopHighlighting(); - eventBus.$emit('mouseleave', this.makeEventContext()); + onMouseLeave() { + this.stopHighlighting(); + eventBus.$emit('mouseLeave', this.makeEventContext()); }, - startHighlighting(expand) { - this.highlighted = true - if (expand) eventBus.$emit('expand', this.annoIdUrl, true) + startHighlighting(expand) { + this.highlighted = true; + if (expand) { eventBus.$emit('expand', this.annoIdUrl, true); } }, - stopHighlighting() {this.highlighted = false}, - toggleHighlighting() {this.highlighted = ! this.highlighted}, + stopHighlighting() { this.highlighted = false; }, + toggleHighlighting() { this.highlighted = !this.highlighted; }, collapse(command) { const el = this; diff --git a/src/default-config/events.md b/src/default-config/events.md index 17fba67..20df3b4 100644 --- a/src/default-config/events.md +++ b/src/default-config/events.md @@ -9,7 +9,7 @@ handlers (event name → function). Currently, these are supported: Fired after the AnnoApp has been installed into the DOM. A single argument is passed: The reference to the AnnoApp. -### `mouseover`, `mouseleave` +### `mouseEnter`, `mouseLeave` Fired when the mouse pointer hovers/unhovers an annotation. For details, see the anno-viewer component documentation. diff --git a/test/html/tests.fragment-selector.js b/test/html/tests.fragment-selector.js index 1825674..57ee709 100644 --- a/test/html/tests.fragment-selector.js +++ b/test/html/tests.fragment-selector.js @@ -22,11 +22,11 @@ window.location.hash = '#' + fragId; }, - mouseenter(ev) { + mouseEnter(ev) { const fragId = ev.dataApi('findTargetFragment'); setUniqueCssClassByDomId('hovering', fragId); }, - mouseleave() { setUniqueCssClassByDomId('hovering'); }, + mouseLeave() { setUniqueCssClassByDomId('hovering'); }, }); }());