动画结束时振动 phone?仅在单击按钮时有效

Vibrate phone when animation has finished? Only works if button is clicked

当图像完成动画(从左侧滑入)时,我希望它使用 HTML 5 振动 API:

振动 2 秒
navigator.vibrate(2000);

对按钮使用点击事件:

<button class="vibrate-button">Vibrate</button>



$('.vibrate-button').click(function(){
        navigator.vibrate(2000);
    });

但当我尝试在动画结束时调用它时却没有:

    $('.iphone-image').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(event) {
        console.log('Animation has finished');
        navigator.vibrate(2000);
  });

演示: https://codepen.io/ifusion/pen/rzRzEO

如何让它在动画结束时振动?

这篇文章说,由于被恶意网站滥用,他们已经禁用了这个功能我试过同样的 returns false on console only on click it returns true.

https://www.chromestatus.com/feature/5644273861001216