anime.js悬停在类

时间:2018-03-06 19:01:29

标签: javascript hover anime.js

我试图让这个功能在我的网站的每个按钮实例上运行。请帮忙:)



// Button Hover
var buttonEl = document.querySelector('button');

function animateButton(scale, duration) {
  anime.remove(buttonEl);
  anime({
    targets: buttonEl,
    scale: scale,
    duration: duration,
    easing: 'easeInOutQuart'
  });
}

function enterButton() { animateButton(1.05, 100) };
function leaveButton() { animateButton(1.0, 75) };

buttonEl.addEventListener('mouseenter', enterButton, false);
buttonEl.addEventListener('mouseleave', leaveButton, false);

<button class="restart">Hover Me</button>
&#13;
&#13;
&#13;

0 个答案:

没有答案