Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pleroma-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
pleroma-fe
Commits
ce00954e
Commit
ce00954e
authored
2 years ago
by
HJ
Browse files
Options
Downloads
Patches
Plain Diff
turns out it is needed still + some code cleanup
parent
71b5462a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!1711
Update stable - 2.5.0 release
,
!1585
Fixing merge conflicts and lint for report notifications MR
,
!1540
Disjointed popovers
Pipeline
#40201
passed
2 years ago
Stage: lint
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/popover/popover.js
+26
-14
26 additions, 14 deletions
src/components/popover/popover.js
with
26 additions
and
14 deletions
src/components/popover/popover.js
+
26
−
14
View file @
ce00954e
...
...
@@ -58,10 +58,18 @@ const Popover = {
const
anchorEl
=
(
this
.
$refs
.
trigger
&&
this
.
$refs
.
trigger
.
children
[
0
])
||
this
.
$el
// SVGs don't have offsetWidth/Height, use fallback
const
anchorHeight
=
anchorEl
.
offsetHeight
||
anchorEl
.
clientHeight
const
anchorWidth
=
anchorEl
.
offsetWidth
||
anchorEl
.
clientWidth
const
anchorScreenBox
=
anchorEl
.
getBoundingClientRect
()
// Screen position of the origin point for popover
const
origin
=
{
x
:
anchorScreenBox
.
left
,
y
:
anchorScreenBox
.
top
}
const
anchorStyle
=
getComputedStyle
(
anchorEl
)
const
topPadding
=
parseFloat
(
anchorStyle
.
paddingTop
)
const
bottomPadding
=
parseFloat
(
anchorStyle
.
paddingBottom
)
// Screen position of the origin point for popover = center of the anchor
const
origin
=
{
x
:
anchorScreenBox
.
left
+
anchorWidth
*
0.5
,
y
:
anchorScreenBox
.
top
+
anchorHeight
*
0.5
}
const
content
=
this
.
$refs
.
content
// Minor optimization, don't call a slow reflow call if we don't have to
...
...
@@ -89,15 +97,17 @@ const Popover = {
max
:
window
.
innerHeight
-
(
margin
.
bottom
||
5
)
}
let
horizOffset
=
0
let
horizOffset
=
content
.
offsetWidth
*
-
0.5
const
leftBorder
=
origin
.
x
+
horizOffset
const
rightBorder
=
origin
.
x
-
horizOffset
// If overflowing from left, move it so that it doesn't
if
(
(
origin
.
x
)
<
xBounds
.
min
)
{
horizOffset
+=
-
origin
.
x
+
xBounds
.
min
if
(
leftBorder
<
xBounds
.
min
)
{
horizOffset
+=
xBounds
.
min
-
leftBorder
}
// If overflowing from right, move it so that it doesn't
if
(
(
o
rig
in
.
x
+
horizOffset
+
content
.
offsetWidth
)
>
xBounds
.
max
)
{
horizOffset
-=
(
o
rig
in
.
x
+
horizOffset
+
content
.
offsetWidth
)
-
xBounds
.
max
if
(
rig
htBorder
>
xBounds
.
max
)
{
horizOffset
-=
rig
htBorder
-
xBounds
.
max
}
// Default to whatever user wished with placement prop
...
...
@@ -106,23 +116,25 @@ const Popover = {
// Handle special cases, first force to displaying on top if there's not space on bottom,
// regardless of what placement value was. Then check if there's not space on top, and
// force to bottom, again regardless of what placement value was.
if
(
origin
.
y
+
content
.
offsetHeight
>
yBounds
.
max
)
usingTop
=
true
if
(
origin
.
y
-
content
.
offsetHeight
<
yBounds
.
min
)
usingTop
=
false
const
topBoundary
=
origin
.
y
-
anchorHeight
*
0.5
+
(
this
.
removePadding
?
topPadding
:
0
)
const
bottomBoundary
=
origin
.
y
+
anchorHeight
*
0.5
-
(
this
.
removePadding
?
bottomPadding
:
0
)
if
(
bottomBoundary
+
content
.
offsetHeight
>
yBounds
.
max
)
usingTop
=
true
if
(
topBoundary
-
content
.
offsetHeight
<
yBounds
.
min
)
usingTop
=
false
const
yOffset
=
(
this
.
offset
&&
this
.
offset
.
y
)
||
0
const
translateY
=
usingTop
?
yOffset
-
content
.
offsetHeight
:
yOffset
+
anchorHeigh
t
?
topBoundary
-
yOffset
-
content
.
offsetHeight
:
bottomBoundary
+
yOffse
t
const
xOffset
=
(
this
.
offset
&&
this
.
offset
.
x
)
||
0
const
translateX
=
horizOffset
+
xOffset
const
translateX
=
origin
.
x
+
horizOffset
+
xOffset
// Note, separate translateX and translateY avoids blurry text on chromium,
// single translate or translate3d resulted in blurry text.
this
.
styles
=
{
opacity
:
1
,
left
:
`
${
Math
.
round
(
origin
.
x
+
translateX
)}
px`
,
top
:
`
${
Math
.
round
(
origin
.
y
+
translateY
)}
px`
,
left
:
`
${
Math
.
round
(
translateX
)}
px`
,
top
:
`
${
Math
.
round
(
translateY
)}
px`
,
position
:
'
fixed
'
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment