Click and Hold event listener with Javascript

前端 未结 2 1915
终归单人心
终归单人心 2021-01-15 05:10

I want to make a page with Click and Hold event effect, like http://andeinerseite.video/ or http://2016.makemepulse.com/, I\'m interested in what framework uses to create th

2条回答
  •  既然无缘
    2021-01-15 06:03

    With plain javascript you can do something like this:

    selector.addEventListener('mousedown', function(event) { 
      // simulating hold event
      setTimeout(function() {
        // You are now in a hold state, you can do whatever you like!
      }, 500);
    });
    

    You can tweak the 500ms value to any timespan fits your needs.

提交回复
热议问题