mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
Moving mouseover
handler into function for calling it from mousemove
This commit is contained in:
parent
c8bd0c9c33
commit
53d345ddff
1 changed files with 5 additions and 3 deletions
|
@ -130,7 +130,7 @@ function createItem(list: HTMLUListElement, suggestion: TermSuggestion) {
|
||||||
item.textContent = suggestion.label;
|
item.textContent = suggestion.label;
|
||||||
item.dataset.value = suggestion.value;
|
item.dataset.value = suggestion.value;
|
||||||
|
|
||||||
item.addEventListener('mouseover', () => {
|
function onItemMouseOver() {
|
||||||
// Prevent selection when mouse entered the element without actually moving.
|
// Prevent selection when mouse entered the element without actually moving.
|
||||||
if (ignoreMouseOver) {
|
if (ignoreMouseOver) {
|
||||||
return;
|
return;
|
||||||
|
@ -138,7 +138,9 @@ function createItem(list: HTMLUListElement, suggestion: TermSuggestion) {
|
||||||
|
|
||||||
removeSelected();
|
removeSelected();
|
||||||
item.classList.add('autocomplete__item--selected');
|
item.classList.add('autocomplete__item--selected');
|
||||||
});
|
}
|
||||||
|
|
||||||
|
item.addEventListener('mouseover', onItemMouseOver);
|
||||||
|
|
||||||
item.addEventListener('mouseout', () => {
|
item.addEventListener('mouseout', () => {
|
||||||
removeSelected();
|
removeSelected();
|
||||||
|
@ -148,7 +150,7 @@ function createItem(list: HTMLUListElement, suggestion: TermSuggestion) {
|
||||||
'mousemove',
|
'mousemove',
|
||||||
() => {
|
() => {
|
||||||
ignoreMouseOver = false;
|
ignoreMouseOver = false;
|
||||||
item.dispatchEvent(new CustomEvent('mouseover'));
|
onItemMouseOver();
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
once: true,
|
once: true,
|
||||||
|
|
Loading…
Reference in a new issue