Skip to content

Commit

Permalink
fix(Overlay): solve problems caused by numerical floating, close #4740
Browse files Browse the repository at this point in the history
  • Loading branch information
YSMJ1994 committed Feb 22, 2024
1 parent bd37853 commit 8f29094
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions components/overlay/utils/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ export default class Position {

// 此处若真实改变元素位置可能为导致布局发生变化,从而导致 container 发生 resize,进而重复触发 postion 和 componentUpdate,导致崩溃
// 需要根据新的 left、top 进行模拟计算 isInViewport
const xOffset = left + this.offset[0] - dom.getStyle(pinElement, 'left');
const yOffset = top + this.offset[1] - dom.getStyle(pinElement, 'top');
const xOffset = Math.round(left + this.offset[0] - dom.getStyle(pinElement, 'left'));
const yOffset = Math.round(top + this.offset[1] - dom.getStyle(pinElement, 'top'));

if (this._isInViewport(pinElement, align, [xOffset, yOffset])) {
// 如果在视区内,则设置 pin 位置,并中断 postion 返回设置的位置
this._setPinElementPostion(pinElement, { left, top }, this.offset);
Expand Down

0 comments on commit 8f29094

Please sign in to comment.