javascript - How do you "bypass" mouse up? -


i trying make when user clicks down, happens.

in order,

does something. (not being specific, isn't important part.)

mouse triggered.

using: angular, html, css. not using: jquery

any suggestions? thanks!

you attach 2 event listeners, 1 while user has mouse pressed down mousedown. once user lets go mouseup event triggered. mouse event listeners passed event object can use information event ie: mouse x, , y positions.one of methods available event.preventdefault() stop browser doing wants do. example: cmd/ctrl + s cause browser save html page. preventdefault stop this.

document.addeventlistener('mousedown' function (event) {     // }) document.addeventlistener('mouseup', function (event) {     event.preventdefault() }) 

to address op comment:

var nomouseup = true document.addeventlistener('mousedown', function () {   if (nomouseup) {       //       nomouseup = false   } }) document.addeventlistener('mouseup', function (event) {  if (!nomouseup) {     nomouseup = true  } 

})


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -