javascript - jQuery - Bind two events to an AND operator -


is posible bind 2 events , logic operator both has active function called? have this:

foobar.bind("foo , bar", barfunc);  function barfunc(e) {     alert("foobar!"); } 

so in order barfunc called both foo , bar needs active. useful cause making slider/seeker out of divs (cannot use jquery ui slider) , need call function when both pressing down mouse button , hovering on div.

it's not possible using syntax that—the events never fire @ exact same time, 1 after other. said, following (pseudo code based off example):

var ishovering = false,     isclicking = false;  function barfunc(e) {     if(ishovering && isclicking){        alert("foobar!");     } }  foobar.on('mousedown', function(event){      isclicking = true;     barfunc(event);  }).on('mouseup', function(event){      isclicking = false;  }).on('mouseenter', function(event){      ishovering = true;     barfunc(event);  }).on('mouseleave', function(event){      ishovering = false;  }); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -