do not compute pageX only to convert it back to clientX
This commit is contained in:
parent
c5bc3d96e0
commit
6411152d00
4 changed files with 20 additions and 31 deletions
|
|
@ -1103,14 +1103,24 @@ var VirtualRenderer = function(container, theme) {
|
|||
// todo: handle horizontal scrolling
|
||||
};
|
||||
|
||||
this.screenToTextCoordinates = function(pageX, pageY) {
|
||||
this.pixelToScreenCoordinates = function(x, y) {
|
||||
var canvasPos = this.scroller.getBoundingClientRect();
|
||||
|
||||
var offset = (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth;
|
||||
var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight);
|
||||
var col = Math.round(offset);
|
||||
|
||||
return {row: row, column: col, side: offset - col};
|
||||
};
|
||||
|
||||
this.screenToTextCoordinates = function(x, y) {
|
||||
var canvasPos = this.scroller.getBoundingClientRect();
|
||||
|
||||
var col = Math.round(
|
||||
(pageX + this.scrollLeft - canvasPos.left - this.$padding - dom.getPageScrollLeft()) / this.characterWidth
|
||||
(x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth
|
||||
);
|
||||
var row = Math.floor(
|
||||
(pageY + this.scrollTop - canvasPos.top - dom.getPageScrollTop()) / this.lineHeight
|
||||
(y + this.scrollTop - canvasPos.top) / this.lineHeight
|
||||
);
|
||||
|
||||
return this.session.screenToDocumentPosition(row, Math.max(col, 0));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue