I have an onclick event and when i click on an object, i notice that if i use a console.log to check if i clicked, each click gives about 6 "hits" for the one click, how can i stop the propagation of clicks after the first so that only the event is only triggered once per click?
var that = this;
var keys = [];
var click = false;
var canvas;
var mEvent = null;
document.addEventListener('mousedown', function (e) {
e.stopPropagation();
e.preventDefault();
that.mEvent = e;
that.click = true;
});
document.addEventListener('mouseup', function (e) {
e.stopPropagation();
e.preventDefault();
that.click = false;
});
function mousedown() {
return click;
}
That should not happen. Make sure you are not registering these events from a function and calling that function multiple times.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.