mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +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.dataset.value = suggestion.value;
|
||||
|
||||
item.addEventListener('mouseover', () => {
|
||||
function onItemMouseOver() {
|
||||
// Prevent selection when mouse entered the element without actually moving.
|
||||
if (ignoreMouseOver) {
|
||||
return;
|
||||
|
@ -138,7 +138,9 @@ function createItem(list: HTMLUListElement, suggestion: TermSuggestion) {
|
|||
|
||||
removeSelected();
|
||||
item.classList.add('autocomplete__item--selected');
|
||||
});
|
||||
}
|
||||
|
||||
item.addEventListener('mouseover', onItemMouseOver);
|
||||
|
||||
item.addEventListener('mouseout', () => {
|
||||
removeSelected();
|
||||
|
@ -148,7 +150,7 @@ function createItem(list: HTMLUListElement, suggestion: TermSuggestion) {
|
|||
'mousemove',
|
||||
() => {
|
||||
ignoreMouseOver = false;
|
||||
item.dispatchEvent(new CustomEvent('mouseover'));
|
||||
onItemMouseOver();
|
||||
},
|
||||
{
|
||||
once: true,
|
||||
|
|
Loading…
Reference in a new issue