mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-06 15:30:26 +00:00
Fix new selection tracker to return relative coordinates
This commit is contained in:
parent
05d2c029a4
commit
cdf5d7bd4a
@ -139,9 +139,9 @@ SelectionTracker.prototype.handleSelectionChange = function() {
|
|||||||
var variables = {};
|
var variables = {};
|
||||||
// Get the bounds of the container and the selection
|
// Get the bounds of the container and the selection
|
||||||
var selectionRectangle = selection.getRangeAt(0).getBoundingClientRect(),
|
var selectionRectangle = selection.getRangeAt(0).getBoundingClientRect(),
|
||||||
trackingRectangle = anchor.container.parentNode.getBoundingClientRect();
|
offsetParentRectangle = anchor.container.offsetParent.getBoundingClientRect();
|
||||||
variables["tv-selection-posx"] = (selectionRectangle.left).toString();
|
variables["tv-selection-posx"] = (selectionRectangle.left - offsetParentRectangle.left).toString();
|
||||||
variables["tv-selection-posy"] = (selectionRectangle.top).toString();
|
variables["tv-selection-posy"] = (selectionRectangle.top - offsetParentRectangle.top).toString();
|
||||||
variables["tv-selection-width"] = (selectionRectangle.width).toString();
|
variables["tv-selection-width"] = (selectionRectangle.width).toString();
|
||||||
variables["tv-selection-height"] = (selectionRectangle.height).toString();
|
variables["tv-selection-height"] = (selectionRectangle.height).toString();
|
||||||
variables["tv-selection-coords"] = "(" + variables["tv-selection-posx"] + "," + variables["tv-selection-posy"] + "," + variables["tv-selection-width"] + "," + variables["tv-selection-height"] + ")";
|
variables["tv-selection-coords"] = "(" + variables["tv-selection-posx"] + "," + variables["tv-selection-posy"] + "," + variables["tv-selection-width"] + "," + variables["tv-selection-height"] + ")";
|
||||||
|
Loading…
Reference in New Issue
Block a user