You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
first popup calculation without flip recalculation
{
width: 600px
left: 300px
right: 900px}
x viewport border for example is 600px
Our popup climbs out of the border, so we implement the recalculation of nextOffsetX. targetAlignPointTL.x = 300px popupAlignPointBR.x = 600px popupOffsetX = 0 nextOffsetX = 300px - 600px - 0 = -300px
Total we get that our popup left offset is -300px
and right 600px - 300px = 300px
And we observe approximately the following picture
In order to get the correct offset, you need to subtract the right coordinate of popup not from the left coordinate of the target, but from the right.
In other words, change targetAlignPointTL to targetAlignPointBR and get
viewport left border 0px popupOffsetX = 0px
then substituting into the current formula we get nextOffsetX = 300px - 0px - 0px = 300px
Popup offset is 300px this is the right border of the target.
Why not just take the left offset of target and make it equal to nextOffsetX?
Well, or as a last resort, add the right border of the target to the existing offset nextOffsetX = nextOffsetX + targetAlignPointBR.x = -200px + 300px = 100px
We will get the same 100px
In general, the problem is on the face and it brings a lot of inconvenience. Please pay attention to it!
The text was updated successfully, but these errors were encountered:
When recalculating nextOffsetY when popup goes beyond the viewport boundaries incorrect calculations occur.
I see problems in these lines:
trigger/src/hooks/useAlign.ts
Line 313 in a73beef
trigger/src/hooks/useAlign.ts
Line 327 in a73beef
Let's analyze each line separately.
suppose
the target's bounding box is
the popup's bounding box is
first popup calculation without flip recalculation
x viewport border for example is 600px
Our popup climbs out of the border, so we implement the recalculation of nextOffsetX.
targetAlignPointTL.x = 300px
popupAlignPointBR.x = 600px
popupOffsetX = 0
nextOffsetX = 300px - 600px - 0 = -300px
Total we get that our popup left offset is -300px
and right
600px - 300px = 300px
And we observe approximately the following picture
In order to get the correct offset, you need to subtract the right coordinate of popup not from the left coordinate of the target, but from the right.
In other words, change targetAlignPointTL to targetAlignPointBR and get
The situation is similar with Left to Right
if we take fake data
target bb
popup bb
popup calculated bb
viewport left border 0px
popupOffsetX = 0px
then substituting into the current formula we get
nextOffsetX = 300px - 0px - 0px = 300px
Popup offset is 300px this is the right border of the target.
Why not just take the left offset of target and make it equal to nextOffsetX?
Well, or as a last resort, add the right border of the target to the existing offset
nextOffsetX = nextOffsetX + targetAlignPointBR.x = -200px + 300px = 100px
We will get the same 100px
In general, the problem is on the face and it brings a lot of inconvenience. Please pay attention to it!
The text was updated successfully, but these errors were encountered: