1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-07-04 02:52:52 +00:00

Fix eventcatcher widget: check for event properties before accessing (#6048)

This commit is contained in:
Saq Imtiaz 2021-09-18 16:08:15 +02:00 committed by GitHub
parent baf0ee9cde
commit 2e59d770f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,6 +77,7 @@ EventWidget.prototype.render = function(parent,nextSibling) {
variables["tv-selectednode-width"] = selectedNode.offsetWidth.toString(); variables["tv-selectednode-width"] = selectedNode.offsetWidth.toString();
variables["tv-selectednode-height"] = selectedNode.offsetHeight.toString(); variables["tv-selectednode-height"] = selectedNode.offsetHeight.toString();
if(event.clientX && event.clientY) {
//Add variables for event X and Y position relative to selected node //Add variables for event X and Y position relative to selected node
selectedNodeRect = selectedNode.getBoundingClientRect(); selectedNodeRect = selectedNode.getBoundingClientRect();
variables["event-fromselected-posx"] = (event.clientX - selectedNodeRect.left).toString(); variables["event-fromselected-posx"] = (event.clientX - selectedNodeRect.left).toString();
@ -91,6 +92,7 @@ EventWidget.prototype.render = function(parent,nextSibling) {
variables["event-fromviewport-posx"] = event.clientX.toString(); variables["event-fromviewport-posx"] = event.clientX.toString();
variables["event-fromviewport-posy"] = event.clientY.toString(); variables["event-fromviewport-posy"] = event.clientY.toString();
} }
}
} else { } else {
return false; return false;
} }