Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F325752
offset_finder.service.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
offset_finder.service.js
View Options
export
const
findOffset
=
(
child
,
parent
,
{
top
=
0
,
left
=
0
}
=
{},
ignorePadding
=
true
)
=>
{
const
result
=
{
top
:
top
+
child
.
offsetTop
,
left
:
left
+
child
.
offsetLeft
}
if
(
!
ignorePadding
&&
child
!==
window
)
{
const
{
topPadding
,
leftPadding
}
=
findPadding
(
child
)
result
.
top
+=
ignorePadding
?
0
:
topPadding
result
.
left
+=
ignorePadding
?
0
:
leftPadding
}
if
(
child
.
offsetParent
&&
(
parent
===
window
||
parent
.
contains
(
child
.
offsetParent
)
||
parent
===
child
.
offsetParent
))
{
return
findOffset
(
child
.
offsetParent
,
parent
,
result
,
false
)
}
else
{
if
(
parent
!==
window
)
{
const
{
topPadding
,
leftPadding
}
=
findPadding
(
parent
)
result
.
top
+=
topPadding
result
.
left
+=
leftPadding
}
return
result
}
}
const
findPadding
=
(
el
)
=>
{
const
topPaddingStr
=
window
.
getComputedStyle
(
el
)[
'padding-top'
]
const
topPadding
=
Number
(
topPaddingStr
.
substring
(
0
,
topPaddingStr
.
length
-
2
))
const
leftPaddingStr
=
window
.
getComputedStyle
(
el
)[
'padding-left'
]
const
leftPadding
=
Number
(
leftPaddingStr
.
substring
(
0
,
leftPaddingStr
.
length
-
2
))
return
{
topPadding
,
leftPadding
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 24, 4:22 AM (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
94279
Default Alt Text
offset_finder.service.js (1 KB)
Attached To
Mode
rPUFE pleroma-fe-upstream
Attached
Detach File
Event Timeline
Log In to Comment