css - Click and Hold event listener with Javascript -


i want make page click , hold event effect, http://andeinerseite.video/ or http://2016.makemepulse.com/, i'm interested in framework uses create effects.

you can use javascript's settimeout function , bind mousedown events. have @ snippet below:

// click , hold event listener    var timeout_id = 0,      hold_time = 1000,      hold_menu = $('.hold_menu'),      hold_trigger = $('.hold_trigger');    hold_menu.hide();    hold_trigger.mousedown(function() {      timeout_id = settimeout(menu_toggle, hold_time);  }).bind('mouseup mouseleave', function() {      cleartimeout(timeout_id);  });    function menu_toggle() {    hold_menu.toggle();  }
ul.hold_menu {    list-style: none;    padding: 0;    margin: 0;  }    ul.hold_menu a, div.hold_trigger  {     display: inline-block;     padding: 5px 15px;     border: 1px solid #ccc;     width: 300px;  }    ul.hold_menu a:link, ul.hold_menu a:visited {     color: black;     text-decoration: none;  }    ul.hold_menu a:active, ul.hold_menu a:hover {     background: #ff0;     text-decoration: none;  }    div.hold_trigger {     color: black;     cursor: pointer;  }    div.hold_trigger:hover {     background: #ccc;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>    <div class="hold_trigger">click , hold toggle menu</div>  <ul class="hold_menu">     <li><a href="#">option 1</a></li>     <li><a href="#">option 2</a></li>     <li><a href="#">option 3</a></li>  </ul>

hope helps!


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -