kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Fix eventcatcher widget: check for event properties before accessing (#6048)
rodzic
baf0ee9cde
commit
2e59d770f7
|
@ -76,20 +76,22 @@ EventWidget.prototype.render = function(parent,nextSibling) {
|
||||||
variables["tv-selectednode-posy"] = selectedNode.offsetTop.toString();
|
variables["tv-selectednode-posy"] = selectedNode.offsetTop.toString();
|
||||||
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
|
||||||
|
selectedNodeRect = selectedNode.getBoundingClientRect();
|
||||||
|
variables["event-fromselected-posx"] = (event.clientX - selectedNodeRect.left).toString();
|
||||||
|
variables["event-fromselected-posy"] = (event.clientY - selectedNodeRect.top).toString();
|
||||||
|
|
||||||
//Add variables for event X and Y position relative to selected node
|
//Add variables for event X and Y position relative to event catcher node
|
||||||
selectedNodeRect = selectedNode.getBoundingClientRect();
|
catcherNodeRect = self.domNode.getBoundingClientRect();
|
||||||
variables["event-fromselected-posx"] = (event.clientX - selectedNodeRect.left).toString();
|
variables["event-fromcatcher-posx"] = (event.clientX - catcherNodeRect.left).toString();
|
||||||
variables["event-fromselected-posy"] = (event.clientY - selectedNodeRect.top).toString();
|
variables["event-fromcatcher-posy"] = (event.clientY - catcherNodeRect.top).toString();
|
||||||
|
|
||||||
//Add variables for event X and Y position relative to event catcher node
|
//Add variables for event X and Y position relative to the viewport
|
||||||
catcherNodeRect = self.domNode.getBoundingClientRect();
|
variables["event-fromviewport-posx"] = event.clientX.toString();
|
||||||
variables["event-fromcatcher-posx"] = (event.clientX - catcherNodeRect.left).toString();
|
variables["event-fromviewport-posy"] = event.clientY.toString();
|
||||||
variables["event-fromcatcher-posy"] = (event.clientY - catcherNodeRect.top).toString();
|
}
|
||||||
|
|
||||||
//Add variables for event X and Y position relative to the viewport
|
|
||||||
variables["event-fromviewport-posx"] = event.clientX.toString();
|
|
||||||
variables["event-fromviewport-posy"] = event.clientY.toString();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
Ładowanie…
Reference in New Issue