Как вызвать функцию-обработчик события mouseenter через 2 сек?

Вешаю событие mouseenter на все li в меню

this.settings.topItemMenu.forEach(li => {
  li.addEventListener('mouseenter', _this.mouseenterTopMenu.bind(_this));
})

Мне нужно вызывать метод _this.mouseenterTopMenu.bind(_this) при наведении через 2 секунды. Пробую делать так:

this.settings.topItemMenu.forEach(li => {
      let myFunc = _this.mouseenterTopMenu.bind(_this);
      li.addEventListener('mouseenter', function() {
        setTimeout(myFunc, 2000)
      });

Но появляется ошибка в самом методе:

mouseenterTopMenu: function(e) { //здесь e - undefined

  if (this.isMobile()) {
    return;
  }
  const li = e.currentTarget; // cannot read property currentTarget of undefined
  e.preventDefault();

  this.closeMenu();
  this.setTopHover(li);
},

Ответы (1 шт):

Автор решения: Unkn

Попробуйте вот так:

this.settings.topItemMenu.forEach(li => {
    let myFunc = _this.mouseenterTopMenu.bind(_this);
    li.addEventListener('mouseenter', function(e) {
       setTimeout(myFunc, 2000, e)
    });
});
→ Ссылка