Add on-mouseup and on-mousedown processing

This commit is contained in:
Isaac Connor 2021-04-16 10:15:57 -04:00
parent 408e0963a0
commit 354a3d9f09
1 changed files with 22 additions and 0 deletions

View File

@ -126,6 +126,28 @@ function dataOnClick() {
window[fnName](ev); window[fnName](ev);
}; };
}); });
document.querySelectorAll("button[data-on-mousedown]").forEach(function(el) {
var fnName = el.getAttribute("data-on-mousedown");
if ( !window[fnName] ) {
console.error("Nothing found to bind to " + fnName + " on element " + el.name);
return;
}
el.onmousedown = function(ev) {
window[fnName](ev);
};
});
document.querySelectorAll("button[data-on-mouseup]").forEach(function(el) {
var fnName = el.getAttribute("data-on-mouseup");
if ( !window[fnName] ) {
console.error("Nothing found to bind to " + fnName + " on element " + el.name);
return;
}
el.onmouseup = function(ev) {
window[fnName](ev);
};
});
} }