1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

tm-navigate: add separate properties to access bounds of client rectangle

Makes it easier to use the client rectangle information within an action handler
This commit is contained in:
jeremy@jermolene.com 2021-07-05 09:52:17 +01:00
parent 1b55eb9eee
commit 56068d8215
3 changed files with 19 additions and 1 deletions

View File

@ -70,6 +70,12 @@ NavigateWidget.prototype.invokeAction = function(triggeringWidget,event) {
navigateFromNode: triggeringWidget,
navigateFromClientRect: bounds && { top: bounds.top, left: bounds.left, width: bounds.width, right: bounds.right, bottom: bounds.bottom, height: bounds.height
},
navigateFromClientTop: bounds && bounds.top,
navigateFromClientLeft: bounds && bounds.left,
navigateFromClientWidth: bounds && bounds.width,
navigateFromClientRight: bounds && bounds.right,
navigateFromClientBottom: bounds && bounds.bottom,
navigateFromClientHeight: bounds && bounds.height,
navigateSuppressNavigation: suppressNavigation,
metaKey: event.metaKey,
ctrlKey: event.ctrlKey,

View File

@ -154,6 +154,12 @@ LinkWidget.prototype.handleClickEvent = function(event) {
navigateFromNode: this,
navigateFromClientRect: { top: bounds.top, left: bounds.left, width: bounds.width, right: bounds.right, bottom: bounds.bottom, height: bounds.height
},
navigateFromClientTop: bounds.top,
navigateFromClientLeft: bounds.left,
navigateFromClientWidth: bounds.width,
navigateFromClientRight: bounds.right,
navigateFromClientBottom: bounds.bottom,
navigateFromClientHeight: bounds.height,
navigateSuppressNavigation: event.metaKey || event.ctrlKey || (event.button === 1),
metaKey: event.metaKey,
ctrlKey: event.ctrlKey,

View File

@ -1,5 +1,5 @@
created: 20140226085215941
modified: 20140226085454346
modified: 20210705094948968
tags: Messages
title: WidgetMessage: tm-navigate
type: text/vnd.tiddlywiki
@ -13,6 +13,12 @@ The navigate message requires the following properties on the `event` object:
|navigateTo |Title of the tiddler that is being navigated |
|navigateFromTitle |Title of the tiddler from which the navigation was initiated |
|navigateFromClientRect |Bounding rectangle in client page coordinates of the element initiating the navigation |
|navigateFromClientTop |Y coordinate of top edge of bounding client rectangle |
|navigateFromClientLeft |X coordinate of left edge of bounding client rectangle |
|navigateFromClientWidth |Width of bounding client rectangle |
|navigateFromClientRight |X coordinate of right edge of bounding client rectangle |
|navigateFromClientBottom |Y coordinate of bottom edge of bounding client rectangle |
|navigateFromClientHeight |Height of bounding client rectangle |
|navigateSuppressNavigation |''true'' causes the new tiddler to only be added to the story, and not the history stack. This suppresses the scrolling associated with navigating to a tiddler |
The navigate message can be generated by the LinkWidget, the ActionNavigateWidget and the ButtonWidget, and is handled by the NavigatorWidget.