简体   繁体   English

handontable中的评论定位问题

[英]Comment positioning issue in handsontable

I am using handsontable's comment and scroll feature, but it results in wrong positioning of comment when scrolled. 我正在使用handsontable的注释滚动功能,但是滚动时会导致注释的位置错误。

Here is jsfiddle of code 这是代码的jsfiddle

Please scroll and then hover for comment, it shows comment div goes out of its position. 请滚动然后将鼠标悬停以发表评论,这表明评论div超出了其位置。

Objects attribute: 对象属性:

    data: getData(),   
    rowHeaders: true,
    colHeaders: true,
    minSpareRows: 1,
    contextMenu: true,
    comments: true,

I want it should come same as it comes without scrolling. 我希望它应该与不滚动时一样。

The problem is a bug in the placeCommentBox . 问题是placeCommentBox的错误。 It's getting an wrong offSet position 偏移位置错误

Based on this post , I modified handsontable.full.js .The placeCommentBox function should look like this: 在此基础上 ,我修改handsontable.full.js .The placeCommentBox功能应该是这样的:

 placeCommentBox = function (range, commentBox) {
  var TD = instance.view.wt.wtTable.getCell(range.from),
   // wrong offset offset = Handsontable.Dom.offset(TD),
    lastColWidth = instance.getColWidth(range.from.col);
    var rect = TD.getBoundingClientRect();
    var docEl = document.documentElement;
    var rectTop = rect.top + window.pageYOffset - docEl.clientTop;
  commentBox.style.position = 'absolute';
  commentBox.style.left = offset.left + lastColWidth + 'px';
  commentBox.style.top = rectTop + 'px';
  commentBox.style.zIndex = 2;
  bindMouseEvent(range, commentBox);
},

You can modify your file or wait for the to fix the bug. 您可以修改文件或等待修复该错误。

Edit handsontable.full.js -> refreshEditorPosition: function() 编辑handsontable.full.js > refreshEditorPosition: function()

Before setting position of editor just add window.pageXOffset 在设置编辑器位置之前,只需添加window.pageXOffset

// offset bug
x += window.pageXOffset;
this.editor.setPosition(x, y);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM