eventcatcher widget: Add viewport-relative coordinates

This is useful because we get viewport relative coordinates from the link and action-navigate widgets
This commit is contained in:
jeremy@jermolene.com 2021-08-05 08:35:44 +01:00
parent 97dff042f7
commit e9613d7f12
2 changed files with 7 additions and 1 deletions

View File

@ -86,6 +86,10 @@ EventWidget.prototype.render = function(parent,nextSibling) {
catcherNodeRect = self.domNode.getBoundingClientRect();
variables["event-fromcatcher-posx"] = (event.clientX - catcherNodeRect.left).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 {
return false;

View File

@ -1,5 +1,5 @@
created: 20201123113532200
modified: 20210711165425543
modified: 20210805083352068
tags: Widgets
title: EventCatcherWidget
type: text/vnd.tiddlywiki
@ -55,6 +55,8 @@ The following variables are made available to the actions:
|`event-fromselected-posy` |`y` position of the event relative to the selected DOM node |
|`event-fromcatcher-posx` |`x` position of the event relative to the event catcher DOM node |
|`event-fromcatcher-posy` |`y` position of the event relative to the event catcher DOM node |
|`event-fromviewport-posx` |<<.from-version "5.2.0">> `x` position of the event relative to the viewport |
|`event-fromviewport-posy` |<<.from-version "5.2.0">> `y` position of the event relative to the viewport |
! Example